mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
e8d1f14c90
commit
df6a80fb37
1 changed files with 21 additions and 7 deletions
|
@ -142,8 +142,8 @@ void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(removeEvent()));
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(removeEvent()));
|
||||||
m.addAction(action);
|
m.addAction(action);
|
||||||
action = new QAction(&m);
|
action = new QAction(&m);
|
||||||
action->setText("Hide events of that type");
|
action->setText("Hide similar events");
|
||||||
action->setData(event->globalPos());
|
action->setData(QVariant::fromValue<void*>(item));
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents()));
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents()));
|
||||||
m.addAction(action);
|
m.addAction(action);
|
||||||
break;
|
break;
|
||||||
|
@ -173,10 +173,24 @@ void ProfileGraphicsView::changeGas()
|
||||||
void ProfileGraphicsView::hideEvents()
|
void ProfileGraphicsView::hideEvents()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction*>(sender());
|
QAction *action = qobject_cast<QAction*>(sender());
|
||||||
QPoint globalPos = action->data().toPoint();
|
EventItem *item = static_cast<EventItem*>(action->data().value<void*>());
|
||||||
QPoint viewPos = mapFromGlobal(globalPos);
|
struct event *event = item->ev;
|
||||||
QPointF scenePos = mapToScene(viewPos);
|
|
||||||
qDebug() << "Hide Event";
|
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()
|
void ProfileGraphicsView::removeEvent()
|
||||||
|
@ -199,8 +213,8 @@ void ProfileGraphicsView::removeEvent()
|
||||||
free(event);
|
free(event);
|
||||||
}
|
}
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
|
plot(current_dive, TRUE);
|
||||||
}
|
}
|
||||||
plot(current_dive, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue