diff options
author | Robert C. Helling <helling@atdotde.de> | 2018-07-02 21:13:44 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-07-03 14:47:15 -0700 |
commit | 00f4fa0d1da7b07efed340e5530dd966b22a1fc7 (patch) | |
tree | 3b221380f8db65ce05c02a0d8473c5a2e4c059d8 /profile-widget/profilewidget2.cpp | |
parent | 8697f7a84d988155e13079e32a7dd00fe418ee42 (diff) | |
download | subsurface-00f4fa0d1da7b07efed340e5530dd966b22a1fc7.tar.gz |
Profile context menu entry to split a dive
Allow the user to manually split a dive in two.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index bf8649834..1e1599937 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -21,6 +21,7 @@ #include "desktop-widgets/diveplanner.h" #include "desktop-widgets/simplewidgets.h" #include "desktop-widgets/divepicturewidget.h" +#include "desktop-widgets/mainwindow.h" #include "core/qthelper.h" #include "core/gettextfromc.h" #endif @@ -1427,6 +1428,8 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) setpointAction->setData(event->globalPos()); QAction *action = m.addAction(tr("Add bookmark"), this, SLOT(addBookmark())); action->setData(event->globalPos()); + QAction *splitAction = m.addAction(tr("Split dive into two"), this, SLOT(splitDive())); + splitAction->setData(event->globalPos()); struct event *ev = NULL; enum divemode_t divemode = UNDEF_COMP_TYPE; QPointF scenePos = mapToScene(mapFromGlobal(event->globalPos())); @@ -1640,6 +1643,20 @@ void ProfileWidget2::addSetpointChange() SetpointDialog::instance()->show(); } +void ProfileWidget2::splitDive() +{ + QAction *action = qobject_cast<QAction *>(sender()); + QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); + duration_t time; + time.seconds = lrint(timeAxis->valueAt((scenePos))); + split_dive_at_time(&displayed_dive, time); + emit updateDiveInfo(false); + mark_divelist_changed(true); + replot(); + MainWindow::instance()->refreshProfile(); + MainWindow::instance()->refreshDisplay(); +} + void ProfileWidget2::changeGas() { QAction *action = qobject_cast<QAction *>(sender()); |