summaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 20:31:11 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 20:39:46 -0700
commit11380a5deb071b647e10dbd51e64340e50da801d (patch)
treed962394fd592d80bb7b039c8d33e9ebc0d064c9c /qt-gui.cpp
parente6fc5d2370db30092fec9f316a1d8edb4cb88d0b (diff)
downloadsubsurface-11380a5deb071b647e10dbd51e64340e50da801d.tar.gz
Really display liters with script el
In commit 125ddd955c04 ("Display liters with script el") Robert only fixed the C routine we use to show units. Strangely, we had a separately implemented C++ function as well. Instead of implementing this in two spots I now simply have the C++ function use the C function to do the actual work and then wrap this into an easier to use (from UI code) QString output. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r--qt-gui.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp
index 224fdd597..41b2e5f12 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -299,15 +299,10 @@ QString get_temp_unit()
QString get_volume_string(volume_t volume, bool showunit, int mbar)
{
- if (prefs.units.volume == units::LITER) {
- double liter = volume.mliter / 1000.0;
- return QString("%1%2").arg(liter, 0, 'f', liter >= 40.0 ? 0 : 1).arg(showunit ? translate("gettextFromC", "l") : "");
- } else {
- double cuft = ml_to_cuft(volume.mliter);
- if (mbar)
- cuft *= bar_to_atm(mbar / 1000.0);
- return QString("%1%2").arg(cuft, 0, 'f', cuft >= 20.0 ? 0 : (cuft >= 2.0 ? 1 : 2)).arg(showunit ? translate("gettextFromC", "cuft") : "");
- }
+ const char *unit;
+ int decimals;
+ double value = get_volume_units(volume.mliter, &decimals, &unit);
+ return QString("%1%2").arg(value, 0, 'f', decimals).arg(showunit ? unit : "");
}
QString get_volume_unit()