mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Completer sort order and ICAO code string building
This commit is contained in:
@@ -177,12 +177,13 @@ namespace BlackGui
|
||||
|
||||
const QStringList &CDbAircraftIcaoSelectorComponent::completerStrings()
|
||||
{
|
||||
static const QStringList empty;
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getWebDataServices()) { return empty; }
|
||||
const int c = sGui->getWebDataServices()->getAircraftIcaoCodesCount();
|
||||
if (c != m_completerStrings.size())
|
||||
{
|
||||
CAircraftIcaoCodeList icaos(sGui->getWebDataServices()->getAircraftIcaoCodes());
|
||||
icaos.removeInvalidCombinedCodes();
|
||||
icaos.sortByDesignatorManufacturerAndRank();
|
||||
m_completerStrings = icaos.toCompleterStrings(true, true, true);
|
||||
}
|
||||
return m_completerStrings;
|
||||
@@ -190,7 +191,7 @@ namespace BlackGui
|
||||
|
||||
void CDbAircraftIcaoSelectorComponent::onCodesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
if (!sGui || !sGui->hasWebDataServices()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->hasWebDataServices()) { return; }
|
||||
if (entity.testFlag(CEntityFlags::AircraftIcaoEntity) && CEntityFlags::isFinishedReadState(readState))
|
||||
{
|
||||
if (count > 0)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "blackmisc/simulation/aircraftmodelinterfaces.h"
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/directories.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/connectionguard.h"
|
||||
|
||||
@@ -128,6 +129,7 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
|
||||
BlackMisc::Simulation::IAircraftModelLoader *m_modelLoader = nullptr; //!< read own aircraft models, aka models on disk
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< currently init to simulator
|
||||
BlackMisc::CSetting<BlackMisc::Settings::TDirectorySettings> m_directorySettings { this }; //!< the swift directories
|
||||
|
||||
//! Request own models
|
||||
void requestOwnModelsUpdate();
|
||||
@@ -166,7 +168,7 @@ namespace BlackGui
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
|
||||
//! Directory selector for given simulator
|
||||
static QString directorySelector(const BlackMisc::Simulation::CSimulatorInfo &simulatorInfo);
|
||||
QString directorySelector(const BlackMisc::Simulation::CSimulatorInfo &simulatorInfo);
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
|
||||
@@ -468,32 +468,30 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftIcaoCode::getCombinedIcaoStringWithKey() const
|
||||
{
|
||||
QString s(hasDesignator() ? getDesignator() : "????");
|
||||
if (hasManufacturer()) { s = s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s = s.append(" ").append(getModelDescription()); }
|
||||
return s.append(getDbKeyAsStringInParentheses(" "));
|
||||
return (this->hasDesignator() ? this->getDesignator() : QStringLiteral("????")) %
|
||||
(this->hasManufacturer() ? (QStringLiteral(" ") % this->getManufacturer()) : QStringLiteral("")) %
|
||||
(this->hasModelDescription() ? (QStringLiteral(" ") % this->getModelDescription()) : QStringLiteral("")) %
|
||||
this->getDbKeyAsStringInParentheses(" ");
|
||||
}
|
||||
|
||||
QString CAircraftIcaoCode::getCombinedIataStringWithKey() const
|
||||
{
|
||||
if (!this->hasIataCode()) { return ""; }
|
||||
QString s(getIataCode());
|
||||
s = s.append(" [IATA]");
|
||||
if (hasDesignator()) { s.append(" ").append(getDesignator()); }
|
||||
if (hasManufacturer()) { s = s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s = s.append(" ").append(getModelDescription()); }
|
||||
return s.append(getDbKeyAsStringInParentheses(" "));
|
||||
return this->getIataCode() % QStringLiteral(" [IATA") %
|
||||
(this->hasDesignator() ? (QStringLiteral(" ") % this->getDesignator()) : QStringLiteral("")) %
|
||||
(this->hasManufacturer() ? (QStringLiteral(" ") % this->getManufacturer()) : QStringLiteral("")) %
|
||||
(this->hasModelDescription() ? (QStringLiteral(" ") % this->getModelDescription()) : QStringLiteral("")) %
|
||||
this->getDbKeyAsStringInParentheses(" ");
|
||||
}
|
||||
|
||||
QString CAircraftIcaoCode::getCombinedFamilyStringWithKey() const
|
||||
{
|
||||
if (!this->hasFamily()) { return ""; }
|
||||
QString s(getFamily());
|
||||
s = s.append(" [family]");
|
||||
if (hasDesignator()) { s.append(" ").append(getDesignator()); }
|
||||
if (hasManufacturer()) { s.append(" ").append(getManufacturer()); }
|
||||
if (hasModelDescription()) { s.append(" ").append(getModelDescription()); }
|
||||
return s.append(getDbKeyAsStringInParentheses(" "));
|
||||
return this->getFamily() % QStringLiteral(" [family") %
|
||||
(this->hasDesignator() ? (QStringLiteral(" ") % this->getDesignator()) : QStringLiteral("")) %
|
||||
(this->hasManufacturer() ? (QStringLiteral(" ") % this->getManufacturer()) : QStringLiteral("")) %
|
||||
(this->hasModelDescription() ? (QStringLiteral(" ") % this->getModelDescription()) : QStringLiteral("")) %
|
||||
this->getDbKeyAsStringInParentheses(" ");
|
||||
}
|
||||
|
||||
bool CAircraftIcaoCode::hasCompleteData() const
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace BlackMisc
|
||||
CAircraftIcaoCodeList icaos(*this);
|
||||
if (sort) { icaos.sortByDesignatorAndRank(); }
|
||||
|
||||
// 3 steps to get a proper sort order
|
||||
// 3 steps to get a proper sort order of the string list
|
||||
for (const CAircraftIcaoCode &icao : as_const(icaos))
|
||||
{
|
||||
c.append(icao.getCombinedIcaoStringWithKey());
|
||||
@@ -230,8 +230,8 @@ namespace BlackMisc
|
||||
|
||||
if (withFamily)
|
||||
{
|
||||
icaos = this->findWithFamily(true);
|
||||
for (const CAircraftIcaoCode &icao : as_const(icaos))
|
||||
const CAircraftIcaoCodeList icaosFamily = icaos.findWithFamily(true);
|
||||
for (const CAircraftIcaoCode &icao : icaosFamily)
|
||||
{
|
||||
c.append(icao.getCombinedFamilyStringWithKey());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user