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_RequestFromNetwork, &QPushButton::pressed, this, &CInternalsComponent::ps_requestPartsFromNetwork);
connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::ps_selectorChanged);
contextFlagsToGui();
}
@@ -312,6 +314,11 @@ namespace BlackGui
});
}
void CInternalsComponent::ps_selectorChanged()
{
this->ps_setCurrentParts();
}
CAircraftParts CInternalsComponent::guiToAircraftParts() const
{
const CAircraftLights lights(

View File

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

View File

@@ -41,6 +41,7 @@ namespace BlackGui
Q_ASSERT(s);
s = connect(sGui->getIContextNetwork(), &IContextNetwork::addedAircraft, this, &CRemoteAircraftSelector::ps_onAddedAircraft);
Q_ASSERT(s);
s = connect(ui->cb_RemoteAircraftSelector, &QComboBox::currentTextChanged, this, &CRemoteAircraftSelector::ps_comboBoxChanged);
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()
{
if (!this->isVisible()) { return; } // for performance reasons
@@ -127,6 +135,5 @@ namespace BlackGui
ui->cb_RemoteAircraftSelector->setCurrentIndex(index);
}
}
} // namespace
} // namespace

View File

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