summaryrefslogtreecommitdiffstats
path: root/qt-ui/undocommands.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-02-14 20:12:05 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-14 15:46:37 -0800
commit87ee8e8aef00f2e183c57a93754717ea41da9179 (patch)
treea10a2297438a290daa8f4648b362bdc7784c9d37 /qt-ui/undocommands.cpp
parent824cc90a9a489fbd08b480c83d17c2dfb523a1a8 (diff)
downloadsubsurface-87ee8e8aef00f2e183c57a93754717ea41da9179.tar.gz
Add ability to undo shifting of dive time
Adds the ability to undo shifting of dive times. The change is captured at simplewidgets.cpp and an undo command is created. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/undocommands.cpp')
-rw-r--r--qt-ui/undocommands.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp
index 8c58c7c96..316def495 100644
--- a/qt-ui/undocommands.cpp
+++ b/qt-ui/undocommands.cpp
@@ -34,3 +34,31 @@ void UndoDeleteDive::redo()
dives.clear();
dives = newList;
}
+
+
+UndoShiftTime::UndoShiftTime(QList<int> diveList, int amount)
+{
+ setText("shift time");
+ dives = diveList;
+ timeChanged = amount;
+}
+
+void UndoShiftTime::undo()
+{
+ for (int i = 0; i < dives.count(); i++) {
+ struct dive* d = get_dive_by_uniq_id(dives.at(i));
+ d->when -= timeChanged;
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}
+
+void UndoShiftTime::redo()
+{
+ for (int i = 0; i < dives.count(); i++) {
+ struct dive* d = get_dive_by_uniq_id(dives.at(i));
+ d->when += timeChanged;
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}