mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: add get_*_unit functions with explicit unit system
The get_*_unit() functions return the unit-name as set in the preferences. Add versions with a "metric" parameter. This will be used by the statistics code, which may in the future allow for binning with alternative units. All the unit-formatting functions should probably be moved away from qthelper to their own source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e23d103c5d
commit
b02847de53
2 changed files with 40 additions and 16 deletions
|
@ -542,14 +542,19 @@ QString get_depth_string(depth_t depth, bool showunit, bool showdecimal)
|
|||
return get_depth_string(depth.mm, showunit, showdecimal);
|
||||
}
|
||||
|
||||
QString get_depth_unit()
|
||||
QString get_depth_unit(bool metric)
|
||||
{
|
||||
if (prefs.units.length == units::METERS)
|
||||
if (metric)
|
||||
return gettextFromC::tr("m");
|
||||
else
|
||||
return gettextFromC::tr("ft");
|
||||
}
|
||||
|
||||
QString get_depth_unit()
|
||||
{
|
||||
return get_depth_unit(prefs.units.length == units::METERS);
|
||||
}
|
||||
|
||||
QString get_weight_string(weight_t weight, bool showunit)
|
||||
{
|
||||
QString str = weight_string(weight.grams);
|
||||
|
@ -561,14 +566,19 @@ QString get_weight_string(weight_t weight, bool showunit)
|
|||
return str;
|
||||
}
|
||||
|
||||
QString get_weight_unit()
|
||||
QString get_weight_unit(bool metric)
|
||||
{
|
||||
if (prefs.units.weight == units::KG)
|
||||
if (metric)
|
||||
return gettextFromC::tr("kg");
|
||||
else
|
||||
return gettextFromC::tr("lbs");
|
||||
}
|
||||
|
||||
QString get_weight_unit()
|
||||
{
|
||||
return get_weight_unit(prefs.units.weight == units::KG);
|
||||
}
|
||||
|
||||
QString get_temperature_string(temperature_t temp, bool showunit)
|
||||
{
|
||||
if (temp.mkelvin == 0) {
|
||||
|
@ -582,12 +592,17 @@ QString get_temperature_string(temperature_t temp, bool showunit)
|
|||
}
|
||||
}
|
||||
|
||||
QString get_temp_unit(bool metric)
|
||||
{
|
||||
if (metric)
|
||||
return QStringLiteral("°C");
|
||||
else
|
||||
return QStringLiteral("°F");
|
||||
}
|
||||
|
||||
QString get_temp_unit()
|
||||
{
|
||||
if (prefs.units.temperature == units::CELSIUS)
|
||||
return QString("°C");
|
||||
else
|
||||
return QString("°F");
|
||||
return get_temp_unit(prefs.units.temperature == units::CELSIUS);
|
||||
}
|
||||
|
||||
QString get_volume_string(int mliter, bool showunit)
|
||||
|
@ -603,11 +618,17 @@ QString get_volume_string(volume_t volume, bool showunit)
|
|||
return get_volume_string(volume.mliter, showunit);
|
||||
}
|
||||
|
||||
QString get_volume_unit(bool metric)
|
||||
{
|
||||
if (metric)
|
||||
return gettextFromC::tr("ℓ");
|
||||
else
|
||||
return gettextFromC::tr("cuft");
|
||||
}
|
||||
|
||||
QString get_volume_unit()
|
||||
{
|
||||
const char *unit;
|
||||
(void) get_volume_units(0, NULL, &unit);
|
||||
return QString(unit);
|
||||
return get_volume_unit(prefs.units.volume == units::LITER);
|
||||
}
|
||||
|
||||
QString get_pressure_string(pressure_t pressure, bool showunit)
|
||||
|
|
|
@ -46,16 +46,19 @@ QStringList videoExtensionFilters();
|
|||
char *copy_qstring(const QString &);
|
||||
QString get_depth_string(depth_t depth, bool showunit = false, bool showdecimal = true);
|
||||
QString get_depth_string(int mm, bool showunit = false, bool showdecimal = true);
|
||||
QString get_depth_unit();
|
||||
QString get_depth_unit(bool metric);
|
||||
QString get_depth_unit(); // use preferences unit
|
||||
QString get_weight_string(weight_t weight, bool showunit = false);
|
||||
QString get_weight_unit();
|
||||
QString get_weight_unit(bool metric);
|
||||
QString get_weight_unit(); // use preferences unit
|
||||
QString get_temperature_string(temperature_t temp, bool showunit = false);
|
||||
QString get_temp_unit();
|
||||
QString get_temp_unit(bool metric);
|
||||
QString get_temp_unit(); // use preferences unit
|
||||
QString get_volume_string(volume_t volume, bool showunit = false);
|
||||
QString get_volume_string(int mliter, bool showunit = false);
|
||||
QString get_volume_unit();
|
||||
QString get_volume_unit(bool metric);
|
||||
QString get_volume_unit(); // use preferences unit
|
||||
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
||||
QString get_pressure_unit();
|
||||
QString get_salinity_string(int salinity);
|
||||
QString get_water_type_string(int salinity);
|
||||
QString getSubsurfaceDataPath(QString folderToFind);
|
||||
|
|
Loading…
Add table
Reference in a new issue