mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: port event unhiding to QtQuick
This has UI changes: - The unhiding options are accessed by a field that appears when there are hidden events. - Only event-types of this particular dive are unhidden. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7c7469b8ab
commit
b099e17042
14 changed files with 98 additions and 50 deletions
|
@ -509,6 +509,16 @@ static QString formatCylinderDescription(int i, const cylinder_t &cylinder)
|
|||
return label;
|
||||
}
|
||||
|
||||
void ProfileView::unhideEvents()
|
||||
{
|
||||
if (!d)
|
||||
return;
|
||||
struct divecomputer *currentdc = mutable_dive()->get_dc(dc);
|
||||
for (auto &ev: currentdc->events)
|
||||
ev.hidden = false;
|
||||
replot();
|
||||
}
|
||||
|
||||
void ProfileView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// Handle dragging of items
|
||||
|
@ -541,6 +551,34 @@ void ProfileView::mousePressEvent(QMouseEvent *event)
|
|||
return execMenu(m, event->globalPos());
|
||||
}
|
||||
|
||||
// Open context menu for event unhiding
|
||||
if (d && profileScene->pointOnEventsHiddenText(event->pos())) {
|
||||
std::vector<MenuEntry> m;
|
||||
const struct divecomputer *currentdc = d->get_dc(dc);
|
||||
if (currentdc->has_individually_hidden_events()) {
|
||||
m.emplace_back(tr("Unhide individually hidden events of this dive"), [this, ¤tdc] {
|
||||
unhideEvents();
|
||||
});
|
||||
}
|
||||
std::vector<int> types = hidden_event_types(*currentdc);
|
||||
if (!types.empty()) {
|
||||
std::vector<MenuEntry> m2;
|
||||
for (int i: types) {
|
||||
m2.emplace_back(event_type_name(i), [this, i]() {
|
||||
show_event_type(i);
|
||||
replot();
|
||||
});
|
||||
}
|
||||
if (types.size() > 1) {
|
||||
m2.emplace_back(tr("All types"), [this, currentdc]() {
|
||||
show_all_event_types(*currentdc);
|
||||
replot();
|
||||
});
|
||||
}
|
||||
m.emplace_back(tr("Unhide event type"), std::move(m2));
|
||||
}
|
||||
return execMenu(m, event->globalPos());
|
||||
}
|
||||
DiveEventItem *item = profileScene->eventAtPosition(event->pos());
|
||||
if (d && item) {
|
||||
std::vector<MenuEntry> m;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue