Commit 8af9c882 authored by Lorenz Meier's avatar Lorenz Meier

Fact system: Translate between normalized units and percent

parent 04fb087b
......@@ -38,6 +38,7 @@
const FactMetaData::BuiltInTranslation_s FactMetaData::_rgBuiltInTranslations[] = {
{ "centi-degrees", "degrees", FactMetaData::_centiDegreesToDegrees, FactMetaData::_degreesToCentiDegrees },
{ "radians", "degrees", FactMetaData::_radiansToDegrees, FactMetaData::_degreesToRadians },
{ "norm", "%", FactMetaData::_normToPercent, FactMetaData::_percentToNorm },
};
// Translations driven by app settings
......@@ -449,6 +450,16 @@ QVariant FactMetaData::_knotsToMetersPerSecond(const QVariant& knots)
return QVariant(knots.toDouble() * 0.51444444444);
}
QVariant FactMetaData::_percentToNorm(const QVariant& percent)
{
return QVariant(percent.toDouble() / 100.0);
}
QVariant FactMetaData::_normToPercent(const QVariant& normalized)
{
return QVariant(normalized.toDouble() * 100.0);
}
void FactMetaData::setRawUnits(const QString& rawUnits)
{
_rawUnits = rawUnits;
......
......@@ -163,6 +163,8 @@ private:
static QVariant _kilometersPerHourToMetersPerSecond(const QVariant& kilometersPerHour);
static QVariant _metersPerSecondToKnots(const QVariant& metersPerSecond);
static QVariant _knotsToMetersPerSecond(const QVariant& knots);
static QVariant _percentToNorm(const QVariant& percent);
static QVariant _normToPercent(const QVariant& normalized);
struct AppSettingsTranslation_s {
const char* rawUnits;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment