summaryrefslogtreecommitdiffstats
path: root/qt-ui/undobuffer.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-02-11 09:10:34 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-11 07:59:46 -0800
commit013da6b0af3e3dd5d074f2dbbc342d9b948717b4 (patch)
tree4bc4cf314e0088f1c76736e45d3d7dcb817a0baf /qt-ui/undobuffer.cpp
parent6374d9cc0334c7dc7af908b4cb9233a091a48740 (diff)
downloadsubsurface-013da6b0af3e3dd5d074f2dbbc342d9b948717b4.tar.gz
Reverse undo buffer
Reverse all the code using the UndoBuffer class so that we can use the QUndoStack and QUndoCommand classes. These are Qt's own inbuild undo framework classes, offering a better undo/redo process. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/undobuffer.cpp')
-rw-r--r--qt-ui/undobuffer.cpp78
1 files changed, 0 insertions, 78 deletions
diff --git a/qt-ui/undobuffer.cpp b/qt-ui/undobuffer.cpp
deleted file mode 100644
index 4ee0cf608..000000000
--- a/qt-ui/undobuffer.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "undobuffer.h"
-#include "mainwindow.h"
-
-UndoBuffer::UndoBuffer(QObject *parent) : QObject(parent)
-{
- curIdx = 0;
-}
-
-UndoBuffer::~UndoBuffer()
-{
-
-}
-
-bool UndoBuffer::canUndo()
-{
- return curIdx > 0;
-}
-
-bool UndoBuffer::canRedo()
-{
- return curIdx < list.count();
-}
-
-void UndoBuffer::redo()
-{
- current()->redo();
- curIdx++;
- if (curIdx > list.count())
- curIdx = list.count() - 1;
-}
-
-void UndoBuffer::undo()
-{
- current()->undo();
- curIdx = list.indexOf(current());
-}
-
-void UndoBuffer::recordbefore(QString commandName, dive *affectedDive)
-{
- UndoCommand *cmd = new UndoCommand(commandName, affectedDive);
- //If we are within the list, clear the extra UndoCommands.
- if (list.count() > 0) {
- if (curIdx + 1 < list.count()) {
- for (int i = curIdx + 1; i < list.count(); i++) {
- list.removeAt(i);
- }
- }
- }
- list.append(cmd);
- curIdx = list.count();
-}
-
-void UndoBuffer::recordAfter(dive *affectedDive)
-{
- list.at(curIdx - 1)->setStateAfter(affectedDive);
-}
-
-
-
-UndoCommand::UndoCommand(QString commandName, dive *affectedDive)
-{
- name = commandName;
- stateBefore = affectedDive;
-}
-
-void UndoCommand::undo()
-{
- if (name == "Delete Dive") {
- record_dive(stateBefore);
- MainWindow::instance()->recreateDiveList();
- }
-}
-
-void UndoCommand::redo()
-{
- //To be implemented
-}
-