summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/undocommands.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-21 18:28:33 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commit014c04f8bd30740e7711f3b3a01619fd27b5b613 (patch)
tree0f7e505cc36e377bed4e24fb6f94adc93db22fb2 /desktop-widgets/undocommands.h
parent302f6adb79681da3fe53336f1e4c7525f46fd47d (diff)
downloadsubsurface-014c04f8bd30740e7711f3b3a01619fd27b5b613.tar.gz
Undo: implement rudimentary support for undo of dive-merging
For this, an output-parameter was added to the backend merge_dives() function. When non-zero, instead of adding the merged dive to the preferred trip, the preferred trip is returned to the caller. Since the new UndoObject, just like the delete-dives UndoObject, needs to remove/readd a set of dives, the corresponding functionality was split-off in a helper function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/undocommands.h')
-rw-r--r--desktop-widgets/undocommands.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/desktop-widgets/undocommands.h b/desktop-widgets/undocommands.h
index c30ae5fae..128c62e51 100644
--- a/desktop-widgets/undocommands.h
+++ b/desktop-widgets/undocommands.h
@@ -180,7 +180,7 @@ private:
void redo() override;
// For redo
- QVector<struct dive*> divesToDelete;
+ std::vector<struct dive*> divesToDelete;
std::vector<OwningTripPtr> tripsToAdd;
std::vector<DiveToAdd> divesToAdd;
@@ -246,4 +246,25 @@ private:
dive *divesToUnsplit[2];
};
+class UndoMergeDives : public QUndoCommand {
+public:
+ UndoMergeDives(const QVector<dive *> &dives);
+private:
+ void undo() override;
+ void redo() override;
+
+ // For redo
+ // Add one and remove a batch of dives
+ DiveToAdd mergedDive;
+ std::vector<dive *> divesToMerge;
+
+ // For undo
+ // Remove one and add a batch of dives
+ dive *diveToUnmerge;
+ std::vector<DiveToAdd> unmergedDives;
+
+ // For undo and redo
+ QVector<QPair<int, int>> divesToRenumber;
+};
+
#endif // UNDOCOMMANDS_H