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