diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-02 16:07:06 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-04 22:37:18 -0700 |
commit | eff405980214d8324d5448b5ed9e80a96addde9c (patch) | |
tree | 715d7d0f6e731361d69441724fe12fd6aa7f02ab /profile-widget | |
parent | e0824ef9f3e2a0cc0fae435b8e3560b309d9708e (diff) | |
download | subsurface-eff405980214d8324d5448b5ed9e80a96addde9c.tar.gz |
Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself. In other words, the cylinder index is
now the primary data for gas switch events.
This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.
Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event. The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.
In that case, we will do:
- if there is no index, but there is explicit gas mix information, we
will look up the index based on that gas mix, picking the cylinder
that has the closest mix.
- if there isn't even explicit gas mix data, so we only have the event
value from libdivecomputer, we will turn that value into a gasmix,
and use that to look up the cylinder index as above.
- if no valid cylinder information is available at all, gas switch
events will just be dropped.
When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).
It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveeventitem.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index daef227d8..876c56e16 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -94,9 +94,10 @@ void DiveEventItem::setupPixmap() transparentPixmap.fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.01)); setPixmap(transparentPixmap); } else if (event_is_gaschange(internalEvent)) { - if (internalEvent->gas.mix.he.permille) + struct gasmix *mix = get_gasmix_from_event(&displayed_dive, internalEvent); + if (mix->he.permille) setPixmap(EVENT_PIXMAP_BIGGER(":gaschangeTrimix")); - else if (gasmix_is_air(&internalEvent->gas.mix)) + else if (gasmix_is_air(mix)) setPixmap(EVENT_PIXMAP_BIGGER(":gaschangeAir")); else setPixmap(EVENT_PIXMAP_BIGGER(":gaschangeNitrox")); @@ -112,15 +113,17 @@ void DiveEventItem::setupToolTipString() QString name = gettextFromC::instance()->tr(internalEvent->name); int value = internalEvent->value; int type = internalEvent->type; - if (value) { - if (event_is_gaschange(internalEvent)) { - name += ": "; - name += gasname(&internalEvent->gas.mix); - - /* Do we have an explicit cylinder index? Show it. */ - if (internalEvent->gas.index >= 0) - name += QString(" (cyl %1)").arg(internalEvent->gas.index+1); - } else if (type == SAMPLE_EVENT_PO2 && name == "SP change") { + + if (event_is_gaschange(internalEvent)) { + struct gasmix *mix = get_gasmix_from_event(&displayed_dive, internalEvent); + name += ": "; + name += gasname(mix); + + /* Do we have an explicit cylinder index? Show it. */ + if (internalEvent->gas.index >= 0) + name += QString(" (cyl %1)").arg(internalEvent->gas.index+1); + } else if (value) { + if (type == SAMPLE_EVENT_PO2 && name == "SP change") { name += QString(":%1").arg((double)value / 1000); } else { name += QString(":%1").arg(value); |