From 8d1e4557a96f81a4cf263ea3d4e2228222d99e42 Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Mon, 9 Feb 2015 09:30:27 +0100 Subject: [PATCH] Add UndoCommand class Add a class to handle all undo/redo events. Whenever a user action affects a dive, an undo command will be created. A list of these commands will be stored in the UndoBuffer, to allow for moving forwards/backwards in the list. Signed-off-by: Grace Karanja Signed-off-by: Dirk Hohndel --- qt-ui/undobuffer.cpp | 18 ++++++++++++++++++ qt-ui/undobuffer.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/qt-ui/undobuffer.cpp b/qt-ui/undobuffer.cpp index fd74466be..1812f6f7a 100644 --- a/qt-ui/undobuffer.cpp +++ b/qt-ui/undobuffer.cpp @@ -39,3 +39,21 @@ void UndoBuffer::recordAfter(dive *affectedDive) { } + + + +UndoCommand::UndoCommand(QString commandName, dive *affectedDive) +{ + name = commandName; + stateBefore = affectedDive; +} + +void UndoCommand::undo() +{ + +} + +void UndoCommand::redo() +{ + +} diff --git a/qt-ui/undobuffer.h b/qt-ui/undobuffer.h index a292d3ba7..beae8e390 100644 --- a/qt-ui/undobuffer.h +++ b/qt-ui/undobuffer.h @@ -4,6 +4,19 @@ #include #include "dive.h" +class UndoCommand { +private: + dive* stateBefore; + dive* stateAfter; + QString name; + +public: + explicit UndoCommand(QString commandName, dive* affectedDive); + void setStateAfter(dive* affectedDive); + void undo(); + void redo(); +}; + class UndoBuffer : public QObject { Q_OBJECT