diff options
author | Willem Ferguson <willemferguson@zoology.up.ac.za> | 2018-04-07 20:39:41 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-14 23:47:00 +0300 |
commit | e46cb2f8007e4767beef8b43a51e2824010875e8 (patch) | |
tree | ec045a4636f7483dc577a6a9b5ddaa4464304a82 | |
parent | 2a2098bab2766eec8e0b1d18e1f965b76ff022b5 (diff) | |
download | subsurface-e46cb2f8007e4767beef8b43a51e2824010875e8.tar.gz |
Create divemode switches using profile context menu
Allow the manual creation of divemode switch events using the
profile context menu.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
-rw-r--r-- | profile-widget/profilewidget2.cpp | 36 | ||||
-rw-r--r-- | profile-widget/profilewidget2.h | 3 |
2 files changed, 39 insertions, 0 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 62aa36114..3b61cee2f 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1413,6 +1413,12 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) setpointAction->setData(event->globalPos()); QAction *action = m.addAction(tr("Add bookmark"), this, SLOT(addBookmark())); action->setData(event->globalPos()); + QAction *OCAction = m.addAction(tr("Add OC switch"), this, SLOT(addOCSwitch())); + OCAction->setData(event->globalPos()); + QAction *CCRAction = m.addAction(tr("Add CCR switch"), this, SLOT(addCCRSwitch())); + CCRAction->setData(event->globalPos()); + QAction *PSCRAction = m.addAction(tr("Add PSCR switch"), this, SLOT(addPSCRSwitch())); + PSCRAction->setData(event->globalPos()); if (same_string(current_dc->model, "manually added dive")) m.addAction(tr("Edit the profile"), this, SIGNAL(editCurrentDive())); @@ -1574,6 +1580,36 @@ void ProfileWidget2::addBookmark() replot(); } +void ProfileWidget2::addOCSwitch() +{ + QAction *action = qobject_cast<QAction *>(sender()); + QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); + add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, 0, "modechange"); + invalidate_dive_cache(current_dive); + mark_divelist_changed(true); + replot(); +} + +void ProfileWidget2::addCCRSwitch() +{ + QAction *action = qobject_cast<QAction *>(sender()); + QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); + add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, 1, "modechange"); + invalidate_dive_cache(current_dive); + mark_divelist_changed(true); + replot(); +} + +void ProfileWidget2::addPSCRSwitch() +{ + QAction *action = qobject_cast<QAction *>(sender()); + QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); + add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, 2, "modechange"); + invalidate_dive_cache(current_dive); + mark_divelist_changed(true); + replot(); +} + void ProfileWidget2::addSetpointChange() { QAction *action = qobject_cast<QAction *>(sender()); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 0e44424ee..65a7d99c5 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -115,6 +115,9 @@ slots: // Necessary to call from QAction's signals. void changeGas(); void addSetpointChange(); void addBookmark(); + void addOCSwitch(); + void addCCRSwitch(); + void addPSCRSwitch(); void hideEvents(); void unhideEvents(); void removeEvent(); |