Browse Source

FactMetadata, QmlUnitsConversion: support for speed unit translation

QGC4.4
davidsastresas 2 years ago committed by Don Gagne
parent
commit
4c1f6c751a
  1. 20
      src/FactSystem/FactMetaData.cc
  2. 6
      src/FactSystem/FactMetaData.h
  3. 6
      src/QmlControls/QmlUnitsConversion.h

20
src/FactSystem/FactMetaData.cc

@ -1200,6 +1200,26 @@ QVariant FactMetaData::appSettingsWeightUnitsToGrams(const QVariant& weight) { @@ -1200,6 +1200,26 @@ QVariant FactMetaData::appSettingsWeightUnitsToGrams(const QVariant& weight) {
}
}
QVariant FactMetaData::metersSecondToAppSettingsSpeedUnits(const QVariant& metersSecond)
{
const AppSettingsTranslation_s* pAppSettingsTranslation = _findAppSettingsUnitsTranslation("m/s", UnitSpeed);
if (pAppSettingsTranslation) {
return pAppSettingsTranslation->rawTranslator(metersSecond);
} else {
return metersSecond;
}
}
QVariant FactMetaData::appSettingsSpeedUnitsToMetersSecond(const QVariant& speed)
{
const AppSettingsTranslation_s* pAppSettingsTranslation = _findAppSettingsUnitsTranslation("m/s", UnitSpeed);
if (pAppSettingsTranslation) {
return pAppSettingsTranslation->cookedTranslator(speed);
} else {
return speed;
}
}
QString FactMetaData::appSettingsSpeedUnitsString()
{
const AppSettingsTranslation_s* pAppSettingsTranslation = _findAppSettingsUnitsTranslation("m/s", UnitSpeed);

6
src/FactSystem/FactMetaData.h

@ -99,6 +99,12 @@ public: @@ -99,6 +99,12 @@ public:
/// Returns the string for distance units which has configued by user
static QString appSettingsAreaUnitsString(void);
/// Converts from meters/second to the user specified speed unit
static QVariant metersSecondToAppSettingsSpeedUnits(const QVariant& metersSecond);
/// Converts from user specified speed unit to meters/second
static QVariant appSettingsSpeedUnitsToMetersSecond(const QVariant& speed);
/// Returns the string for speed units which has configued by user
static QString appSettingsSpeedUnitsString();

6
src/QmlControls/QmlUnitsConversion.h

@ -59,6 +59,12 @@ public: @@ -59,6 +59,12 @@ public:
QString appSettingsAreaUnitsString(void) const { return FactMetaData::appSettingsAreaUnitsString(); }
/// Converts from meters/second to the user specified speed unit
Q_INVOKABLE QVariant metersSecondToAppSettingsSpeedUnits(const QVariant& metersSecond) const { return FactMetaData::metersSecondToAppSettingsSpeedUnits(metersSecond); }
/// Converts from user specified speed unit to meters/second
Q_INVOKABLE QVariant appSettingsSpeedUnitsToMetersSecond(const QVariant& speed) const { return FactMetaData::appSettingsSpeedUnitsToMetersSecond(speed); }
/// Returns the string for speed units which has configued by user
QString appSettingsSpeedUnitsString() { return FactMetaData::appSettingsSpeedUnitsString(); }

Loading…
Cancel
Save