Desktop: Consider Severity when Hiding Events.

When events are hidden in the profile, only hide events with the same
name and the same severity (flags).
From discussion in https://github.com/subsurface/libdc/pull/54.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-07-28 01:21:25 +12:00
parent b324849d0c
commit 26f20b805d
5 changed files with 17 additions and 22 deletions

View file

@ -1,3 +1,4 @@
desktop: hide only events with the same severity when 'Hide similar events' is used
equipment: mark gas mixes reported by the dive computer as 'inactive' as 'not used'
equipment: include unused cylinders in merged dive if the preference is enabled
equipment: fix bug showing the first diluent in the gas list as 'used' for CCR dives

View file

@ -39,13 +39,6 @@ extern "C" bool is_event_hidden(const char *eventname)
return it != event_names.end() && !it->plot;
}
extern "C" void hide_event(const char *eventname)
{
auto it = std::find(event_names.begin(), event_names.end(), eventname);
if (it != event_names.end())
it->plot = false;
}
extern "C" void show_all_events()
{
for (event_name &en: event_names)

View file

@ -10,7 +10,6 @@ extern "C" {
extern void clear_event_names(void);
extern void remember_event_name(const char *eventname);
extern bool is_event_hidden(const char *eventname);
extern void hide_event(const char *eventname);
extern void show_all_events();
extern bool any_events_hidden();

View file

@ -600,7 +600,8 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) {
m.addAction(tr("Remove event"), [this,item] { removeEvent(item); });
m.addAction(tr("Hide similar events"), [this, item] { hideEvents(item); });
m.addAction(tr("Hide event"), [this, item] { hideEvent(item); });
m.addAction(tr("Hide similar events"), [this, item] { hideSimilarEvents(item); });
const struct event *dcEvent = item->getEvent();
if (dcEvent->type == SAMPLE_EVENT_BOOKMARK)
m.addAction(tr("Edit name"), [this, item] { editName(item); });
@ -682,22 +683,22 @@ void ProfileWidget2::renameCurrentDC()
Command::editDeviceNickname(currentdc, newName);
}
void ProfileWidget2::hideEvents(DiveEventItem *item)
void ProfileWidget2::hideEvent(DiveEventItem *item)
{
item->hide();
}
void ProfileWidget2::hideSimilarEvents(DiveEventItem *item)
{
const struct event *event = item->getEvent();
if (QMessageBox::question(this,
TITLE_OR_TEXT(tr("Hide events"), tr("Hide all %1 events?").arg(event->name)),
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
hideEvent(item);
if (!empty_string(event->name)) {
hide_event(event->name);
for (DiveEventItem *evItem: profileScene->eventItems) {
if (same_string(evItem->getEvent()->name, event->name))
if (same_string(evItem->getEvent()->name, event->name) && evItem->getEvent()->flags == event->flags)
evItem->hide();
}
} else {
item->hide();
}
}
}

View file

@ -125,7 +125,8 @@ private:
void splitDive(int seconds);
void addSetpointChange(int seconds);
void removeEvent(DiveEventItem *item);
void hideEvents(DiveEventItem *item);
void hideEvent(DiveEventItem *item);
void hideSimilarEvents(DiveEventItem *item);
void editName(DiveEventItem *item);
void unhideEvents();
void makeFirstDC();