summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_divelist.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-31 10:20:13 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-04 09:38:12 -0700
commit145f70aab59a5ebd1b4ca82432caf38b4821b055 (patch)
tree2527f595c552559ffe74e6cce39f3c52283762d9 /desktop-widgets/command_divelist.h
parent8c9e5becb20d2d8c8aa1f7108775cc520b08fae1 (diff)
downloadsubsurface-145f70aab59a5ebd1b4ca82432caf38b4821b055.tar.gz
Undo: implement split-out of dive computer
Allow splitting out a dive computer into a distinct dive. This is realized by generating a base class from SplitDive. This turned out to be more cumbersome than expected: we don't know a-priori which of the split dives will come first. Since the undo-command saves the indices where the dives will be insert, these have to be calculated. This is an premature optimization, which makes more pain than necessary. Let's remove it and simply determine the insertion index when executing the command. Original code by Linus Torvalds <torvalds@linux-foundation.org>. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/command_divelist.h')
-rw-r--r--desktop-widgets/command_divelist.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/desktop-widgets/command_divelist.h b/desktop-widgets/command_divelist.h
index 6cf7f48ab..7742cf729 100644
--- a/desktop-widgets/command_divelist.h
+++ b/desktop-widgets/command_divelist.h
@@ -185,10 +185,9 @@ struct MergeTrips : public TripBase {
MergeTrips(dive_trip *trip1, dive_trip *trip2);
};
-class SplitDives : public DiveListBase {
-public:
- // If time is < 0, split at first surface interval
- SplitDives(dive *d, duration_t time);
+class SplitDivesBase : public DiveListBase {
+protected:
+ SplitDivesBase(dive *old, std::array<dive *, 2> newDives);
private:
void undoit() override;
void redoit() override;
@@ -209,6 +208,18 @@ private:
std::vector<dive *> divesToUnsplit;
};
+class SplitDives : public SplitDivesBase {
+public:
+ // If time is < 0, split at first surface interval
+ SplitDives(dive *d, duration_t time);
+};
+
+class SplitDiveComputer : public SplitDivesBase {
+public:
+ // If time is < 0, split at first surface interval
+ SplitDiveComputer(dive *d, int dc_num);
+};
+
class MergeDives : public DiveListBase {
public:
MergeDives(const QVector<dive *> &dives);