mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T219, unified selector namings and keep editable even without DB completer data.
Also "private slots" -> "private"
This commit is contained in:
@@ -50,9 +50,9 @@ namespace BlackGui
|
||||
this->setAcceptDrops(true);
|
||||
this->setAcceptedMetaTypeIds({qMetaTypeId<CAircraftIcaoCode>(), qMetaTypeId<CAircraftIcaoCodeList>()});
|
||||
ui->le_Aircraft->setValidator(new CUpperCaseValidator(this));
|
||||
connect(ui->le_Aircraft, &QLineEdit::editingFinished, this, &CDbAircraftIcaoSelectorComponent::ps_dataChanged);
|
||||
connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAircraftIcaoSelectorComponent::ps_codesRead);
|
||||
this->ps_codesRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getAircraftIcaoCodesCount());
|
||||
connect(ui->le_Aircraft, &QLineEdit::editingFinished, this, &CDbAircraftIcaoSelectorComponent::onDataChanged);
|
||||
connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAircraftIcaoSelectorComponent::onCodesRead);
|
||||
this->onCodesRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getAircraftIcaoCodesCount());
|
||||
}
|
||||
|
||||
CDbAircraftIcaoSelectorComponent::~CDbAircraftIcaoSelectorComponent()
|
||||
@@ -188,7 +188,7 @@ namespace BlackGui
|
||||
return m_completerStrings;
|
||||
}
|
||||
|
||||
void CDbAircraftIcaoSelectorComponent::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
void CDbAircraftIcaoSelectorComponent::onCodesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
if (!sGui || !sGui->hasWebDataServices()) { return; }
|
||||
if (entity.testFlag(CEntityFlags::AircraftIcaoEntity) && readState == CEntityFlags::ReadFinished)
|
||||
@@ -200,7 +200,7 @@ namespace BlackGui
|
||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||
c->setMaxVisibleItems(10);
|
||||
c->popup()->setMinimumWidth(175);
|
||||
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAircraftIcaoSelectorComponent::ps_completerActivated);
|
||||
connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAircraftIcaoSelectorComponent::onCompleterActivated);
|
||||
|
||||
ui->le_Aircraft->setCompleter(c);
|
||||
m_completerIcaoDescription.reset(c); // deletes any old completer
|
||||
@@ -209,12 +209,11 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
this->m_completerIcaoDescription.reset(nullptr);
|
||||
this->setReadOnly(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDbAircraftIcaoSelectorComponent::ps_dataChanged()
|
||||
void CDbAircraftIcaoSelectorComponent::onDataChanged()
|
||||
{
|
||||
if (!sGui || !sGui->hasWebDataServices()) { return; }
|
||||
const int key = CDatastoreUtility::extractIntegerKey(ui->le_Aircraft->text());
|
||||
@@ -232,7 +231,7 @@ namespace BlackGui
|
||||
this->setAircraftIcao(icao);
|
||||
}
|
||||
|
||||
void CDbAircraftIcaoSelectorComponent::ps_completerActivated(const QString &icaoString)
|
||||
void CDbAircraftIcaoSelectorComponent::onCompleterActivated(const QString &icaoString)
|
||||
{
|
||||
const int dbKey = CDatastoreUtility::extractIntegerKey(icaoString);
|
||||
if (dbKey < 0) { return; }
|
||||
|
||||
@@ -103,26 +103,25 @@ namespace BlackGui
|
||||
//! \copydoc QWidget::dropEvent
|
||||
virtual void dropEvent(QDropEvent *event) override;
|
||||
|
||||
private slots:
|
||||
//! Distributors have been read
|
||||
void ps_codesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
//! Data have been changed
|
||||
void ps_dataChanged();
|
||||
|
||||
//! Data have been changed
|
||||
void ps_completerActivated(const QString &icaoString);
|
||||
|
||||
private:
|
||||
//! Distributors have been read
|
||||
void onCodesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
//! Data have been changed
|
||||
void onCompleterActivated(const QString &icaoString);
|
||||
|
||||
//! Data have been changed
|
||||
void onDataChanged();
|
||||
|
||||
//! Get the completer strings
|
||||
//! \remark shared for performance reasons
|
||||
const QStringList &completerStrings();
|
||||
|
||||
QScopedPointer<Ui::CDbAircraftIcaoSelectorComponent> ui;
|
||||
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
|
||||
const QStringList &completerStrings();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -19,11 +19,8 @@
|
||||
<property name="whatsThis">
|
||||
<string>search for correct ICAO code</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_AircraftIcaoSelectorComponent">
|
||||
<property name="leftMargin">
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
this->setFocusProxy(ui->le_Airline);
|
||||
ui->le_Airline->setValidator(new CUpperCaseValidator(this));
|
||||
connect(ui->le_Airline, &QLineEdit::editingFinished, this, &CDbAirlineIcaoSelectorComponent::ps_dataChanged);
|
||||
connect(ui->le_Airline, &QLineEdit::editingFinished, this, &CDbAirlineIcaoSelectorComponent::onDataChanged);
|
||||
}
|
||||
|
||||
CDbAirlineIcaoSelectorComponent::~CDbAirlineIcaoSelectorComponent()
|
||||
@@ -97,7 +97,7 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
void CDbAirlineIcaoSelectorComponent::ps_dataChanged()
|
||||
void CDbAirlineIcaoSelectorComponent::onDataChanged()
|
||||
{
|
||||
if (!sGui) { return; }
|
||||
QString s(ui->le_Airline->text());
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackGui
|
||||
|
||||
//! Destructor
|
||||
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
||||
~CDbAirlineIcaoSelectorComponent();
|
||||
virtual ~CDbAirlineIcaoSelectorComponent();
|
||||
|
||||
//! \name Base class overrides
|
||||
//! @{
|
||||
@@ -71,17 +71,16 @@ namespace BlackGui
|
||||
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
||||
virtual QCompleter *createCompleter() override;
|
||||
|
||||
private slots:
|
||||
//! Data have been changed
|
||||
void ps_dataChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbAirlineIcaoSelectorComponent> ui;
|
||||
Display m_display = DisplayVDesignatorAndId;
|
||||
|
||||
//! Get the completer strings
|
||||
//! \remark shared for performance reasons
|
||||
static const QStringList &completerStrings();
|
||||
|
||||
//! Data have been changed
|
||||
void onDataChanged();
|
||||
|
||||
QScopedPointer<Ui::CDbAirlineIcaoSelectorComponent> ui;
|
||||
Display m_display = DisplayVDesignatorAndId;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user