mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
PQ parsing using "best guess" strategy as default plus renamings
This commit is contained in:
committed by
Mat Sutcliffe
parent
4e1835b80d
commit
d89b217e9b
@@ -328,7 +328,7 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
const CFrequency radioFrequency = CComSystem::parseComFrequency(receiver, CPqString::SeparatorsBestGuess);
|
||||
const CFrequency radioFrequency = CComSystem::parseComFrequency(receiver, CPqString::SeparatorBestGuess);
|
||||
if (!radioFrequency.isNull())
|
||||
{
|
||||
if (CComSystem::isValidCivilAviationFrequency(radioFrequency))
|
||||
@@ -383,7 +383,7 @@ namespace BlackCore
|
||||
CLength os(CLength::null());
|
||||
if (parser.hasPart(2))
|
||||
{
|
||||
os.parseFromString(parser.part(2));
|
||||
os.parseFromString(parser.part(2), CPqString::SeparatorBestGuess);
|
||||
}
|
||||
|
||||
const bool added = this->testAddAltitudeOffset(cs, os);
|
||||
|
||||
@@ -1445,7 +1445,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
CAltitude cruiseAlt;
|
||||
cruiseAlt.parseFromString(cruiseAltString, CPqString::SeparatorsBestGuess);
|
||||
cruiseAlt.parseFromString(cruiseAltString, CPqString::SeparatorBestGuess);
|
||||
|
||||
const QString depTimePlanned = QString("0000").append(QString::number(fp->departTime)).right(4);
|
||||
const QString depTimeActual = QString("0000").append(QString::number(fp->departTimeActual)).right(4);
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace BlackGui
|
||||
// TAS
|
||||
v = ui->le_CruiseTrueAirspeed->text();
|
||||
CSpeed cruiseTAS;
|
||||
cruiseTAS.parseFromString(v, CPqString::SeparatorsLocale);
|
||||
cruiseTAS.parseFromString(v, CPqString::SeparatorBestGuess);
|
||||
if (cruiseTAS.isNull())
|
||||
{
|
||||
messages.push_back(CStatusMessage(this).validationError("Wrong TAS, %1") << ui->lbl_CruiseTrueAirspeed->text());
|
||||
|
||||
@@ -358,7 +358,7 @@ namespace BlackGui
|
||||
if (situations.isEmpty()) { return; }
|
||||
|
||||
CAltitude alt;
|
||||
alt.parseFromString(elv);
|
||||
alt.parseFromString(elv, CPqString::SeparatorBestGuess);
|
||||
const CElevationPlane ep(situations.latestAdjustedObject(), alt, CElevationPlane::singlePointRadius());
|
||||
|
||||
// inject as received from simulator
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace BlackGui
|
||||
{
|
||||
const QString e = ui->le_Elevation->text().trimmed();
|
||||
CAltitude a;
|
||||
a.parseFromString(e);
|
||||
a.parseFromString(e, CPqString::SeparatorBestGuess);
|
||||
ui->lblp_ElvCheck->setTicked(!e.isNull());
|
||||
CCoordinateGeodetic c = m_coordinate;
|
||||
c.setGeodeticHeight(a);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace BlackGui
|
||||
{
|
||||
CAngle pitch;
|
||||
const QString p = ui->le_PitchOnGround->text().trimmed();
|
||||
pitch.parseFromString(p, CPqString::SeparatorsBestGuess);
|
||||
pitch.parseFromString(p, CPqString::SeparatorBestGuess);
|
||||
return pitch;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
CLength cg;
|
||||
cg.parseFromString(v);
|
||||
cg.parseFromString(v, CPqString::SeparatorBestGuess);
|
||||
return cg;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace BlackMisc
|
||||
|
||||
void CAltitude::parseFromString(const QString &value)
|
||||
{
|
||||
this->parseFromString(value, CPqString::SeparatorsBestGuess);
|
||||
this->parseFromString(value, CPqString::SeparatorBestGuess);
|
||||
}
|
||||
|
||||
void CAltitude::parseFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Altitude as string
|
||||
CAltitude(const QString &altitudeAsString, PhysicalQuantities::CPqString::SeparatorMode mode = PhysicalQuantities::CPqString::SeparatorsBestGuess);
|
||||
CAltitude(const QString &altitudeAsString, PhysicalQuantities::CPqString::SeparatorMode mode = PhysicalQuantities::CPqString::SeparatorBestGuess);
|
||||
|
||||
//! Constructor by CLength
|
||||
CAltitude(const PhysicalQuantities::CLength &altitude, ReferenceDatum datum) : CLength(altitude), m_datum(datum) {}
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorsCLocale);
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorQtDefault);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
|
||||
@@ -117,13 +117,13 @@ namespace BlackMisc
|
||||
double numberD = -1;
|
||||
switch (mode)
|
||||
{
|
||||
case SeparatorsLocale:
|
||||
case SeparatorLocale:
|
||||
numberD = QLocale::system().toDouble(number, &success);
|
||||
break;
|
||||
case SeparatorsCLocale:
|
||||
case SeparatorQtDefault:
|
||||
numberD = number.toDouble(&success);
|
||||
break;
|
||||
case SeparatorsBestGuess:
|
||||
case SeparatorBestGuess:
|
||||
numberD = number.toDouble(&success);
|
||||
if (!success) { numberD = QLocale::system().toDouble(number, &success); }
|
||||
break;
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace BlackMisc
|
||||
//! Number separators / group separators
|
||||
enum SeparatorMode
|
||||
{
|
||||
SeparatorsCLocale, //!< 100,000.00
|
||||
SeparatorsLocale, //!< depending on QLocale, e.g. 100.000,00 in Germany
|
||||
SeparatorsBestGuess //!< try to figure out
|
||||
SeparatorQtDefault, //!< 100000.00 no group separator
|
||||
SeparatorLocale, //!< depending on QLocale, e.g. 100.000,00 in Germany
|
||||
SeparatorBestGuess //!< try to figure out
|
||||
};
|
||||
|
||||
//! Group and digit separator
|
||||
@@ -57,10 +57,10 @@ namespace BlackMisc
|
||||
CPqString(const QString &value) : m_string(value) {}
|
||||
|
||||
//! Parse a string value like "100m", "10.3Mhz"
|
||||
static CVariant parseToVariant(const QString &value, SeparatorMode mode = SeparatorsCLocale);
|
||||
static CVariant parseToVariant(const QString &value, SeparatorMode mode = SeparatorQtDefault);
|
||||
|
||||
//! Parse into concrete type
|
||||
template <class PQ> static PQ parse(const QString &value, SeparatorMode mode = SeparatorsCLocale)
|
||||
template <class PQ> static PQ parse(const QString &value, SeparatorMode mode = SeparatorQtDefault)
|
||||
{
|
||||
if (value.isEmpty()) {return PQ::null(); }
|
||||
if (value.contains("null", Qt::CaseInsensitive)) { return PQ::null(); }
|
||||
@@ -73,7 +73,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Locale aware parsing
|
||||
static double parseNumber(const QString &number, bool &success, SeparatorMode mode = SeparatorsCLocale);
|
||||
static double parseNumber(const QString &number, bool &success, SeparatorMode mode = SeparatorBestGuess);
|
||||
|
||||
private:
|
||||
QString m_string;
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace BlackMisc
|
||||
const QString p = this->part(index);
|
||||
if (p.isEmpty()) { return false; }
|
||||
bool ok = false;
|
||||
CPqString::parseNumber(p, ok, CPqString::SeparatorsBestGuess);
|
||||
CPqString::parseNumber(p, ok, CPqString::SeparatorBestGuess);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace BlackMisc
|
||||
const QString p = this->part(index);
|
||||
if (p.isEmpty()) { return def; }
|
||||
bool ok = false;
|
||||
double d = CPqString::parseNumber(p, ok, CPqString::SeparatorsBestGuess);
|
||||
double d = CPqString::parseNumber(p, ok, CPqString::SeparatorBestGuess);
|
||||
return ok ? d : def;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user