diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-11-19 23:59:56 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-19 18:17:41 -0800 |
commit | df6a80fb37505239680e7d59290bf4f4ba7a89ca (patch) | |
tree | 90ae58278e82af6db0bbbb54f76be0dbf50b2d43 /qt-ui/profilegraphics.cpp | |
parent | e8d1f14c90701077d6edc645ad575632fcf29a78 (diff) | |
download | subsurface-df6a80fb37505239680e7d59290bf4f4ba7a89ca.tar.gz |
Hooked up 'Hide Events'
With this commit one can hide all events of the selected type through a
context menu on the profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index a1852a6ab..a7b3d88af 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -142,8 +142,8 @@ void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event) connect(action, SIGNAL(triggered(bool)), this, SLOT(removeEvent())); m.addAction(action); action = new QAction(&m); - action->setText("Hide events of that type"); - action->setData(event->globalPos()); + action->setText("Hide similar events"); + action->setData(QVariant::fromValue<void*>(item)); connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents())); m.addAction(action); break; @@ -173,10 +173,24 @@ void ProfileGraphicsView::changeGas() void ProfileGraphicsView::hideEvents() { QAction *action = qobject_cast<QAction*>(sender()); - QPoint globalPos = action->data().toPoint(); - QPoint viewPos = mapFromGlobal(globalPos); - QPointF scenePos = mapToScene(viewPos); - qDebug() << "Hide Event"; + EventItem *item = static_cast<EventItem*>(action->data().value<void*>()); + struct event *event = item->ev; + + if (QMessageBox::question(mainWindow(), + tr("Hide events"), + tr("Hide all %1 events?").arg(event->name), + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok){ + if (event->name) { + for (int i = 0; i < evn_used; i++) { + if (! strcmp(event->name, ev_namelist[i].ev_name)) { + ev_namelist[i].plot_ev = false; + break; + } + } + } + mark_divelist_changed(TRUE); + plot(current_dive, TRUE); + } } void ProfileGraphicsView::removeEvent() @@ -199,8 +213,8 @@ void ProfileGraphicsView::removeEvent() free(event); } mark_divelist_changed(TRUE); + plot(current_dive, TRUE); } - plot(current_dive, TRUE); } |