mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
events: make event severity explicit
Currently the event type code uses libdivecomputer's flags to differentiate between events. Make this explicit and extract the event severity. The reason is that later we want to be more explicit about showing/ hiding events and thereto we must format the name of events. Moreover, this encapsulates the complexities of extracting the severity in the event code (that used to be in the profile code). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6ad7e577f1
commit
4422dbb52b
4 changed files with 32 additions and 14 deletions
|
@ -47,6 +47,7 @@ struct event *DiveEventItem::getEventMutable()
|
|||
|
||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix, const DivePixmaps &pixmaps)
|
||||
{
|
||||
event_severity severity = get_event_severity(ev);
|
||||
if (empty_string(ev->name)) {
|
||||
setPixmap(pixmaps.warning);
|
||||
} else if (same_string_caseinsensitive(ev->name, "modechange")) {
|
||||
|
@ -82,12 +83,8 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix, const DivePixmaps &pix
|
|||
else
|
||||
setPixmap(pixmaps.gaschangeEAN);
|
||||
}
|
||||
#ifdef SAMPLE_FLAGS_SEVERITY_SHIFT
|
||||
} else if ((((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 1) ||
|
||||
// those are useless internals of the dive computer
|
||||
#else
|
||||
} else if (
|
||||
#endif
|
||||
same_string_caseinsensitive(ev->name, "heading") ||
|
||||
(same_string_caseinsensitive(ev->name, "SP change") && ev->time.seconds == 0)) {
|
||||
// 2 cases:
|
||||
|
@ -98,14 +95,12 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix, const DivePixmaps &pix
|
|||
// that allows tooltips to work when we don't want to show a specific
|
||||
// pixmap for an event, but want to show the event value in the tooltip
|
||||
setPixmap(pixmaps.transparent);
|
||||
#ifdef SAMPLE_FLAGS_SEVERITY_SHIFT
|
||||
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 2) {
|
||||
} else if (severity == EVENT_SEVERITY_INFO) {
|
||||
setPixmap(pixmaps.info);
|
||||
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 3) {
|
||||
} else if (severity == EVENT_SEVERITY_WARN) {
|
||||
setPixmap(pixmaps.warning);
|
||||
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 4) {
|
||||
} else if (severity == EVENT_SEVERITY_ALARM) {
|
||||
setPixmap(pixmaps.violation);
|
||||
#endif
|
||||
} else if (same_string_caseinsensitive(ev->name, "violation") || // generic libdivecomputer
|
||||
same_string_caseinsensitive(ev->name, "Safety stop violation") || // the rest are from the Uemis downloader
|
||||
same_string_caseinsensitive(ev->name, "pO₂ ascend alarm") ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue