diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-06 07:38:18 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-06 07:39:19 -0700 |
commit | 74e7b8e87971cdc1675a4c98a1c293b36b8cc66d (patch) | |
tree | fed7802184e8bd9929a0fe47930bee0741322324 | |
parent | eb63ccfed58d7a9f391bd5032e576707d4a58b58 (diff) | |
download | subsurface-74e7b8e87971cdc1675a4c98a1c293b36b8cc66d.tar.gz |
Don't show a SAC of 0.0l/min (or cuft/min)
When we have no data about the gas consumption it makes no sense to show a
SAC of 0. Instead we should show either "unknown" or nothing.
Fixes #693
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/maintab.cpp | 19 | ||||
-rw-r--r-- | qt-ui/models.cpp | 11 |
2 files changed, 21 insertions, 9 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 5a37c168b..075bfb734 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -477,7 +477,7 @@ void MainTab::updateDiveInfo(bool clear) per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration); volume_t sac; QString SACs; - if (mean[0] && duration[0]) { + if (mean[0] && duration[0] && gases[0].mliter) { 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 { @@ -485,7 +485,7 @@ void MainTab::updateDiveInfo(bool clear) } for (int i = 1; i < MAX_CYLINDERS && gases[i].mliter != 0; i++) { volumes.append("\n" + get_volume_string(gases[i], true)); - if (duration[i]) { + if (duration[i] && gases[i].mliter) { 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"))); } else { @@ -520,9 +520,18 @@ void MainTab::updateDiveInfo(bool clear) // ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true)); ui.depthLimits->overrideMaxToolTipText(tr("Deepest dive")); ui.depthLimits->overrideMinToolTipText(tr("Shallowest dive")); - ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min"))); - ui.sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min"))); - ui.sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min"))); + if (stats_selection.max_sac.mliter) + ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min"))); + else + ui.sacLimits->setMaximum(""); + if (stats_selection.min_sac.mliter) + ui.sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min"))); + else + ui.sacLimits->setMinimum(""); + if (stats_selection.avg_sac.mliter) + ui.sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min"))); + else + ui.sacLimits->setAverage(""); ui.divesAllText->setText(QString::number(stats_selection.selection_size)); temp.mkelvin = stats_selection.max_temp; ui.tempLimits->setMaximum(get_temperature_string(temp, true)); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 213a13d5f..11e84c9c2 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1263,10 +1263,13 @@ QString DiveItem::displaySac() const { QString str; struct dive *dive = get_dive_by_uniq_id(diveId); - const char *unit; - int decimal; - double value = get_volume_units(dive->sac, &decimal, &unit); - return QString::number(value, 'f', decimal).append(unit).append(tr("/min")); + if (dive->sac) { + const char *unit; + int decimal; + double value = get_volume_units(dive->sac, &decimal, &unit); + return QString::number(value, 'f', decimal).append(unit).append(tr("/min")); + } + return QString(""); } QString DiveItem::displayWeight() const |