diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-12 15:39:42 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-12 15:39:42 -0700 |
commit | ed5a8059292c7743120fa4a089f92f4e84ee14b6 (patch) | |
tree | ed38828b0d34e86bd44a0074a55898fbae803b63 | |
parent | 1b2d3c29d3cfe36f2109ab306858004e20e82b3e (diff) | |
download | subsurface-ed5a8059292c7743120fa4a089f92f4e84ee14b6.tar.gz |
Fix tank size display
In commit 11380a5deb07 ("Really display liters with script el")
I inadvertantly broke the display of cylinder sizes in the imperial case.
This patch restores that and also tries to give slightly more useful
guidance on the number of decimals to display.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-gui.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index f8b6b8637..52b26febd 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -281,6 +281,14 @@ QString get_volume_string(volume_t volume, bool showunit, int mbar) const char *unit; int decimals; double value = get_volume_units(volume.mliter, &decimals, &unit); + if (mbar) { + // we are showing a tank size + // fix the weird imperial way of denominating size and provide + // reasonable number of decimals + if (prefs.units.volume == units::CUFT) + value *= bar_to_atm(mbar / 1000.0); + decimals = (value > 20.0) ? 0 : (value > 2.0) ? 1 : 2; + } return QString("%1%2").arg(value, 0, 'f', decimals).arg(showunit ? unit : ""); } |