refs #873, changed signal for selector in internal component

This commit is contained in:
Klaus Basan
2017-02-02 01:15:46 +01:00
committed by Mathew Sutcliffe
parent 2a0d0e1d84
commit 7e70662a29
4 changed files with 28 additions and 3 deletions

View File

@@ -86,6 +86,8 @@ namespace BlackGui
connect(ui->pb_LatestPartsLog, &QPushButton::pressed, this, &CInternalsComponent::ps_showLogFiles); connect(ui->pb_LatestPartsLog, &QPushButton::pressed, this, &CInternalsComponent::ps_showLogFiles);
connect(ui->pb_RequestFromNetwork, &QPushButton::pressed, this, &CInternalsComponent::ps_requestPartsFromNetwork); connect(ui->pb_RequestFromNetwork, &QPushButton::pressed, this, &CInternalsComponent::ps_requestPartsFromNetwork);
connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::ps_selectorChanged);
contextFlagsToGui(); contextFlagsToGui();
} }
@@ -312,6 +314,11 @@ namespace BlackGui
}); });
} }
void CInternalsComponent::ps_selectorChanged()
{
this->ps_setCurrentParts();
}
CAircraftParts CInternalsComponent::guiToAircraftParts() const CAircraftParts CInternalsComponent::guiToAircraftParts() const
{ {
const CAircraftLights lights( const CAircraftLights lights(

View File

@@ -75,6 +75,9 @@ namespace BlackGui
//! Request parts (aka aircraft config) from network //! Request parts (aka aircraft config) from network
void ps_requestPartsFromNetwork(); void ps_requestPartsFromNetwork();
//! Selector has been changed
void ps_selectorChanged();
private: private:
QScopedPointer<Ui::CInternalsComponent> ui; QScopedPointer<Ui::CInternalsComponent> ui;

View File

@@ -41,6 +41,7 @@ namespace BlackGui
Q_ASSERT(s); Q_ASSERT(s);
s = connect(sGui->getIContextNetwork(), &IContextNetwork::addedAircraft, this, &CRemoteAircraftSelector::ps_onAddedAircraft); s = connect(sGui->getIContextNetwork(), &IContextNetwork::addedAircraft, this, &CRemoteAircraftSelector::ps_onAddedAircraft);
Q_ASSERT(s); Q_ASSERT(s);
s = connect(ui->cb_RemoteAircraftSelector, &QComboBox::currentTextChanged, this, &CRemoteAircraftSelector::ps_comboBoxChanged);
Q_UNUSED(s); Q_UNUSED(s);
} }
@@ -83,6 +84,13 @@ namespace BlackGui
} }
} }
void CRemoteAircraftSelector::ps_comboBoxChanged(const QString &text)
{
if (this->m_currentText == text) { return; }
this->m_currentText = text;
emit this->changedCallsign();
}
void CRemoteAircraftSelector::fillComboBox() void CRemoteAircraftSelector::fillComboBox()
{ {
if (!this->isVisible()) { return; } // for performance reasons if (!this->isVisible()) { return; } // for performance reasons
@@ -127,6 +135,5 @@ namespace BlackGui
ui->cb_RemoteAircraftSelector->setCurrentIndex(index); ui->cb_RemoteAircraftSelector->setCurrentIndex(index);
} }
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -47,6 +47,10 @@ namespace BlackGui
//! Indicate if aircraft parts enabled aircraft //! Indicate if aircraft parts enabled aircraft
void indicatePartsEnabled(bool indicate); void indicatePartsEnabled(bool indicate);
signals:
//! Callsign changed
void changedCallsign();
protected: protected:
//! \copydoc QWidget::showEvent //! \copydoc QWidget::showEvent
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
@@ -58,15 +62,19 @@ namespace BlackGui
//! IContextNetwork::removedAircraft //! IContextNetwork::removedAircraft
void ps_onRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign); void ps_onRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
//! Combo box has been changed
void ps_comboBoxChanged(const QString &text);
private: private:
QScopedPointer<Ui::CRemoteAircraftSelector> ui; QScopedPointer<Ui::CRemoteAircraftSelector> ui;
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
QString m_currentText;
bool m_showPartsEnabled = false; bool m_showPartsEnabled = false;
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
//! Set combobox items //! Set combobox items
void fillComboBox(); void fillComboBox();
}; };
} // namespace } // namespace
} // namespace } // namespace