summaryrefslogtreecommitdiff
path: root/tikzit/src/gui/undocommands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/gui/undocommands.cpp')
-rw-r--r--tikzit/src/gui/undocommands.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/tikzit/src/gui/undocommands.cpp b/tikzit/src/gui/undocommands.cpp
index 997bf75..736c258 100644
--- a/tikzit/src/gui/undocommands.cpp
+++ b/tikzit/src/gui/undocommands.cpp
@@ -2,6 +2,8 @@
#include "nodeitem.h"
#include "edgeitem.h"
+#include <QGraphicsView>
+
MoveCommand::MoveCommand(TikzScene *scene,
QMap<Node*, QPointF> oldNodePositions,
QMap<Node*, QPointF> newNodePositions,
@@ -131,9 +133,10 @@ void DeleteCommand::redo()
}
}
-AddNodeCommand::AddNodeCommand(TikzScene *scene, Node *node) :
- _scene(scene), _node(node)
-{}
+AddNodeCommand::AddNodeCommand(TikzScene *scene, Node *node, QRectF newBounds) :
+ _scene(scene), _node(node), _oldBounds(_scene->sceneRect()), _newBounds(newBounds)
+{
+}
void AddNodeCommand::undo()
{
@@ -143,6 +146,8 @@ void AddNodeCommand::undo()
delete ni;
_scene->graph()->removeNode(_node);
+
+ _scene->setBounds(_oldBounds);
}
void AddNodeCommand::redo()
@@ -152,4 +157,6 @@ void AddNodeCommand::redo()
NodeItem *ni = new NodeItem(_node);
_scene->nodeItems().insert(_node, ni);
_scene->addItem(ni);
+
+ _scene->setBounds(_newBounds);
}