From b9174332d562b8b9c436a94880c51acf2c5ab761 Mon Sep 17 00:00:00 2001 From: Willem Ferguson Date: Sat, 7 Apr 2018 14:56:37 +0200 Subject: Read and write divemode changes (xml and git) This provides for reading of divemode change events from dive logs and for writing them to dive logs. This applies to xml and git divelogs. Divemode change events have the following structure: event->name = "modechange" event->value = integer corresponding to enum dive_comp_type (dive.c), reflecting the type of divemode change (OC, CCR, PSCR, etc). In the dive log file, the event value is written as a string that corresponds to each of the enum values, e.g. This xml is also read from the dive log file and translated to an appropriate value of event->value. The file diveeventitem.cpp was udated to reflect this new way of dealing with divemode change events. Signed-off-by: Willem Ferguson --- profile-widget/diveeventitem.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 7e7c602a1..b734f5b5e 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -84,9 +84,10 @@ void DiveEventItem::setupPixmap(struct gasmix *lastgasmix) #define EVENT_PIXMAP_BIGGER(PIX) QPixmap(QString(PIX)).scaled(sz_bigger, sz_bigger, Qt::KeepAspectRatio, Qt::SmoothTransformation) if (empty_string(internalEvent->name)) { setPixmap(EVENT_PIXMAP(":status-warning-icon")); - } else if (same_string_caseinsensitive(internalEvent->name, "OC")) { - setPixmap(EVENT_PIXMAP(":bailout-icon")); - } else if (same_string_caseinsensitive(internalEvent->name, "CCR") || same_string_caseinsensitive(internalEvent->name, "PSCR")) { + } else if (same_string_caseinsensitive(internalEvent->name, "modechange")) { + if (internalEvent->value == 0) + setPixmap(EVENT_PIXMAP(":bailout-icon")); + else setPixmap(EVENT_PIXMAP(":onCCRLoop-icon")); } else if (internalEvent->type == SAMPLE_EVENT_BOOKMARK) { setPixmap(EVENT_PIXMAP(":dive-bookmark-icon")); @@ -192,6 +193,8 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix) free_buffer(&mb); } *lastgasmix = *mix; + } else if (same_string(internalEvent->name, "modechange")) { + name += tr(": %1").arg(divemode_text[internalEvent->value]); } else if (value) { if (type == SAMPLE_EVENT_PO2 && same_string(internalEvent->name, "SP change")) { name += QString(": %1bar").arg((double)value / 1000, 0, 'f', 1); -- cgit v1.2.3-70-g09d2