summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 4930ac8..c6eb692 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -16,6 +16,7 @@
#include <QDebug>
#include "commands.h"
+#include "diagramdocument.h"
#include "databasetable.h"
#include "column.h"
@@ -143,3 +144,29 @@ MoveItemCommand::undo()
{
m_item->setPos(m_oldPos);
}
+
+
+AddItemCommand::AddItemCommand(DiagramDocument *document, DiagramItem *item, QUndoCommand *parent)
+ : QUndoCommand(parent), m_document(document), m_item(item), m_owner(true)
+{
+}
+
+AddItemCommand::~AddItemCommand()
+{
+ if (m_owner)
+ delete m_item;
+}
+
+void
+AddItemCommand::redo()
+{
+ m_document->addItem(m_item);
+ m_owner = false;
+}
+
+void
+AddItemCommand::undo()
+{
+ m_document->removeItem(m_item);
+ m_owner = true;
+}