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>
This commit is contained in:
Robert C. Helling 2018-07-02 21:13:44 +02:00 committed by Dirk Hohndel
parent 8697f7a84d
commit 00f4fa0d1d
4 changed files with 39 additions and 0 deletions

View file

@ -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());