diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-07-20 20:26:06 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-11 16:22:27 -0700 |
commit | 302f6adb79681da3fe53336f1e4c7525f46fd47d (patch) | |
tree | ce752cf002ec01cd9c26a804e49b2ee5b516d6ac /desktop-widgets/undocommands.h | |
parent | 12df9faaa2037b5155ebb84a7f6f6102491a0091 (diff) | |
download | subsurface-302f6adb79681da3fe53336f1e4c7525f46fd47d.tar.gz |
Undo: implement rudimentary support for undo of dive-splitting
For this, the core functionality of the split_dive() and
split_dive_at_time() functions were split out into new
split_dive_dont_insert() and split_dive_at_time_dont_insert(),
which do not add the new dives to the log. Thus, the undo-command
can take ownership of these dives, without having to remove them
first.
The split-dive functionality is temporarily made desktop-only
until mobile also supports "UndoObjects".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/undocommands.h')
-rw-r--r-- | desktop-widgets/undocommands.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/desktop-widgets/undocommands.h b/desktop-widgets/undocommands.h index 4c4073454..c30ae5fae 100644 --- a/desktop-widgets/undocommands.h +++ b/desktop-widgets/undocommands.h @@ -227,4 +227,23 @@ private: std::vector<OwningTripPtr> tripsToAdd; }; +class UndoSplitDives : public QUndoCommand { +public: + // If time is < 0, split at first surface interval + UndoSplitDives(dive *d, duration_t time); +private: + void undo() override; + void redo() override; + + // For redo + // For each dive to split, we remove one from and put two dives into the backend + dive *diveToSplit; + DiveToAdd splitDives[2]; + + // For undo + // For each dive to unsplit, we remove two dives from and add one into the backend + DiveToAdd unsplitDive; + dive *divesToUnsplit[2]; +}; + #endif // UNDOCOMMANDS_H |