mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #535 completer for airline name
* common base class for airline completers * changed dependend classes
This commit is contained in:
@@ -210,6 +210,19 @@ namespace BlackMisc
|
||||
return s.append(" ").append(getDbKeyAsStringInParentheses());
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getNameWithKey() const
|
||||
{
|
||||
if (!hasValidDbKey()) { return getName(); }
|
||||
if (hasName())
|
||||
{
|
||||
return QString(getName()).append(" ").append(getDbKeyAsStringInParentheses());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getDbKeyAsStringInParentheses();
|
||||
}
|
||||
}
|
||||
|
||||
void CAirlineIcaoCode::updateMissingParts(const CAirlineIcaoCode &otherIcaoCode)
|
||||
{
|
||||
if (!this->hasValidDesignator()) { this->setDesignator(otherIcaoCode.getDesignator()); }
|
||||
|
||||
@@ -76,6 +76,9 @@ namespace BlackMisc
|
||||
//! Get name, e.g. "Lufthansa"
|
||||
const QString &getName() const { return this->m_name; }
|
||||
|
||||
//! Name plus key, e.g. "Lufthansa (3421)"
|
||||
QString getNameWithKey() const;
|
||||
|
||||
//! Set name
|
||||
void setName(const QString &name) { this->m_name = name.trimmed(); }
|
||||
|
||||
|
||||
@@ -60,16 +60,30 @@ namespace BlackMisc
|
||||
return codes;
|
||||
}
|
||||
|
||||
QStringList CAirlineIcaoCodeList::toCompleterStrings() const
|
||||
QStringList CAirlineIcaoCodeList::toIcaoDesignatorCompleterStrings() const
|
||||
{
|
||||
QStringList c;
|
||||
for (const CAirlineIcaoCode &icao : *this)
|
||||
{
|
||||
QString cs(icao.getCombinedStringWithKey());
|
||||
if (!icao.hasValidDbKey()) { continue; }
|
||||
const QString cs(icao.getCombinedStringWithKey());
|
||||
if (cs.isEmpty()) { continue; }
|
||||
c.append(cs);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
QStringList CAirlineIcaoCodeList::toNameCompleterStrings() const
|
||||
{
|
||||
QStringList c;
|
||||
for (const CAirlineIcaoCode &icao : *this)
|
||||
{
|
||||
if (!icao.hasValidDbKey()) { continue; }
|
||||
const QString cs(icao.getNameWithKey());
|
||||
if (cs.isEmpty()) { continue; }
|
||||
c.append(cs);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -49,8 +49,11 @@ namespace BlackMisc
|
||||
//! Find by v-designator, this should be unique
|
||||
CAirlineIcaoCode findByVDesignator(const QString &designator);
|
||||
|
||||
//! String list for completion
|
||||
QStringList toCompleterStrings() const;
|
||||
//! String list for completion by ICAO designator
|
||||
QStringList toIcaoDesignatorCompleterStrings() const;
|
||||
|
||||
//! String list for completion by name
|
||||
QStringList toNameCompleterStrings() const;
|
||||
|
||||
//! From our DB JSON
|
||||
static CAirlineIcaoCodeList fromDatabaseJson(const QJsonArray &array, bool ignoreIncomplete = true);
|
||||
|
||||
Reference in New Issue
Block a user