diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-30 21:09:24 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-30 21:28:38 -0700 |
commit | 2fa66f7ab1fc53fc0d4482a53723f81fadd82809 (patch) | |
tree | 3298bceb75d8f997d9efa8bed1de650b611b812c /qt-models/cylindermodel.cpp | |
parent | 56c206d19fba315a633404e54c16891db49a97ac (diff) | |
download | subsurface-2fa66f7ab1fc53fc0d4482a53723f81fadd82809.tar.gz |
Tweak the "display_unused_tanks" preferences logic
This is really unrelated to my recent "multiple gas pressures" work, but
the test case from Gaetan Bisson showed that the logic for which
cylinders to show in the equipment tab was less than optimal.
We basically used to show only cylinders that were actively used, unless
you had the "display_unused_tanks" preference option set. That comes
from some dive computers reporting a *lot* of cylinders that the diver
really doesn't even have with him on the dive. And showing those extra
dummy cylinders gets pretty annoying after a time, which is why we
default to not showing unused tanks.
However, in Gaetan's case, he had a total of four cylinders on the dive:
the O2 and diluent bottle for the rebreather dive, and then bailout
bottles (both air and deco). And while the bailout bottles weren't
actually used, Gaetan had actually filled in all the pressure details
etc for them, and so you'd really expect them to show up. These were
*not* just some extraneous default cylinder filled in by an over-eager
dive computer.
But because the bailout wasn't used, the manual pressures at the end
were the same as at the beginning, and the "unused cylinder" logic
triggered anyway.
So tweak the logic a bit, and say that you show cylinder equipment not
only if it has been used on the dive, but also if it has any pressure
information for it.
So the o nly cylinders we don't show are the ones that really have no
interesting information at all, except for possibly the cylinder tank
type itself (which is exactly what the over-eager dive computer case
might fill in, usually in the form of a default cylinder type).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/cylindermodel.cpp')
-rw-r--r-- | qt-models/cylindermodel.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 5da0d42a9..594df658c 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -484,15 +484,33 @@ void CylindersModel::clear() } } +static bool show_cylinder(struct dive *dive, int i) +{ + cylinder_t *cyl = dive->cylinder + i; + + if (is_cylinder_used(dive, i)) + return true; + if (cylinder_none(cyl)) + return false; + if (cyl->start.mbar || cyl->sample_start.mbar || + cyl->end.mbar || cyl->sample_end.mbar) + return true; + if (cyl->manually_added) + return true; + + /* + * The cylinder has some data, but none of it is very interesting, + * it has no pressures and no gas switches. Do we want to show it? + */ + return prefs.display_unused_tanks; +} + void CylindersModel::updateDive() { clear(); rows = 0; for (int i = 0; i < MAX_CYLINDERS; i++) { - if (!cylinder_none(&displayed_dive.cylinder[i]) && - (prefs.display_unused_tanks || - is_cylinder_used(&displayed_dive, i) || - displayed_dive.cylinder[i].manually_added)) + if (show_cylinder(&displayed_dive, i)) rows = i + 1; } if (rows > 0) { @@ -507,10 +525,8 @@ void CylindersModel::copyFromDive(dive *d) return; rows = 0; for (int i = 0; i < MAX_CYLINDERS; i++) { - if (!cylinder_none(&d->cylinder[i]) && - (is_cylinder_used(d, i) || prefs.display_unused_tanks)) { + if (show_cylinder(d, i)) rows = i + 1; - } } if (rows > 0) { beginInsertRows(QModelIndex(), 0, rows - 1); |