summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profile-widget/profilewidget2.cpp21
-rw-r--r--profile-widget/profilewidget2.h6
2 files changed, 9 insertions, 18 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 8da3de72c..53a9e3e1f 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1490,20 +1490,17 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) {
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()));
+ connect(action, &QAction::triggered, [this,item] { removeEvent(item); });
m.addAction(action);
action = new QAction(&m);
action->setText(tr("Hide similar events"));
- action->setData(QVariant::fromValue<void *>(item));
- connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents()));
+ connect(action, &QAction::triggered, [this, item] { hideEvents(item); });
m.addAction(action);
struct event *dcEvent = item->getEvent();
if (dcEvent->type == SAMPLE_EVENT_BOOKMARK) {
action = new QAction(&m);
action->setText(tr("Edit name"));
- action->setData(QVariant::fromValue<void *>(item));
- connect(action, SIGNAL(triggered(bool)), this, SLOT(editName()));
+ connect(action, &QAction::triggered, [this, item] { editName(item); });
m.addAction(action);
}
#if 0 // TODO::: FINISH OR DISABLE
@@ -1575,10 +1572,8 @@ void ProfileWidget2::makeFirstDC()
Command::moveDiveComputerToFront(current_dive, dc_number);
}
-void ProfileWidget2::hideEvents()
+void ProfileWidget2::hideEvents(DiveEventItem *item)
{
- QAction *action = qobject_cast<QAction *>(sender());
- DiveEventItem *item = static_cast<DiveEventItem *>(action->data().value<void *>());
struct event *event = item->getEvent();
if (QMessageBox::question(this,
@@ -1610,10 +1605,8 @@ void ProfileWidget2::unhideEvents()
item->show();
}
-void ProfileWidget2::removeEvent()
+void ProfileWidget2::removeEvent(DiveEventItem *item)
{
- QAction *action = qobject_cast<QAction *>(sender());
- DiveEventItem *item = static_cast<DiveEventItem *>(action->data().value<void *>());
struct event *event = item->getEvent();
if (QMessageBox::question(this, TITLE_OR_TEXT(
@@ -1730,10 +1723,8 @@ double ProfileWidget2::getFontPrintScale()
}
#ifndef SUBSURFACE_MOBILE
-void ProfileWidget2::editName()
+void ProfileWidget2::editName(DiveEventItem *item)
{
- QAction *action = qobject_cast<QAction *>(sender());
- DiveEventItem *item = static_cast<DiveEventItem *>(action->data().value<void *>());
struct event *event = item->getEvent();
bool ok;
QString newName = QInputDialog::getText(this, tr("Edit name of bookmark"),
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 342032567..bc049781d 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -115,10 +115,7 @@ slots: // Necessary to call from QAction's signals.
void removePictures(const QVector<QString> &fileUrls);
void setPlanState();
void setAddState();
- void hideEvents();
void unhideEvents();
- void removeEvent();
- void editName();
void makeFirstDC();
void deleteCurrentDC();
void splitCurrentDC();
@@ -175,6 +172,9 @@ private:
void addBookmark(int seconds);
void splitDive(int seconds);
void addSetpointChange(int seconds);
+ void removeEvent(DiveEventItem *item);
+ void hideEvents(DiveEventItem *item);
+ void editName(DiveEventItem *item);
private:
DivePlotDataModel *dataModel;
int zoomLevel;