summaryrefslogtreecommitdiff
path: root/tikzit/src/gui/undocommands.h
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/gui/undocommands.h')
-rw-r--r--tikzit/src/gui/undocommands.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/tikzit/src/gui/undocommands.h b/tikzit/src/gui/undocommands.h
index bb6a8e9..c1b4910 100644
--- a/tikzit/src/gui/undocommands.h
+++ b/tikzit/src/gui/undocommands.h
@@ -1,5 +1,8 @@
/**
- * These classes store the data required to undo/redo a single UI action.
+ * All changes to a TikzDocument are done via subclasses of QUndoCommand. When a controller
+ * (e.g. TikzScene) gets input from the user to change the document, it will push one of
+ * these commands onto the TikzDocument's undo stack, which automatically calls the redo()
+ * method of the command.
*/
#ifndef UNDOCOMMANDS_H
@@ -45,4 +48,31 @@ private:
int _newOutAngle;
};
+class DeleteCommand : public QUndoCommand
+{
+public:
+ explicit DeleteCommand(TikzScene *scene,
+ QMap<int,Node*> deleteNodes,
+ QMap<int,Edge*> deleteEdges,
+ QSet<Edge*> selEdges);
+ void undo() override;
+ void redo() override;
+private:
+ TikzScene *_scene;
+ QMap<int,Node*> _deleteNodes;
+ QMap<int,Edge*> _deleteEdges;
+ QSet<Edge*> _selEdges;
+};
+
+class AddNodeCommand : public QUndoCommand
+{
+public:
+ explicit AddNodeCommand(TikzScene *scene, Node *node);
+ void undo() override;
+ void redo() override;
+private:
+ TikzScene *_scene;
+ Node *_node;
+};
+
#endif // UNDOCOMMANDS_H