diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-31 10:20:13 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-04 09:38:12 -0700 |
commit | 145f70aab59a5ebd1b4ca82432caf38b4821b055 (patch) | |
tree | 2527f595c552559ffe74e6cce39f3c52283762d9 /profile-widget | |
parent | 8c9e5becb20d2d8c8aa1f7108775cc520b08fae1 (diff) | |
download | subsurface-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 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 9 | ||||
-rw-r--r-- | profile-widget/profilewidget2.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 5d282fd95..157ab9fcd 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1436,8 +1436,10 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) // create menu to show when right clicking on dive computer name if (dc_number > 0) m.addAction(tr("Make first dive computer"), this, SLOT(makeFirstDC())); - if (count_divecomputers() > 1) + if (count_divecomputers() > 1) { m.addAction(tr("Delete this dive computer"), this, SLOT(deleteCurrentDC())); + m.addAction(tr("Split this dive computer into own dive"), this, SLOT(splitCurrentDC())); + } m.exec(event->globalPos()); // don't show the regular profile context menu return; @@ -1581,6 +1583,11 @@ void ProfileWidget2::deleteCurrentDC() emit refreshDisplay(true); } +void ProfileWidget2::splitCurrentDC() +{ + Command::splitDiveComputer(current_dive, dc_number); +} + void ProfileWidget2::makeFirstDC() { make_first_dc(); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 443b83c64..4cf69efa6 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -126,6 +126,7 @@ slots: // Necessary to call from QAction's signals. void editName(); void makeFirstDC(); void deleteCurrentDC(); + void splitCurrentDC(); void pointInserted(const QModelIndex &parent, int start, int end); void pointsRemoved(const QModelIndex &, int start, int end); void updateThumbnail(QString filename, QImage thumbnail, duration_t duration); |