mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #681, FSD UI at login screen
* plus completers for login GUI (ICAO, ...) * some utility functions in related value object classed
This commit is contained in:
@@ -490,9 +490,10 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString CAircraftIcaoCode::normalizeDesignator(const QString candidate)
|
||||
QString CAircraftIcaoCode::normalizeDesignator(const QString candidate)
|
||||
{
|
||||
QString n(candidate.trimmed().toUpper());
|
||||
if (n.contains(' ')) { n = n.left(n.indexOf(' ')); } // cutoff as first space
|
||||
if (n.isEmpty()) { return n; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace BlackMisc
|
||||
static const QStringList &getSpecialDesignators();
|
||||
|
||||
//! Normalize designator, remove illegal characters
|
||||
static const QString normalizeDesignator(const QString candidate);
|
||||
static QString normalizeDesignator(const QString candidate);
|
||||
|
||||
//! Create relaxed combined codes, e.g "L2J" -> "L3J", ...
|
||||
static QStringList alternativeCombinedCodes(const QString &combinedCode);
|
||||
|
||||
@@ -263,6 +263,18 @@ namespace BlackMisc
|
||||
return (regexp.match(airline).hasMatch());
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::normalizeDesignator(const QString candidate)
|
||||
{
|
||||
QString n(candidate.trimmed().toUpper());
|
||||
if (n.contains(' ')) { n = n.left(n.indexOf(' ')); } // cutoff as first space
|
||||
if (n.isEmpty()) { return n; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("[^a-zA-Z\\d\\s]")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
return n.remove(regexp);
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getCombinedStringWithKey() const
|
||||
{
|
||||
QString s(getVDesignator());
|
||||
|
||||
@@ -180,6 +180,9 @@ namespace BlackMisc
|
||||
//! Valid designator?
|
||||
static bool isValidAirlineDesignator(const QString &airline);
|
||||
|
||||
//! Normalize string as airline designator
|
||||
static QString normalizeDesignator(const QString candidate);
|
||||
|
||||
//! From our DB JSON
|
||||
static CAirlineIcaoCode fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
|
||||
|
||||
|
||||
@@ -154,6 +154,20 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
QStringList CAirlineIcaoCodeList::toIcaoDesignatorNameCountryCompleterStrings(bool sort) const
|
||||
{
|
||||
QStringList c;
|
||||
for (const CAirlineIcaoCode &icao : *this)
|
||||
{
|
||||
if (!icao.hasValidDesignator()) { continue; }
|
||||
const QString cs(icao.getDesignatorNameCountry());
|
||||
if (cs.isEmpty()) { continue; }
|
||||
c.append(cs);
|
||||
}
|
||||
if (sort) { c.sort(); }
|
||||
return c;
|
||||
}
|
||||
|
||||
QStringList CAirlineIcaoCodeList::toNameCompleterStrings(bool sort) const
|
||||
{
|
||||
QStringList c;
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace BlackMisc
|
||||
//! String list for completion by ICAO designator
|
||||
QStringList toIcaoDesignatorCompleterStrings(bool combinedString = true, bool sort = true) const;
|
||||
|
||||
//! String list for completion by ICAO designator plus Name
|
||||
QStringList toIcaoDesignatorNameCountryCompleterStrings(bool sort = true) const;
|
||||
|
||||
//! String list for completion by name
|
||||
QStringList toNameCompleterStrings(bool sort = true) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user