2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
9 #include "SetPropertiesCommand.h"
16 #include "CommonPropertyIDs.h"
17 #include "IconObject.h"
19 #include "PropertyObject.h"
22 #undef B_TRANSLATION_CONTEXT
23 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-Properties"
27 SetPropertiesCommand::SetPropertiesCommand(IconObject
** objects
,
29 PropertyObject
* previous
,
30 PropertyObject
* current
)
33 fObjectCount(objectCount
),
35 fOldProperties(previous
),
36 fNewProperties(current
)
41 SetPropertiesCommand::~SetPropertiesCommand()
44 delete fOldProperties
;
45 delete fNewProperties
;
50 SetPropertiesCommand::InitCheck()
52 return fObjects
&& fOldProperties
&& fNewProperties
53 && fObjectCount
> 0 && fOldProperties
->CountProperties() > 0
54 && fOldProperties
->ContainsSameProperties(*fNewProperties
) ?
60 SetPropertiesCommand::Perform()
62 for (int32 i
= 0; i
< fObjectCount
; i
++) {
64 fObjects
[i
]->SetToPropertyObject(fNewProperties
);
71 SetPropertiesCommand::Undo()
73 for (int32 i
= 0; i
< fObjectCount
; i
++) {
75 fObjects
[i
]->SetToPropertyObject(fOldProperties
);
82 SetPropertiesCommand::GetName(BString
& name
)
84 if (fOldProperties
->CountProperties() > 1) {
86 name
<< B_TRANSLATE("Multi Paste Properties");
88 name
<< B_TRANSLATE("Paste Properties");
90 BString property
= name_for_id(
91 fOldProperties
->PropertyAt(0)->Identifier());
93 name
<< B_TRANSLATE_CONTEXT("Multi Set ",
94 "Multi Set (property name)") << property
;
96 name
<< B_TRANSLATE_CONTEXT("Set ", "Set (property name)")