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