From 00f4fa0d1da7b07efed340e5530dd966b22a1fc7 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Mon, 2 Jul 2018 21:13:44 +0200 Subject: Profile context menu entry to split a dive Allow the user to manually split a dive in two. Signed-off-by: Robert C. Helling --- profile-widget/profilewidget2.cpp | 17 +++++++++++++++++ profile-widget/profilewidget2.h | 1 + 2 files changed, 18 insertions(+) (limited to 'profile-widget') 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(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(sender()); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 1d85a125c..7c01a8139 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -115,6 +115,7 @@ slots: // Necessary to call from QAction's signals. void setAddState(); void changeGas(); void addSetpointChange(); + void splitDive(); void addBookmark(); void addDivemodeSwitch(); void hideEvents(); -- cgit v1.2.3-70-g09d2