summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-05 09:28:58 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-05 09:32:13 -0700
commit3063991e4ed22932c3c66d3970d22f4f9a513bbf (patch)
treed65608d0fd795f59db1f5f4504c9f4e6e27ba13a
parent8de1a736693e1fa4ff2cf79b284b44c3b2e1d639 (diff)
downloadsubsurface-3063991e4ed22932c3c66d3970d22f4f9a513bbf.tar.gz
Fix bug in handling of fake SAMPLE_EVENT_PO2 events
In commit bcdd6192fe45 ("Show translated event names in tooltip") I was too aggressive in replacing the checking for event names with checking for event types. It turns out that we are abusing an existing event type in the planner (and use a different event name to mark the difference). By just checking for the type this now caused incorrect information to be displayed in the info box (a simply "PO2 warning" on a Suunto D9 could turn into a "Bailing out to OC" notice). The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from libdivecomputer. Once we have those, we can do this the right way. For now we just fall back to also checking the event name (which is what I wanted to get away from so translated names don't trip us up). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--planner.c3
-rw-r--r--qt-ui/profile/diveeventitem.cpp6
2 files changed, 7 insertions, 2 deletions
diff --git a/planner.c b/planner.c
index c56f04639..5c0bbecbc 100644
--- a/planner.c
+++ b/planner.c
@@ -264,6 +264,9 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan)
/* Check for SetPoint change */
if (oldpo2 != po2) {
if (lasttime)
+ /* this is a bad idea - we should get a different SAMPLE_EVENT type
+ * reserved for this in libdivecomputer... overloading SMAPLE_EVENT_PO2
+ * with a different meaning will only cause confusion elsewhere in the code */
add_event(dc, lasttime, SAMPLE_EVENT_PO2, 0, po2, "SP change");
oldpo2 = po2;
}
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 2f2bec60e..873c6abbe 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -92,12 +92,14 @@ void DiveEventItem::setupToolTipString()
name += tr("air");
else
name += QString(tr("EAN%1")).arg(o2);
- } else if (type == SAMPLE_EVENT_PO2) {
+ } else if (type == SAMPLE_EVENT_PO2 && name == "SP change") {
name += QString(":%1").arg((double)value / 1000);
} else {
name += QString(":%1").arg(value);
}
- } else if (type == SAMPLE_EVENT_PO2) {
+ } else if (type == SAMPLE_EVENT_PO2 && name == "SP change") {
+ // this is a bad idea - we are abusing an existing event type that is supposed to
+ // warn of high or low PO2 and are turning it into a set point change event
name += "\n" + tr("Bailing out to OC");
} else {
name += internalEvent->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :