mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
[PQ] Parsing with default unit, bug fixed
This commit is contained in:
committed by
Mat Sutcliffe
parent
170da452ee
commit
0a2b25e409
@@ -453,9 +453,9 @@ namespace BlackMisc
|
||||
template<class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing)
|
||||
{
|
||||
if (is09OnlyString(value))
|
||||
if (is09OrSeparatorOnlyString(value))
|
||||
{
|
||||
const QString v = value + defaultUnitIfMissing.getName();
|
||||
const QString v = value + defaultUnitIfMissing.getSymbol();
|
||||
this->parseFromString(v, mode);
|
||||
}
|
||||
else
|
||||
@@ -470,6 +470,21 @@ namespace BlackMisc
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorQtDefault);
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::parsedFromString(const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing)
|
||||
{
|
||||
QString v = value;
|
||||
if (is09OrSeparatorOnlyString(value))
|
||||
{
|
||||
v = value + defaultUnitIfMissing.getSymbol();
|
||||
}
|
||||
|
||||
// no idea why I cannot call pq.parseFromString(v, mode, defaultUnitIfMissing);
|
||||
PQ pq;
|
||||
pq.parseFromString(v, mode);
|
||||
return pq;
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::parsedFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
{
|
||||
|
||||
@@ -282,6 +282,9 @@ namespace BlackMisc
|
||||
//! Parsed from given string
|
||||
static PQ parsedFromString(const QString &value, CPqString::SeparatorMode mode = CPqString::SeparatorBestGuess);
|
||||
|
||||
//! Parsed from given string
|
||||
static PQ parsedFromString(const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing);
|
||||
|
||||
protected:
|
||||
//! Constructor with double
|
||||
CPhysicalQuantity(double value, MU unit);
|
||||
|
||||
Reference in New Issue
Block a user