summaryrefslogtreecommitdiffstats
path: root/qt-ui/undocommands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/undocommands.cpp')
-rw-r--r--qt-ui/undocommands.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp
index 316def495..6a15f7e03 100644
--- a/qt-ui/undocommands.cpp
+++ b/qt-ui/undocommands.cpp
@@ -62,3 +62,34 @@ void UndoShiftTime::redo()
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
}
+
+
+UndoRenumberDives::UndoRenumberDives(QMap<int, int> originalNumbers, int startNumber)
+{
+ oldNumbers = originalNumbers;
+ start = startNumber;
+ setText("renumber dive");
+ if (oldNumbers.count() > 1)
+ setText(QString("renumber %1 dives").arg(QString::number(oldNumbers.count())));
+}
+
+void UndoRenumberDives::undo()
+{
+ foreach (int key, oldNumbers.keys()) {
+ struct dive* d = get_dive_by_uniq_id(key);
+ d->number = oldNumbers.value(key);
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}
+
+void UndoRenumberDives::redo()
+{
+ int i = start;
+ foreach (int key, oldNumbers.keys()) {
+ struct dive* d = get_dive_by_uniq_id(key);
+ d->number = i++;
+ }
+ mark_divelist_changed(true);
+ MainWindow::instance()->refreshDisplay();
+}