summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-02-09 09:44:10 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-09 21:02:19 -0800
commitd60a6201931ed11e019e7582a6d6f72d6f4e0400 (patch)
tree39d99b9267d924ca97bfe8435c56aa640e03fe3e /qt-ui/divelistview.cpp
parent8d1e4557a96f81a4cf263ea3d4e2228222d99e42 (diff)
downloadsubsurface-d60a6201931ed11e019e7582a6d6f72d6f4e0400.tar.gz
Add ability to undo deleted dives
Before the dive is deleted, a copy is made and passed to the undo buffer. When edit->undo is clicked, this dive is restored to the dive list. 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.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index ec54af906..89b851aab 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -11,6 +11,7 @@
#include <QSettings>
#include <QFileDialog>
#include "qthelper.h"
+#include "undobuffer.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};
@@ -730,6 +731,9 @@ void DiveListView::deleteDive()
for_each_dive (i, d) {
if (!d->selected)
continue;
+ struct dive* undo_entry = alloc_dive();
+ copy_dive(get_dive(i), undo_entry);
+ MainWindow::instance()->undoBuffer->recordbefore("Delete Dive", undo_entry);
delete_single_dive(i);
i--; // so the next dive isn't skipped... it's now #i
lastDiveNr = i;