When we have no volume of has used, that doesn't actually mean you aren't breathing. It means that that cylinder doesn't have pressure information or perhaps wasn't used.
Showing it as "0.00cuft/min" (or liter/min) is just completely bogus, and actively visually misleading. Leave it empty. This showed up both in the divelist, and in the the dive statistics page. The dive statistics case had a special case for "unknown", but only for the first gas. I don't think that was actually all that sane, and the logic was really odd - if you had gases that weren't used (or pressures not known) intermixed with gases you *did* have pressure for, the statistics thing did odd/wrong things. This makes all the cylinders act the same way, leaving unknown gas use (and thus SAC) just empty for that gas. There are bound to be odd combinations I didn't test, but this looks *much* better for the cases I did test (complete missing gas information, one tank with gas info, and a couple of gases with known pressures). Signed-off-by: Linus Torvalds <[email protected]> --- qt-ui/maintab.cpp | 23 +++++++++++------------ qt-ui/models.cpp | 2 ++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index bf108a9c170d..d7caab4391de 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -462,25 +462,24 @@ void MainTab::updateDiveInfo(bool clear) ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true)); volume_t gases[MAX_CYLINDERS] = {}; get_gas_used(&displayed_dive, gases); - QString volumes = get_volume_string(gases[0], true); + QString volumes; int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS]; per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration); volume_t sac; - QString SACs; - if (mean[0] && duration[0]) { - sac.mliter = gases[0].mliter / (depth_to_atm(mean[0], &displayed_dive) * duration[0] / 60.0); - SACs = get_volume_string(sac, true).append(tr("/min")); - } else { - SACs = QString(tr("unknown")); - } - for (int i = 1; i < MAX_CYLINDERS && gases[i].mliter != 0; i++) { - volumes.append("\n" + get_volume_string(gases[i], true)); + QString SACs, separator; + + SACs = ""; volumes = ""; separator = ""; + for (int i = 0; i < MAX_CYLINDERS; i++) { + if (!gases[i].mliter) + continue; + volumes.append(separator + get_volume_string(gases[i], true)); if (duration[i]) { sac.mliter = gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60); - SACs.append("\n" + get_volume_string(sac, true).append(tr("/min"))); + SACs.append(separator + get_volume_string(sac, true).append(tr("/min"))); } else { - SACs.append("\n"); + SACs.append(separator); } + separator = "\n"; } ui.gasUsedText->setText(volumes); ui.oxygenHeliumText->setText(get_gaslist(&displayed_dive)); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 9d43da624f13..6cf5c2bd24b3 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1250,6 +1250,8 @@ QString DiveItem::displaySac() const const char *unit; int decimal; double value = get_volume_units(dive->sac, &decimal, &unit); + if (!value) + return ""; return QString::number(value, 'f', decimal).append(unit).append(tr("/min")); } _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
