mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T80, improved completer
* no invalid combined codes in list * sort by rank * refresh completer strings when new codes are added
This commit is contained in:
@@ -177,11 +177,15 @@ namespace BlackGui
|
||||
|
||||
const QStringList &CDbAircraftIcaoSelectorComponent::completerStrings()
|
||||
{
|
||||
// done for performance reasons
|
||||
// init only once, future instance can share thte list
|
||||
// only to be called when data are read!
|
||||
static const QStringList cs(sGui->getWebDataServices()->getAircraftIcaoCodes().toCompleterStrings(true, true, true));
|
||||
return cs;
|
||||
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;
|
||||
}
|
||||
|
||||
void CDbAircraftIcaoSelectorComponent::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
@@ -191,7 +195,7 @@ namespace BlackGui
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
QCompleter *c = new QCompleter(completerStrings(), this);
|
||||
QCompleter *c = new QCompleter(this->completerStrings(), this);
|
||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||
c->setMaxVisibleItems(10);
|
||||
|
||||
@@ -118,10 +118,11 @@ namespace BlackGui
|
||||
QScopedPointer<QCompleter> m_completerIcaoDescription;
|
||||
BlackMisc::Aviation::CAircraftIcaoCode m_currentIcao;
|
||||
Display m_display = DisplayIcaoAndId;
|
||||
QStringList m_completerStrings; //!< the completer strings
|
||||
|
||||
//! Get the completer strings
|
||||
//! \remark shared for performance reasons
|
||||
static const QStringList &completerStrings();
|
||||
const QStringList &completerStrings();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user