summaryrefslogtreecommitdiffstats
path: root/qt-ui/undocommands.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-04-10 09:39:51 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-14 10:29:15 -0700
commit193edd9f13b4a1a6cbddd494de6b7aa38709be95 (patch)
tree0e2c4a9cdc0289b09933746973ec5476aa404bc2 /qt-ui/undocommands.cpp
parent8e32faa866a144fc29a806a7e61a72e7eaf2a9e4 (diff)
downloadsubsurface-193edd9f13b4a1a6cbddd494de6b7aa38709be95.tar.gz
Add ability to undo removing of dives from trips
Add the functionality to undo/redo removing of dives from trips. The code calling remove_dive_from_trip has moved to the UndoCommands class. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/undocommands.cpp')
-rw-r--r--qt-ui/undocommands.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp
index be27e27dc..aad264e24 100644
--- a/qt-ui/undocommands.cpp
+++ b/qt-ui/undocommands.cpp
@@ -92,3 +92,32 @@ void UndoRenumberDives::redo()
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
}
+
+
+UndoRemoveDivesFromTrip::UndoRemoveDivesFromTrip(QMap<dive *, dive_trip *> removedDives)
+{
+ divesToUndo = removedDives;
+ setText("remove dive(s) from trip");
+}
+
+void UndoRemoveDivesFromTrip::undo()
+{
+ QMapIterator<dive*, dive_trip*> i(divesToUndo);
+ while (i.hasNext()) {
+ i.next();
+ add_dive_to_trip(i.key (), i.value());
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}
+
+void UndoRemoveDivesFromTrip::redo()
+{
+ QMapIterator<dive*, dive_trip*> i(divesToUndo);
+ while (i.hasNext()) {
+ i.next();
+ remove_dive_from_trip(i.key(), false);
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}