mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
Ref T338, style
This commit is contained in:
@@ -19,7 +19,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
|
||||
/*!
|
||||
* Physical unit frequency
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackMisc
|
||||
bool CMeasurementUnit::operator ==(const CMeasurementUnit &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
return this->m_data->m_name == other.m_data->m_name;
|
||||
return m_data->m_name == other.m_data->m_name;
|
||||
}
|
||||
|
||||
bool CMeasurementUnit::operator !=(const CMeasurementUnit &other) const
|
||||
@@ -31,8 +31,8 @@ namespace BlackMisc
|
||||
double CMeasurementUnit::convertFrom(double value, const CMeasurementUnit &unit) const
|
||||
{
|
||||
if (this->isNull() || unit.isNull()) return 0;
|
||||
if (this->m_data->m_toDefault == unit.m_data->m_toDefault && this->m_data->m_fromDefault == unit.m_data->m_fromDefault) return value;
|
||||
return this->m_data->m_fromDefault(unit.m_data->m_toDefault(value));
|
||||
if (m_data->m_toDefault == unit.m_data->m_toDefault && m_data->m_fromDefault == unit.m_data->m_fromDefault) return value;
|
||||
return m_data->m_fromDefault(unit.m_data->m_toDefault(value));
|
||||
}
|
||||
|
||||
QString CMeasurementUnit::makeRoundedQStringWithUnit(double value, int digits, bool i18n) const
|
||||
@@ -42,7 +42,7 @@ namespace BlackMisc
|
||||
|
||||
double CMeasurementUnit::roundValue(double value, int digits) const
|
||||
{
|
||||
if (digits < 0) { digits = this->m_data->m_displayDigits; }
|
||||
if (digits < 0) { digits = m_data->m_displayDigits; }
|
||||
return CMathUtils::round(value, digits);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace BlackMisc
|
||||
QString CMeasurementUnit::makeRoundedQString(double value, int digits, bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (digits < 0) digits = this->m_data->m_displayDigits;
|
||||
if (digits < 0) digits = m_data->m_displayDigits;
|
||||
const double v = CMathUtils::round(value, digits);
|
||||
const QString s = QLocale::system().toString(v, 'f', digits);
|
||||
return s;
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::DBusByMetaClass::marshallToDbus
|
||||
void marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << this->m_data->m_symbol;
|
||||
argument << m_data->m_symbol;
|
||||
}
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::DBusByMetaClass::unmarshallFromDbus
|
||||
@@ -281,13 +281,13 @@ namespace BlackMisc
|
||||
//! Name such as "meter"
|
||||
QString getName(bool i18n = false) const
|
||||
{
|
||||
return i18n ? QCoreApplication::translate("CMeasurementUnit", this->m_data->m_name.latin1()) : this->m_data->m_name;
|
||||
return i18n ? QCoreApplication::translate("CMeasurementUnit", m_data->m_name.latin1()) : m_data->m_name;
|
||||
}
|
||||
|
||||
//! Unit name such as "m"
|
||||
QString getSymbol(bool i18n = false) const
|
||||
{
|
||||
return i18n ? QCoreApplication::translate("CMeasurementUnit", this->m_data->m_symbol.latin1()) : this->m_data->m_symbol;
|
||||
return i18n ? QCoreApplication::translate("CMeasurementUnit", m_data->m_symbol.latin1()) : m_data->m_symbol;
|
||||
}
|
||||
|
||||
//! Does a string end with name or symbol? E.g. 3meter, 3m, 3deg
|
||||
@@ -317,13 +317,13 @@ namespace BlackMisc
|
||||
//! Threshold for comparions
|
||||
double getEpsilon() const
|
||||
{
|
||||
return this->m_data->m_epsilon;
|
||||
return m_data->m_epsilon;
|
||||
}
|
||||
|
||||
//! Display digits
|
||||
int getDisplayDigits() const
|
||||
{
|
||||
return this->m_data->m_displayDigits;
|
||||
return m_data->m_displayDigits;
|
||||
}
|
||||
|
||||
//! Convert from other unit to this unit.
|
||||
@@ -334,13 +334,13 @@ namespace BlackMisc
|
||||
{
|
||||
if (this->isNull()) return false;
|
||||
if (qFuzzyIsNull(value)) return true;
|
||||
return std::abs(value) <= this->m_data->m_epsilon;
|
||||
return std::abs(value) <= m_data->m_epsilon;
|
||||
}
|
||||
|
||||
//! Is unit null?
|
||||
bool isNull() const
|
||||
{
|
||||
return this->m_data->m_toDefault == nullptr;
|
||||
return m_data->m_toDefault == nullptr;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -7,15 +7,10 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/pq/measurementunit.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/pqstring.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/pressure.h"
|
||||
#include "blackmisc/pq/frequency.h"
|
||||
@@ -25,6 +20,11 @@
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/pq/acceleration.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusArgument>
|
||||
@@ -432,7 +432,7 @@ namespace BlackMisc
|
||||
{
|
||||
const QJsonValue unit = json.value("unit");
|
||||
const QJsonValue value = json.value("value");
|
||||
if (unit.isUndefined()) { throw CJsonException("Missing 'unit'"); }
|
||||
if (unit.isUndefined()) { throw CJsonException("Missing 'unit'"); }
|
||||
if (value.isUndefined()) { throw CJsonException("Missing 'value'"); }
|
||||
|
||||
this->setUnitBySymbol(unit.toString());
|
||||
|
||||
@@ -38,8 +38,8 @@ namespace BlackMisc
|
||||
//! Number separators / group separators
|
||||
enum SeparatorMode
|
||||
{
|
||||
SeparatorsCLocale, //!< 100,000.00
|
||||
SeparatorsLocale, //!< depending on QLocale, e.g. 100.000,00 in Germany
|
||||
SeparatorsCLocale, //!< 100,000.00
|
||||
SeparatorsLocale, //!< depending on QLocale, e.g. 100.000,00 in Germany
|
||||
SeparatorsBestGuess //!< try to figure out
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user