Fix tank size display

In commit 11380a5deb ("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>
This commit is contained in:
Dirk Hohndel 2014-06-12 15:39:42 -07:00
parent 1b2d3c29d3
commit ed5a805929

View file

@ -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 : "");
}