mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Really display liters with script el
In commit 125ddd955c
("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>
This commit is contained in:
parent
e6fc5d2370
commit
11380a5deb
2 changed files with 5 additions and 10 deletions
13
qt-gui.cpp
13
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()
|
||||
|
|
|
@ -538,7 +538,7 @@ volume_t string_to_volume(const char *str, pressure_t workp)
|
|||
QString local_cuft = CylindersModel::tr("cuft");
|
||||
volume_t volume;
|
||||
|
||||
if (rest.startsWith("l") || rest.startsWith(local_l))
|
||||
if (rest.startsWith("l") || rest.startsWith("ℓ") || rest.startsWith(local_l))
|
||||
goto l;
|
||||
if (rest.startsWith("cuft") || rest.startsWith(local_cuft))
|
||||
goto cuft;
|
||||
|
|
Loading…
Reference in a new issue