diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-05-17 22:22:55 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-05-20 21:23:16 -0700 |
commit | eba6e76b963115a77b5f8607bc6c3ea1040a466f (patch) | |
tree | e926eb7112a902561c1b66f4d6a342ec2a7134b5 /desktop-widgets/command_divelist.h | |
parent | f0307abf50397da79671ce79707eb4ce1f78acd0 (diff) | |
download | subsurface-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.h | 17 |
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); |