summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-02-11 10:57:56 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-11 08:07:23 -0800
commit60a7404ed4c79398c08a9d83d6575a3381c999a1 (patch)
tree07e6d398f93f5dad7c42da1089cf832e07611fe8 /qt-ui/divelistview.cpp
parent6d996a78742deb349cc1cb66ddea6abfb1b813d5 (diff)
downloadsubsurface-60a7404ed4c79398c08a9d83d6575a3381c999a1.tar.gz
Add option to undo deleted dives
Add ability to undo deleted dives by storing a list of the deleted dives in a QUndoCommand. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index b866a1aa1..e4ccb7208 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -14,6 +14,7 @@
#include <QKeyEvent>
#include <QFileDialog>
#include "qthelper.h"
+#include "undocommands.h"
// # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc
static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500};
@@ -731,13 +732,19 @@ void DiveListView::deleteDive()
// so instead of using the for_each_dive macro I'm using an explicit for loop
// to make this easier to understand
int lastDiveNr = -1;
+ QList<struct dive*> deletedDives; //a list of all deleted dives to be stored in the undo command
for_each_dive (i, d) {
if (!d->selected)
continue;
+ struct dive* undo_entry = alloc_dive();
+ copy_dive(get_dive(i), undo_entry);
+ deletedDives.append(undo_entry);
delete_single_dive(i);
i--; // so the next dive isn't skipped... it's now #i
lastDiveNr = i;
}
+ UndoDeleteDive *undoEntry = new UndoDeleteDive(deletedDives);
+ MainWindow::instance()->undoStack->push(undoEntry);
if (amount_selected == 0) {
MainWindow::instance()->cleanUpEmpty();
}