30 #include "../../../../core/pattern/mvc/ItemObserver.h"
31 #include "../../../../core/enum/EnumType.h"
32 #include "../../../../core/pattern/mvc/Observable.h"
33 #include "../../Scene.h"
34 #include "../../../../core/pattern/singleton/Context.h"
37 #include <QGraphicsItem>
40 QUndoCommand *parent ) :
49 QUndoCommand *parent ) :
54 std::map<QGraphicsItem*, QPointF>::iterator it;
57 QGraphicsItem* item = it->first;
58 QPointF ptNew = item->scenePos();
72 m_item->setPos(m_oldPos);
73 m_item->scene()->update();
74 setText(QObject::tr(
"Move %1")
75 .arg(createCommandString(m_item, m_oldPos)));
78 if(m_moveItems.empty())
81 int size = m_moveItems.size();
83 std::map<QGraphicsItem*, QPointF>::iterator it;
84 for (it = m_moveItems.begin(); it != m_moveItems.end(); ++it)
86 QGraphicsItem* item = it->first;
87 QPointF ptOld = it->second;
93 setText(QObject::tr(
"Move %1").arg(size));
100 m_item->setPos(m_newPos);
101 setText(QObject::tr(
"Move %1")
102 .arg(createCommandString(m_item, m_newPos)));
105 if(m_moveItems.empty())
108 if(m_moveItems.size() != m_itemsPoints.size())
118 bool resultFound =
false;
122 const QUndoCommand* cmd = sc->
getUndoStack()->command(i);
129 int size = m_moveItems.size();
136 std::map<QGraphicsItem*, QPointF>::iterator it;
137 for (it = m_moveItems.begin(); it != m_moveItems.end(); ++it)
139 QGraphicsItem* item = it->first;
140 QPointF ptNew = m_itemsPoints[index];
147 setText(QObject::tr(
"Move %1").arg(size));
153 return QObject::tr(
"%1");
158 return QObject::tr(
"%1");
160 return QObject::tr(
"%1 at (%2, %3)")
162 .arg(pos.x()).arg(pos.y());
std::string getName()
Returns name.
MoveCommand(QGraphicsItem *item, const QPointF oldPos, QUndoCommand *parent=0)
Constructor.
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
QList< QPointF > m_itemsPoints
virtual EnumType * getType()=0
Returns the type of component Reimplement this function in a Observable subclass to provide the model...
static Context & getInstance()
It returns a reference to the singleton instance.
virtual QUndoStack * getUndoStack()
Method that return stack of Undo/Redo.
Undo/Redo for moving components.
virtual void undo()
Reimplemented from QUndoCommand.
virtual QString createCommandString(QGraphicsItem *item, const QPointF &pos)
std::map< QGraphicsItem *, QPointF > m_moveItems
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
virtual void redo()
Reimplemented from QUndoCommand.
virtual Observable * getModel()
Returns the "Model" part of the MVC.
AbstractScene * getScene()
Returns abstract scene for QGraphicsScene class, part of Graphics View Framework. ...
virtual ~MoveCommand()
Destructor.