mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 07:35:53 +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()
|
const QStringList &CDbAircraftIcaoSelectorComponent::completerStrings()
|
||||||
{
|
{
|
||||||
// done for performance reasons
|
const int c = sGui->getWebDataServices()->getAircraftIcaoCodesCount();
|
||||||
// init only once, future instance can share thte list
|
if (c != m_completerStrings.size())
|
||||||
// only to be called when data are read!
|
{
|
||||||
static const QStringList cs(sGui->getWebDataServices()->getAircraftIcaoCodes().toCompleterStrings(true, true, true));
|
CAircraftIcaoCodeList icaos(sGui->getWebDataServices()->getAircraftIcaoCodes());
|
||||||
return cs;
|
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)
|
void CDbAircraftIcaoSelectorComponent::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||||
@@ -191,7 +195,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
QCompleter *c = new QCompleter(completerStrings(), this);
|
QCompleter *c = new QCompleter(this->completerStrings(), this);
|
||||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
c->setMaxVisibleItems(10);
|
c->setMaxVisibleItems(10);
|
||||||
|
|||||||
@@ -118,10 +118,11 @@ namespace BlackGui
|
|||||||
QScopedPointer<QCompleter> m_completerIcaoDescription;
|
QScopedPointer<QCompleter> m_completerIcaoDescription;
|
||||||
BlackMisc::Aviation::CAircraftIcaoCode m_currentIcao;
|
BlackMisc::Aviation::CAircraftIcaoCode m_currentIcao;
|
||||||
Display m_display = DisplayIcaoAndId;
|
Display m_display = DisplayIcaoAndId;
|
||||||
|
QStringList m_completerStrings; //!< the completer strings
|
||||||
|
|
||||||
//! Get the completer strings
|
//! Get the completer strings
|
||||||
//! \remark shared for performance reasons
|
//! \remark shared for performance reasons
|
||||||
static const QStringList &completerStrings();
|
const QStringList &completerStrings();
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user