NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnstchangecommand.cpp
1 #include "qnstchangecommand.h"
2 
3 QnstChangeCommand::QnstChangeCommand(QnstView* view, QString uid,
4  const QMap<QString,QString> &properties)
5 {
6  this->uid = uid;
7  this->view = view;
8 
9  if (view->entities.contains(uid))
10  {
11  QnstGraphicsEntity* entity = view->entities[uid];
12 
13  previous["top"] = QString::number(entity->getTop());
14  previous["left"] = QString::number(entity->getLeft());
15  previous["width"] = QString::number(entity->getWidth());
16  previous["height"] = QString::number(entity->getHeight());
17  }
18 
19  next = properties;
20 
21  ignore = true;
22 }
23 
24 QnstChangeCommand::~QnstChangeCommand()
25 {
26 
27 }
28 
29 void QnstChangeCommand::undo()
30 {
31  if (view->entities.contains(uid))
32  {
33  QnstGraphicsEntity* entity = view->entities[uid];
34 
35  entity->setProperties(previous);
36 
37  entity->adjust();
38  }
39 }
40 
41 void QnstChangeCommand::redo()
42 {
43  if (!ignore)
44  {
45  if (view->entities.contains(uid))
46  {
47  QnstGraphicsEntity* entity = view->entities[uid];
48 
49  entity->setProperties(next);
50 
51  entity->adjust();
52  }
53  }
54  else
55  {
56  ignore = false;
57  }
58 }