mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
[PQ] Allow to provide a default unit for parsing, e.g. "0" -> "0ft"
This commit is contained in:
committed by
Mat Sutcliffe
parent
92fdbd3117
commit
9b031bb582
@@ -21,6 +21,7 @@
|
||||
#include "blackmisc/pq/acceleration.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/verify.h"
|
||||
@@ -419,7 +420,7 @@ namespace BlackMisc
|
||||
// there is no double qHash
|
||||
// also unit and rounding has to be considered
|
||||
hashs << qHash(this->valueRoundedWithUnit(MU::defaultUnit()));
|
||||
return BlackMisc::calculateHash(hashs, "PQ");
|
||||
return calculateHash(hashs, "PQ");
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -449,6 +450,20 @@ namespace BlackMisc
|
||||
*this = CPqString::parse<PQ>(value, mode);
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing)
|
||||
{
|
||||
if (is09OnlyString(value))
|
||||
{
|
||||
const QString v = value + defaultUnitIfMissing.getName();
|
||||
this->parseFromString(v, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->parseFromString(value, mode);
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user