summaryrefslogtreecommitdiffstats
path: root/profile-widget/profilewidget2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r--profile-widget/profilewidget2.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 53baa917c..8da3de72c 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1457,15 +1457,11 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
gasChange->addAction(action);
}
}
- QAction *setpointAction = m.addAction(tr("Add setpoint change"), this, &ProfileWidget2::addSetpointChange);
- setpointAction->setData(event->globalPos());
- QAction *action = m.addAction(tr("Add bookmark"), this, &ProfileWidget2::addBookmark);
- action->setData(event->globalPos());
- QAction *splitAction = m.addAction(tr("Split dive into two"), this, &ProfileWidget2::splitDive);
- splitAction->setData(event->globalPos());
+ m.addAction(tr("Add setpoint change"), [this, seconds]() { ProfileWidget2::addSetpointChange(seconds); });
+ m.addAction(tr("Add bookmark"), [this, seconds]() { addBookmark(seconds); });
+ m.addAction(tr("Split dive into two"), [this, seconds]() { splitDive(seconds); });
const struct event *ev = NULL;
enum divemode_t divemode = UNDEF_COMP_TYPE;
- QString gas = action->text();
get_current_divemode(current_dc, seconds, &ev, &divemode);
QMenu *changeMode = m.addMenu(tr("Change divemode"));
@@ -1492,7 +1488,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
m.addAction(tr("Edit the profile"), this, SIGNAL(editCurrentDive()));
if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) {
- action = new QAction(&m);
+ QAction *action = new QAction(&m);
action->setText(tr("Remove event"));
action->setData(QVariant::fromValue<void *>(item)); // so we know what to remove.
connect(action, SIGNAL(triggered(bool)), this, SLOT(removeEvent()));
@@ -1631,11 +1627,9 @@ void ProfileWidget2::removeEvent()
}
}
-void ProfileWidget2::addBookmark()
+void ProfileWidget2::addBookmark(int seconds)
{
- QAction *action = qobject_cast<QAction *>(sender());
- QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
- add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), SAMPLE_EVENT_BOOKMARK, 0, 0, "bookmark");
+ add_event(current_dc, seconds, SAMPLE_EVENT_BOOKMARK, 0, 0, "bookmark");
invalidate_dive_cache(current_dive);
mark_divelist_changed(true);
replot();
@@ -1649,26 +1643,20 @@ void ProfileWidget2::addDivemodeSwitch(int seconds, int divemode)
replot();
}
-void ProfileWidget2::addSetpointChange()
+void ProfileWidget2::addSetpointChange(int seconds)
{
- QAction *action = qobject_cast<QAction *>(sender());
- QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
- SetpointDialog::instance()->setpointData(current_dc, lrint(timeAxis->valueAt(scenePos)));
+ SetpointDialog::instance()->setpointData(current_dc, seconds);
SetpointDialog::instance()->show();
}
-void ProfileWidget2::splitDive()
+void ProfileWidget2::splitDive(int seconds)
{
#ifndef SUBSURFACE_MOBILE
// Make sure that this is an actual dive and we're not in add mode
dive *d = get_dive_by_uniq_id(displayed_dive.id);
if (!d)
return;
- QAction *action = qobject_cast<QAction *>(sender());
- QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
- duration_t time;
- time.seconds = lrint(timeAxis->valueAt(scenePos));
- Command::splitDives(d, time);
+ Command::splitDives(d, duration_t{ seconds });
#endif
}