summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_divelist.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-17 22:22:55 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-20 21:23:16 -0700
commiteba6e76b963115a77b5f8607bc6c3ea1040a466f (patch)
treee926eb7112a902561c1b66f4d6a342ec2a7134b5 /desktop-widgets/command_divelist.h
parentf0307abf50397da79671ce79707eb4ce1f78acd0 (diff)
downloadsubsurface-eba6e76b963115a77b5f8607bc6c3ea1040a466f.tar.gz
Undo: make "move dive computer to front" undoable
Instead of the elegant solution that just modifies the dive, keep two copies and add either the old or the new copy. This is primitive, but it trivially keeps the dives in the right order. The order might change on renumbering the dive computers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divelist.h')
-rw-r--r--desktop-widgets/command_divelist.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/desktop-widgets/command_divelist.h b/desktop-widgets/command_divelist.h
index 2d3ee8db1..d46697454 100644
--- a/desktop-widgets/command_divelist.h
+++ b/desktop-widgets/command_divelist.h
@@ -236,6 +236,23 @@ public:
SplitDiveComputer(dive *d, int dc_num);
};
+// When moving the dive computer to the front, we go the ineffective,
+// but easy way: We keep two full copies of the dive (before and after).
+// Removing and readding assures that the dive stays at the correct
+// position in the list (the dive computer list is used for sorting dives).
+class MoveDiveComputerToFront : public DiveListBase {
+public:
+ MoveDiveComputerToFront(dive *d, int dc_num);
+private:
+ void undoit() override;
+ void redoit() override;
+ bool workToBeDone() override;
+
+ // For redo and undo
+ DivesAndTripsToAdd diveToAdd;
+ DivesAndSitesToRemove diveToRemove;
+};
+
class MergeDives : public DiveListBase {
public:
MergeDives(const QVector<dive *> &dives);