10 #include "util/Commands.h"
12 #include "modules/MessageControl.h"
13 #include "modules/ProjectControl.h"
20 QMap <QString, QString> newAttrs, QUndoCommand *parent)
21 : QUndoCommand(parent)
23 this->project = project;
25 this->uniqueId = entity->getUniqueId();
26 QMap <QString, QString>::iterator begin, end, it;
28 for (it = begin; it != end; ++it)
29 attrs[it.key()] = it.value();
30 this->newAttrs = newAttrs;
32 msgControl = PluginControl::getInstance()->getMessageControl(project);
35 void EditCommand::undo()
37 msgControl->anonymousChangeEntity(this->uniqueId, this->attrs);
40 void EditCommand::redo()
42 msgControl->anonymousChangeEntity(this->uniqueId, this->newAttrs);
45 RemoveCommand::RemoveCommand(
Project *project,
Entity *entity,
48 this->parentUniqueId = entity->getParentUniqueId();
49 this->entity = entity;
50 this->project = project;
52 msgControl = PluginControl::getInstance()->getMessageControl(project);
57 void RemoveCommand::undo()
59 msgControl->anonymousAddEntity(this->entity, parentUniqueId);
69 void RemoveCommand::redo()
76 msgControl->anonymousRemoveEntity(this->entity->getUniqueId());
78 this->entity = entityTmp;
81 AddCommand::AddCommand(
Project *project,
Entity *entity, QString parentUniqueId,
84 this->parentUniqueId = parentUniqueId;
85 this->entity = entity;
86 this->project = project;
90 msgControl = PluginControl::getInstance()->getMessageControl(project);
93 void AddCommand::undo()
97 msgControl->anonymousRemoveEntity(this->entity->getUniqueId());
102 void AddCommand::redo()
108 project->
addEntity(this->entity, parentUniqueId);
110 msgControl->anonymousAddEntity(this->entity, parentUniqueId);
112 this->entity = entityTmp;