From b4615e8b753f3c5563901c68cd6c689088578d98 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 30 Apr 2014 00:56:57 +0200 Subject: [PATCH] refs #212, removed set method as of MS review https://dev.vatsim-germany.org/issues/212#note-6 --- src/blackmisc/pqphysicalquantity.cpp | 10 ---------- src/blackmisc/pqphysicalquantity.h | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/blackmisc/pqphysicalquantity.cpp b/src/blackmisc/pqphysicalquantity.cpp index 25d4b03ce..cdef08c85 100644 --- a/src/blackmisc/pqphysicalquantity.cpp +++ b/src/blackmisc/pqphysicalquantity.cpp @@ -306,16 +306,6 @@ namespace BlackMisc this->m_value = json.value("value").toDouble(); } - /* - * Parse from string - */ - template void CPhysicalQuantity::parseFromString(const QString &value) - { - PQ parsed = CPqString::parse(value); - this->m_value = parsed.m_value; - this->m_unit = parsed.m_unit; - } - /* * metaTypeId */ diff --git a/src/blackmisc/pqphysicalquantity.h b/src/blackmisc/pqphysicalquantity.h index 138268c1d..4de445395 100644 --- a/src/blackmisc/pqphysicalquantity.h +++ b/src/blackmisc/pqphysicalquantity.h @@ -9,6 +9,7 @@ #include "blackmisc/pqbase.h" #include "blackmisc/pqunits.h" #include "blackmisc/mathematics.h" +#include "blackmisc/pqstring.h" #include #include #include @@ -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(value); + } //! Register metadata of unit and quantity static void registerMetadata();