refs #212, removed set method as of MS review

https://dev.vatsim-germany.org/issues/212#note-6
This commit is contained in:
Klaus Basan
2014-04-30 00:56:57 +02:00
parent c1acc1fa69
commit b4615e8b75
2 changed files with 11 additions and 18 deletions

View File

@@ -306,16 +306,6 @@ namespace BlackMisc
this->m_value = json.value("value").toDouble();
}
/*
* Parse from string
*/
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
{
PQ parsed = CPqString::parse<PQ>(value);
this->m_value = parsed.m_value;
this->m_unit = parsed.m_unit;
}
/*
* metaTypeId
*/

View File

@@ -9,6 +9,7 @@
#include "blackmisc/pqbase.h"
#include "blackmisc/pqunits.h"
#include "blackmisc/mathematics.h"
#include "blackmisc/pqstring.h"
#include <QtDBus/QDBusMetaType>
#include <QtGlobal>
#include <QString>
@@ -51,6 +52,12 @@ namespace BlackMisc
//! Copy constructor
CPhysicalQuantity(const CPhysicalQuantity &other);
//! Constructor by parsed string, e.g. 10m
CPhysicalQuantity(const QString &unitString) : m_value(0.0), m_unit(MU::nullUnit())
{
this->parseFromString(unitString);
}
//! \copydoc CValueObject::convertToQString
virtual QString convertToQString(bool i18n = false) const override;
@@ -119,13 +126,6 @@ namespace BlackMisc
}
}
//! Set by other PQ
void set(const PQ &pq)
{
this->m_value = pq.m_value;
this->m_unit = pq.m_unit;
}
//! Rounded value in given unit
double valueRounded(const MU &unit, int digits = -1) const;
@@ -235,7 +235,10 @@ namespace BlackMisc
virtual void fromJson(const QJsonObject &json) override;
//! \copydoc CValueObject::parseFromString
virtual void parseFromString(const QString &value) override;
virtual void parseFromString(const QString &value) override
{
*this = CPqString::parse<PQ>(value);
}
//! Register metadata of unit and quantity
static void registerMetadata();