From 6ca0d480d3225b3a7773591785a9562146d696c4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 23 Sep 2015 23:22:05 +0200 Subject: [PATCH] refs #452 adjusted GUI components to * changed classes (e.g. CAircraft -> CSimulatedAircraft) * changes signatures in contexts / providers * minor fixes as renamed GUI widgets, asserts, paint event --- src/blackgui/components/aircraftcomponent.h | 1 - .../components/atcstationcomponent.ui | 12 --- .../components/cockpitcomcomponent.cpp | 18 ++-- src/blackgui/components/cockpitcomcomponent.h | 11 +- src/blackgui/components/cockpitcomponent.h | 2 + .../components/cockpitinfoareacomponent.ui | 8 +- .../cockpittranspondermodeledscomponent.cpp | 7 +- .../cockpittranspondermodeledscomponent.h | 6 +- .../components/coreinfoareacomponent.ui | 20 ++-- .../components/flightplancomponent.cpp | 13 ++- src/blackgui/components/flightplancomponent.h | 7 +- .../components/infowindowcomponent.cpp | 37 +------ src/blackgui/components/infowindowcomponent.h | 4 +- .../components/internalscomponent.cpp | 1 + src/blackgui/components/logincomponent.cpp | 102 +++++++++--------- src/blackgui/components/logincomponent.h | 11 +- .../components/maininfoareacomponent.cpp | 2 +- .../components/maininfoareacomponent.ui | 6 +- .../components/mainkeypadareacomponent.cpp | 3 +- .../components/mainkeypadareacomponent.h | 3 +- .../components/remoteaircraftselector.cpp | 4 +- src/blackgui/components/settingscomponent.h | 1 - .../components/settingsfsxcomponent.cpp | 1 + .../settingsnetworkserverscomponent.cpp | 6 +- .../settingsnetworkserverscomponent.h | 2 +- .../components/simulatorcomponent.cpp | 4 +- .../components/textmessagecomponent.cpp | 6 +- .../components/textmessagecomponent.h | 3 +- src/blackgui/infoarea.cpp | 6 +- src/blackgui/managedstatusbar.cpp | 3 + 30 files changed, 132 insertions(+), 178 deletions(-) diff --git a/src/blackgui/components/aircraftcomponent.h b/src/blackgui/components/aircraftcomponent.h index 2dfbee3ad..d92f19849 100644 --- a/src/blackgui/components/aircraftcomponent.h +++ b/src/blackgui/components/aircraftcomponent.h @@ -16,7 +16,6 @@ #include "blackgui/components/enableforruntime.h" #include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/components/updatetimer.h" -#include "blackmisc/aviation/aircraft.h" #include #include diff --git a/src/blackgui/components/atcstationcomponent.ui b/src/blackgui/components/atcstationcomponent.ui index 472ec40f2..bc40ccd5f 100644 --- a/src/blackgui/components/atcstationcomponent.ui +++ b/src/blackgui/components/atcstationcomponent.ui @@ -10,12 +10,6 @@ 462 - - - 0 - 0 - - ATC stations @@ -44,12 +38,6 @@ - - - 0 - 0 - - 16777215 diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp index a4fd365bb..c710be729 100644 --- a/src/blackgui/components/cockpitcomcomponent.cpp +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -13,7 +13,6 @@ #include "blackcore/context_network.h" #include "blackcore/context_ownaircraft.h" #include "blackcore/context_audio.h" -#include "blackmisc/aviation/aircraft.h" #include "blackmisc/audio/voiceroomlist.h" #include "blackmisc/logmessage.h" @@ -25,6 +24,7 @@ using namespace BlackCore; using namespace BlackMisc; using namespace BlackMisc::Audio; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; using namespace BlackMisc::PhysicalQuantities; namespace BlackGui @@ -62,7 +62,7 @@ namespace BlackGui Q_ASSERT(this->getIContextAudio()); // init from aircraft - CAircraft ownAircraft = this->getOwnAircraft(); + CSimulatedAircraft ownAircraft = this->getOwnAircraft(); this->ps_updateCockpitFromContext(ownAircraft, CIdentifier("dummyInitialValues")); // intentionally different name here // SELCAL pairs in cockpit @@ -106,7 +106,7 @@ namespace BlackGui this->ui->ds_ComPanelCom2Standby->setValue(f); } - const CAircraft ownAircraft = this->cockpitValuesToAircraftObject(); + const CSimulatedAircraft ownAircraft = this->cockpitValuesToAircraftObject(); this->updateOwnCockpitInContext(ownAircraft); } @@ -115,7 +115,7 @@ namespace BlackGui this->getIContextOwnAircraft()->updateSelcal(this->getSelcal(), identifier()); } - void CCockpitComComponent::ps_updateCockpitFromContext(const CAircraft &ownAircraft, const CIdentifier &originator) + void CCockpitComComponent::ps_updateCockpitFromContext(const CSimulatedAircraft &ownAircraft, const CIdentifier &originator) { if (isMyIdentifier(originator)) { return; } // comes from myself @@ -201,9 +201,9 @@ namespace BlackGui this->ui->led_ComPanelCom2->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 connected", "COM2 disconnected", 14); } - CAircraft CCockpitComComponent::cockpitValuesToAircraftObject() + CSimulatedAircraft CCockpitComComponent::cockpitValuesToAircraftObject() { - CAircraft ownAircraft = this->getOwnAircraft(); + CSimulatedAircraft ownAircraft = this->getOwnAircraft(); CTransponder transponder = ownAircraft.getTransponder(); CComSystem com1 = ownAircraft.getCom1System(); CComSystem com2 = ownAircraft.getCom2System(); @@ -238,14 +238,14 @@ namespace BlackGui return ownAircraft; } - CAircraft CCockpitComComponent::getOwnAircraft() const + CSimulatedAircraft CCockpitComComponent::getOwnAircraft() const { Q_ASSERT(this->getIContextOwnAircraft()); - if (!this->getIContextOwnAircraft()) return CAircraft(); + if (!this->getIContextOwnAircraft()) return CSimulatedAircraft(); return this->getIContextOwnAircraft()->getOwnAircraft(); } - bool CCockpitComComponent::updateOwnCockpitInContext(const CAircraft &ownAircraft) + bool CCockpitComComponent::updateOwnCockpitInContext(const CSimulatedAircraft &ownAircraft) { return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), identifier()); } diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h index fd7aca1a7..2cc7718d3 100644 --- a/src/blackgui/components/cockpitcomcomponent.h +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -7,6 +7,8 @@ * contained in the LICENSE file. */ +//! \file + #ifndef BLACKGUI_COCKPITCOMCOMPONENT_H #define BLACKGUI_COCKPITCOMCOMPONENT_H @@ -14,7 +16,6 @@ #include "enablefordockwidgetinfoarea.h" #include "enableforruntime.h" #include "blackmisc/identifiable.h" -#include "blackmisc/aviation/aircraft.h" #include "blackmisc/aviation/transponder.h" #include "blackmisc/audio/voiceroomlist.h" #include @@ -68,7 +69,7 @@ namespace BlackGui void ps_guiChangedSelcal(); //! Update cockpit from context - void ps_updateCockpitFromContext(const BlackMisc::Aviation::CAircraft &ownAircraft, const BlackMisc::CIdentifier &originator); + void ps_updateCockpitFromContext(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft, const BlackMisc::CIdentifier &originator); //! Cockpit values have been changed in GUI void ps_testSelcal(); @@ -84,16 +85,16 @@ namespace BlackGui void initLeds(); //! Cockpit values to aircraft - BlackMisc::Aviation::CAircraft cockpitValuesToAircraftObject(); + BlackMisc::Simulation::CSimulatedAircraft cockpitValuesToAircraftObject(); //! Get own aircraft - BlackMisc::Aviation::CAircraft getOwnAircraft() const; + BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const; //! Current SELCAL code BlackMisc::Aviation::CSelcal getSelcal() const; //! Cockpit updates - bool updateOwnCockpitInContext(const BlackMisc::Aviation::CAircraft &ownAircraft); + bool updateOwnCockpitInContext(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft); //! COM frequencies displayed void updateFrequencyDisplaysFromComSystems(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); diff --git a/src/blackgui/components/cockpitcomponent.h b/src/blackgui/components/cockpitcomponent.h index 23902ee67..bfac015f8 100644 --- a/src/blackgui/components/cockpitcomponent.h +++ b/src/blackgui/components/cockpitcomponent.h @@ -7,6 +7,8 @@ * contained in the LICENSE file. */ +//! \file + #ifndef BLACKGUI_COCKPITCOMPONENT_H #define BLACKGUI_COCKPITCOMPONENT_H diff --git a/src/blackgui/components/cockpitinfoareacomponent.ui b/src/blackgui/components/cockpitinfoareacomponent.ui index a95d27b9c..fc45f7a12 100644 --- a/src/blackgui/components/cockpitinfoareacomponent.ui +++ b/src/blackgui/components/cockpitinfoareacomponent.ui @@ -28,13 +28,19 @@ QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks - + 0 0 + + + 0 + 3 + + diff --git a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp index a4a4ed336..7205005e0 100644 --- a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp +++ b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp @@ -14,6 +14,7 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; using namespace BlackCore; namespace BlackGui @@ -37,7 +38,7 @@ namespace BlackGui this->setMode(getOwnTransponder().getTransponderMode()); } - void CCockpitTransponderModeLedsComponent::ps_onAircraftCockpitChanged(const CAircraft &aircraft, const BlackMisc::CIdentifier &originator) + void CCockpitTransponderModeLedsComponent::ps_onAircraftCockpitChanged(const CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator) { if (isMyIdentifier(originator)) { return; } this->setMode(aircraft.getTransponderMode()); @@ -65,7 +66,7 @@ namespace BlackGui { return; } - CAircraft ownAircraft = this->getOwnAircraft(); + CSimulatedAircraft ownAircraft(this->getOwnAircraft()); if (ownAircraft.getTransponderMode() == mode) { return; } this->setMode(mode); @@ -128,7 +129,7 @@ namespace BlackGui return getIContextOwnAircraft()->getOwnAircraft().getTransponder(); } - CAircraft CCockpitTransponderModeLedsComponent::getOwnAircraft() const + CSimulatedAircraft CCockpitTransponderModeLedsComponent::getOwnAircraft() const { Q_ASSERT(getIContextOwnAircraft()); return getIContextOwnAircraft()->getOwnAircraft(); diff --git a/src/blackgui/components/cockpittranspondermodeledscomponent.h b/src/blackgui/components/cockpittranspondermodeledscomponent.h index 379048199..7cd111f81 100644 --- a/src/blackgui/components/cockpittranspondermodeledscomponent.h +++ b/src/blackgui/components/cockpittranspondermodeledscomponent.h @@ -16,7 +16,7 @@ #include "enableforruntime.h" #include "../led.h" #include "blackmisc/identifiable.h" -#include "blackmisc/aviation/aircraft.h" +#include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/aviation/transponder.h" #include @@ -43,7 +43,7 @@ namespace BlackGui private slots: //! \copydoc IContextOwnAircraft::changedAircraftCockpit - void ps_onAircraftCockpitChanged(const BlackMisc::Aviation::CAircraft &aircraft, const BlackMisc::CIdentifier &originator); + void ps_onAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator); //! LED clicked void ps_onLedClicked(); @@ -61,7 +61,7 @@ namespace BlackGui BlackMisc::Aviation::CTransponder getOwnTransponder() const; //! Own Aircraft - BlackMisc::Aviation::CAircraft getOwnAircraft() const; + BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const; QScopedPointer m_ledStandby; QScopedPointer m_ledModes; diff --git a/src/blackgui/components/coreinfoareacomponent.ui b/src/blackgui/components/coreinfoareacomponent.ui index d52b9735c..17fa2f125 100644 --- a/src/blackgui/components/coreinfoareacomponent.ui +++ b/src/blackgui/components/coreinfoareacomponent.ui @@ -32,14 +32,14 @@ QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks - + false 0 - 0 + 3 @@ -104,8 +104,8 @@ 0 - - + + 0 @@ -194,18 +194,18 @@ - - BlackGui::Components::CLogComponent - QWidget -
blackgui/components/logcomponent.h
- 1 -
BlackGui::CDockWidgetInfoArea QDockWidget
blackgui/dockwidgetinfoarea.h
1
+ + BlackGui::Components::CLogComponent + QFrame +
blackgui/components/logcomponent.h
+ 1 +
BlackGui::Components::CCoreStatusComponent QFrame diff --git a/src/blackgui/components/flightplancomponent.cpp b/src/blackgui/components/flightplancomponent.cpp index 2292158ed..879915030 100644 --- a/src/blackgui/components/flightplancomponent.cpp +++ b/src/blackgui/components/flightplancomponent.cpp @@ -16,6 +16,7 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackGui; @@ -69,16 +70,16 @@ namespace BlackGui this->prefillWithAircraftData(this->getIContextOwnAircraft()->getOwnAircraft()); } - void CFlightPlanComponent::prefillWithAircraftData(const BlackMisc::Aviation::CAircraft &ownAircraft) + void CFlightPlanComponent::prefillWithAircraftData(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft) { // only override with valid values if (CCallsign::isValidCallsign(ownAircraft.getCallsignAsString())) { this->ui->le_Callsign->setText(ownAircraft.getCallsign().asString()); } - if (CAircraftIcaoCode::isValidDesignator(ownAircraft.getIcaoInfo().getAircraftDesignator())) + if (CAircraftIcaoCode::isValidDesignator(ownAircraft.getAircraftIcaoCodeDesignator())) { - this->ui->le_AircraftType->setText(ownAircraft.getIcaoInfo().getAircraftDesignator()); + this->ui->le_AircraftType->setText(ownAircraft.getAircraftIcaoCodeDesignator()); } if (ownAircraft.hasValidRealName()) { @@ -340,7 +341,7 @@ namespace BlackGui return; } - CAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); + CSimulatedAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); CFlightPlan loadedPlan = this->getIContextNetwork()->loadFlightPlanFromNetwork(ownAircraft.getCallsign()); if (loadedPlan.wasSentOrLoaded()) { @@ -419,9 +420,7 @@ namespace BlackGui CIdentifier CFlightPlanComponent::flightPlanIdentifier() { - if (m_identifier.getName().isEmpty()) - m_identifier = CIdentifier(QStringLiteral("FLIGHTPLANCOMPONENT")); - + if (m_identifier.getName().isEmpty()) { m_identifier = CIdentifier(QStringLiteral("FLIGHTPLANCOMPONENT")); } return m_identifier; } diff --git a/src/blackgui/components/flightplancomponent.h b/src/blackgui/components/flightplancomponent.h index eb2767660..e61f702e2 100644 --- a/src/blackgui/components/flightplancomponent.h +++ b/src/blackgui/components/flightplancomponent.h @@ -15,7 +15,6 @@ #include "blackgui/blackguiexport.h" #include "blackgui/components/enableforruntime.h" #include "blackmisc/identifier.h" -#include "blackmisc/aviation/aircraft.h" #include "blackmisc/aviation/flightplan.h" #include @@ -45,7 +44,7 @@ namespace BlackGui void loginDataSet(); //! Prefill with aircraft data - void prefillWithAircraftData(const BlackMisc::Aviation::CAircraft &ownAircraft); + void prefillWithAircraftData(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft); //! Prefill with aircraft dara void fillWithFlightPlanData(const BlackMisc::Aviation::CFlightPlan &flightPlan); @@ -70,10 +69,10 @@ namespace BlackGui BlackMisc::CIdentifier m_identifier; //! Default value for airport ICAO airports - static const QString &defaultIcao() { static QString d("ICAO"); return d; } + static const QString &defaultIcao() { static const QString d("ICAO"); return d; } //! Default value for time - static const QString &defaultTime() { static QString t("00:00"); return t; } + static const QString &defaultTime() { static const QString t("00:00"); return t; } //! Identifier BlackMisc::CIdentifier flightPlanIdentifier(); diff --git a/src/blackgui/components/infowindowcomponent.cpp b/src/blackgui/components/infowindowcomponent.cpp index 5ad675fb2..380dfa643 100644 --- a/src/blackgui/components/infowindowcomponent.cpp +++ b/src/blackgui/components/infowindowcomponent.cpp @@ -22,10 +22,6 @@ namespace BlackGui { namespace Components { - - /* - * Constructor - */ CInfoWindowComponent::CInfoWindowComponent(QWidget *parent) : QWizardPage(parent), ui(new Ui::InfoWindow) @@ -34,21 +30,15 @@ namespace BlackGui this->hide(); this->m_hideTimer = new QTimer(this); this->m_hideTimer->setSingleShot(true); - this->onStyleSheetsChanged(); + this->ps_onStyleSheetsChanged(); connect(this->m_hideTimer, &QTimer::timeout, this, &CInfoWindowComponent::hide); connect(this->ui->pb_Close, &QPushButton::pressed, this, &CInfoWindowComponent::hide); - connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CInfoWindowComponent::onStyleSheetsChanged); + connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CInfoWindowComponent::ps_onStyleSheetsChanged); } - /* - * Destructor - */ CInfoWindowComponent::~CInfoWindowComponent() { } - /* - * Info message for some time - */ void CInfoWindowComponent::displayStringMessage(const QString &message, int displayTimeMs) { if (message.isEmpty()) @@ -63,9 +53,6 @@ namespace BlackGui this->showWindow(displayTimeMs); } - /* - * Info message for some time - */ void CInfoWindowComponent::displayTextMessage(const CTextMessage &textMessage, int displayTimeMs) { if (textMessage.isEmpty()) @@ -84,9 +71,6 @@ namespace BlackGui this->showWindow(displayTimeMs); } - /* - * Display status message - */ void CInfoWindowComponent::displayStatusMessage(const CStatusMessage &statusMessage, int displayTimeMs) { if (statusMessage.isEmpty()) @@ -104,9 +88,6 @@ namespace BlackGui this->showWindow(displayTimeMs); } - /* - * Display - */ void CInfoWindowComponent::display(const BlackMisc::CVariant &variant, int displayTimeMs) { if (variant.isNull()) @@ -128,9 +109,6 @@ namespace BlackGui } } - /* - * Init this window - */ void CInfoWindowComponent::initWindow() { // center @@ -143,9 +121,6 @@ namespace BlackGui this->show(); } - /* - * Show window - */ void CInfoWindowComponent::showWindow(int displayTimeMs) { this->initWindow(); @@ -154,18 +129,12 @@ namespace BlackGui this->m_hideTimer->start(displayTimeMs); } - /* - * Set current widget - */ void CInfoWindowComponent::setCurrentPage(QWidget *widget) { this->ui->sw_DifferentModes->setCurrentWidget(widget); } - /* - * Style sheet changed - */ - void CInfoWindowComponent::onStyleSheetsChanged() + void CInfoWindowComponent::ps_onStyleSheetsChanged() { QString st = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameInfoWindow()); this->setStyleSheet(st); diff --git a/src/blackgui/components/infowindowcomponent.h b/src/blackgui/components/infowindowcomponent.h index 6763cfd29..53b52709b 100644 --- a/src/blackgui/components/infowindowcomponent.h +++ b/src/blackgui/components/infowindowcomponent.h @@ -26,7 +26,6 @@ namespace BlackGui { namespace Components { - /*! * Multi purpose info window (like pop up window) */ @@ -44,7 +43,6 @@ namespace BlackGui ~CInfoWindowComponent(); public slots: - //! Info message, pure string void displayStringMessage(const QString &message, int displayTimeMs = DefaultDisplayTimeMs); @@ -72,7 +70,7 @@ namespace BlackGui private slots: //! Style sheet changed - void onStyleSheetsChanged(); + void ps_onStyleSheetsChanged(); }; } // namespace } // namespace diff --git a/src/blackgui/components/internalscomponent.cpp b/src/blackgui/components/internalscomponent.cpp index d42b32978..0da769a23 100644 --- a/src/blackgui/components/internalscomponent.cpp +++ b/src/blackgui/components/internalscomponent.cpp @@ -10,6 +10,7 @@ #include "internalscomponent.h" #include "ui_internalscomponent.h" #include "blackcore/context_all_interfaces.h" +#include using namespace BlackMisc; using namespace BlackMisc::Aviation; diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index 844c3436f..936a6d246 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -16,9 +16,8 @@ #include "blackcore/context_simulator.h" #include "blackcore/network.h" #include "blackcore/simulator.h" -#include "blackcore/global_network_settings.h" +#include "blackcore/settings/global_network_settings.h" #include "blackmisc/logmessage.h" -#include "blackmisc/aviation/aircrafticaodata.h" #include "../uppercasevalidator.h" #include @@ -27,6 +26,7 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; using namespace BlackCore; +using namespace BlackCore::Settings; using namespace BlackGui; namespace BlackGui @@ -183,18 +183,35 @@ namespace BlackGui return; } + // sync values with GUI values CGuiAircraftValues aircraftValues = this->getAircraftValuesFromGui(); - CAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); - CAircraftIcaoData icao = ownAircraft.getIcaoInfo(); - icao.setAircraftDesignator(aircraftValues.ownAircraftIcaoTypeDesignator); - icao.setAirlineDesignator(aircraftValues.ownAircraftIcaoAirline); - icao.setAircraftCombinedType(aircraftValues.ownAircraftCombinedType); - ownAircraft.setIcaoInfo(icao); - ownAircraft.setCallsign(aircraftValues.ownCallsign); + CSimulatedAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); + CAircraftIcaoCode aircraftCode(ownAircraft.getAircraftIcaoCode()); + CAirlineIcaoCode airlineCode(ownAircraft.getAirlineIcaoCode()); - // set latest ICAO, callsign - this->getIContextOwnAircraft()->updateOwnIcaoData(ownAircraft.getIcaoInfo()); - this->getIContextOwnAircraft()->updateOwnCallsign(ownAircraft.getCallsign()); + bool setIcaoCodes = false; + if (!ownAircraft.hasAircraftDesignator() && !aircraftValues.ownAircraftIcaoTypeDesignator.isEmpty()) + { + aircraftCode = CAircraftIcaoCode(aircraftValues.ownAircraftIcaoTypeDesignator, aircraftValues.ownAircraftCombinedType); + setIcaoCodes = true; + } + if (!ownAircraft.hasAircraftDesignator() && !aircraftValues.ownAircraftIcaoAirline.isEmpty()) + { + airlineCode = CAirlineIcaoCode(aircraftValues.ownAircraftIcaoAirline); + setIcaoCodes = true; + } + + if (ownAircraft.getCallsign().asString() != aircraftValues.ownCallsign) + { + ownAircraft.setCallsign(aircraftValues.ownCallsign); + this->getIContextOwnAircraft()->updateOwnCallsign(ownAircraft.getCallsign()); + } + + if (setIcaoCodes) + { + ownAircraft.setIcaoCodes(aircraftCode, airlineCode); + this->getIContextOwnAircraft()->updateOwnIcaoCodes(ownAircraft.getAircraftIcaoCode(), ownAircraft.getAirlineIcaoCode()); + } // Login mode INetwork::LoginMode mode = ui->gbp_LoginMode->getLoginMode(); @@ -258,13 +275,13 @@ namespace BlackGui this->ui->cbp_VatsimServer->setServers(vatsimFsdServers); } - void CLoginComponent::setGuiValuesFromAircraft(const CAircraft &ownAircraft) + void CLoginComponent::setGuiValuesFromAircraft(const CSimulatedAircraft &ownAircraft) { - CAircraftIcaoData icao = ownAircraft.getIcaoInfo(); + CAircraftIcaoCode aircraftIcao = ownAircraft.getAircraftIcaoCode(); this->ui->le_Callsign->setText(ownAircraft.getCallsignAsString()); - this->ui->le_AircraftIcaoDesignator->setText(icao.getAircraftDesignator()); - this->ui->le_AircraftIcaoAirline->setText(icao.getAirlineDesignator()); - this->ui->le_AircraftCombinedType->setText(icao.getAircraftCombinedType()); + this->ui->le_AircraftIcaoDesignator->setText(aircraftIcao.getDesignator()); + this->ui->le_AircraftIcaoAirline->setText(ownAircraft.getAirlineIcaoCodeDesignator()); + this->ui->le_AircraftCombinedType->setText(aircraftIcao.getCombinedType()); } void CLoginComponent::loadFromSettings() @@ -288,15 +305,6 @@ namespace BlackGui return values; } - void CLoginComponent::mergeGuiIcaoValues(CAircraftIcaoData &icao) const - { - CGuiAircraftValues values = getAircraftValuesFromGui(); - CAircraftIcaoData guiIcao( - CAircraftIcaoCode(values.ownAircraftIcaoTypeDesignator, values.ownAircraftCombinedType), - CAirlineIcaoCode(values.ownAircraftIcaoAirline)); - icao.updateMissingParts(guiIcao); - } - CLoginComponent::CVatsimValues CLoginComponent::getVatsimValuesFromGui() const { CVatsimValues values; @@ -356,55 +364,46 @@ namespace BlackGui Q_ASSERT(this->getIContextOwnAircraft()); Q_ASSERT(this->getIContextSimulator()); - static const CAircraftIcaoData defaultIcao( - CAircraftIcaoCode("C172", "L1P"), - CAirlineIcaoCode() - ); // default values - - CAircraftIcaoData icao; + static const CAircraftModel defaultModel( + "", CAircraftModel::TypeOwnSimulatorModel, "default model", + CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0)); + CAircraftModel model; bool simulating = this->getIContextSimulator() && (this->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating); if (simulating) { - CAircraftModel model = this->getIContextOwnAircraft()->getOwnAircraft().getModel(); + model = this->getIContextOwnAircraft()->getOwnAircraft().getModel(); this->ui->le_SimulatorModel->setText(model.getModelString()); - - icao = model.getIcao(); - if (!icao.hasAircraftDesignator()) - { - // not valid, reverse lookup - this->getIContextSimulator()->getIcaoForModelString(model.getModelString()); - } } else { // Set observer mode without simulator //! \todo Currently not working in OBS mode + model = CAircraftModel(defaultModel); this->ui->gbp_LoginMode->setLoginMode(INetwork::LoginNormal); this->ui->le_SimulatorModel->setText("No simulator"); - icao = defaultIcao; } - if (icao.hasAircraftDesignator()) + if (model.hasAircraftDesignator()) { - this->setGuiIcaoValues(icao, false); + this->setGuiIcaoValues(model, false); } } - void CLoginComponent::setGuiIcaoValues(const CAircraftIcaoData &icao, bool onlyIfEmpty) + void CLoginComponent::setGuiIcaoValues(const CAircraftModel &model, bool onlyIfEmpty) { if (!onlyIfEmpty || this->ui->le_AircraftIcaoDesignator->text().trimmed().isEmpty()) { - this->ui->le_AircraftIcaoDesignator->setText(icao.getAircraftDesignator()); + this->ui->le_AircraftIcaoDesignator->setText(model.getAircraftIcaoCode().getDesignator()); } if (!onlyIfEmpty || this->ui->le_AircraftIcaoAirline->text().trimmed().isEmpty()) { - this->ui->le_AircraftIcaoAirline->setText(icao.getAirlineDesignator()); + this->ui->le_AircraftIcaoAirline->setText(model.getAirlineIcaoCode().getDesignator()); } if (!onlyIfEmpty || this->ui->le_AircraftCombinedType->text().trimmed().isEmpty()) { - this->ui->le_AircraftCombinedType->setText(icao.getAircraftCombinedType()); + this->ui->le_AircraftCombinedType->setText(model.getAircraftIcaoCode().getCombinedType()); } this->ps_validateAircraftValues(); } @@ -477,17 +476,12 @@ namespace BlackGui Q_ASSERT(getIContextSimulator()); CAircraftModel model(this->getIContextOwnAircraft()->getOwnAircraft().getModel()); - CAircraftIcaoData icao = this->getIContextSimulator()->getIcaoForModelString(model.getModelString()); - if (icao.hasAircraftDesignator()) + if (model.getAircraftIcaoCode().hasDesignator()) { CLogMessage(this).validationInfo("Reverse lookup for %1") << model.getModelString(); - // set value in backend - this->mergeGuiIcaoValues(icao); - this->getIContextOwnAircraft()->updateOwnIcaoData(icao); - // update GUI - this->setGuiIcaoValues(icao, false); + this->setGuiIcaoValues(model, false); } else { diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index 22d3ef01e..98eb4ffe4 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -15,7 +15,6 @@ #include "blackgui/blackguiexport.h" #include "enableforruntime.h" #include "blackcore/settings/network.h" -#include "blackmisc/aviation/aircraft.h" #include "blackmisc/network/server.h" #include #include @@ -106,7 +105,7 @@ namespace BlackGui }; //! GUI values from aircraft - void setGuiValuesFromAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft); + void setGuiValuesFromAircraft(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft); //! Load from settings void loadFromSettings(); @@ -142,16 +141,12 @@ namespace BlackGui void setOwnModel(); //! Set ICAO values - void setGuiIcaoValues(const BlackMisc::Aviation::CAircraftIcaoData &icao, bool onlyIfEmpty); - - //! Merge with GUI icao values - void mergeGuiIcaoValues(BlackMisc::Aviation::CAircraftIcaoData &icao) const; + void setGuiIcaoValues(const BlackMisc::Simulation::CAircraftModel &model, bool onlyIfEmpty); bool m_visible = false; //!< is this component selected? QScopedPointer ui; const int LogoffIntervalSeconds = 10; - QTimer *m_logoffCountdownTimer = nullptr; - + QTimer *m_logoffCountdownTimer { nullptr }; BlackCore::CSetting m_trafficNetworkServers { this }; }; diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index 379bf282c..ee3405164 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -127,7 +127,7 @@ namespace BlackGui case InfoAreaAtc: return CIcons::appAtc16(); case InfoAreaAircraft: - return CIcons::appAircrafts16(); + return CIcons::appAircraft16(); case InfoAreaSettings: return CIcons::appSettings16(); case InfoAreaFlightPlan: diff --git a/src/blackgui/components/maininfoareacomponent.ui b/src/blackgui/components/maininfoareacomponent.ui index caae9ddac..ceef1d75a 100644 --- a/src/blackgui/components/maininfoareacomponent.ui +++ b/src/blackgui/components/maininfoareacomponent.ui @@ -6,8 +6,8 @@ 0 0 - 1533 - 242 + 1530 + 71
@@ -32,7 +32,7 @@ QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks - + false diff --git a/src/blackgui/components/mainkeypadareacomponent.cpp b/src/blackgui/components/mainkeypadareacomponent.cpp index 393a9fdfc..8d68f52f0 100644 --- a/src/blackgui/components/mainkeypadareacomponent.cpp +++ b/src/blackgui/components/mainkeypadareacomponent.cpp @@ -15,6 +15,7 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; using namespace BlackCore; namespace BlackGui @@ -160,7 +161,7 @@ namespace BlackGui this->ui->le_CommandLineInput->clear(); } - void CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged(const CAircraft &aircraft, const CIdentifier &originator) + void CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged(const CSimulatedAircraft &aircraft, const CIdentifier &originator) { Q_UNUSED(originator); bool ident = aircraft.getTransponder().getTransponderMode() == CTransponder::StateIdent; diff --git a/src/blackgui/components/mainkeypadareacomponent.h b/src/blackgui/components/mainkeypadareacomponent.h index 9787edc05..a9556b726 100644 --- a/src/blackgui/components/mainkeypadareacomponent.h +++ b/src/blackgui/components/mainkeypadareacomponent.h @@ -16,7 +16,6 @@ #include "maininfoareacomponent.h" #include "enableforruntime.h" #include "blackmisc/identifier.h" -#include "blackmisc/aviation/aircraft.h" #include #include @@ -83,7 +82,7 @@ namespace BlackGui void ps_commandEntered(); //! \copydoc BlackCore::IContextOwnAircraft::changedAircraftCockpit - void ps_ownAircraftCockpitChanged(const BlackMisc::Aviation::CAircraft &aircraft, const BlackMisc::CIdentifier &originator); + void ps_ownAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator); //! \copydoc BlackCore::IContextAudio::changedMute void ps_muteChanged(bool muted); diff --git a/src/blackgui/components/remoteaircraftselector.cpp b/src/blackgui/components/remoteaircraftselector.cpp index 9e0cd10ea..77a308c19 100644 --- a/src/blackgui/components/remoteaircraftselector.cpp +++ b/src/blackgui/components/remoteaircraftselector.cpp @@ -87,10 +87,10 @@ namespace BlackGui { if (aircraft.getCallsign().isEmpty()) { continue; } QString i(aircraft.getCallsign().toQString()); - if (aircraft.hasValidAircraftDesignator()) + if (aircraft.hasAircraftDesignator()) { i += " ("; - i += aircraft.getIcaoInfo().toQString(false); + i += aircraft.getAircraftIcaoCode().toQString(false); i += ")"; } if (aircraft.hasValidRealName()) diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index 1d115716a..4b12bd4f0 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -15,7 +15,6 @@ #include "blackgui/blackguiexport.h" #include "blackgui/components/enableforruntime.h" #include "blackmisc/network/server.h" -#include "blackmisc/aviation/aircrafticaodata.h" #include #include #include diff --git a/src/blackgui/components/settingsfsxcomponent.cpp b/src/blackgui/components/settingsfsxcomponent.cpp index b7ddb4601..d7e4da74d 100644 --- a/src/blackgui/components/settingsfsxcomponent.cpp +++ b/src/blackgui/components/settingsfsxcomponent.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include using namespace BlackMisc; diff --git a/src/blackgui/components/settingsnetworkserverscomponent.cpp b/src/blackgui/components/settingsnetworkserverscomponent.cpp index cb3f180e2..7b084fe64 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.cpp +++ b/src/blackgui/components/settingsnetworkserverscomponent.cpp @@ -11,12 +11,14 @@ #include "ui_settingsnetworkserverscomponent.h" #include "blackcore/context_network.h" #include "blackcore/context_settings.h" -#include "blackcore/global_network_settings.h" +#include "blackcore/settings/global_network_settings.h" #include "blackmisc/logmessage.h" #include "blackmisc/project.h" #include "blackmisc/settingsblackmiscclasses.h" +#include using namespace BlackCore; +using namespace BlackCore::Settings; using namespace BlackMisc; using namespace BlackGui; using namespace BlackMisc::Network; @@ -57,7 +59,7 @@ namespace BlackGui this->ui->tvp_SettingsTnServers->updateContainer(serverList); } - void CSettingsNetworkServersComponent::ps_networkServerSelected(QModelIndex index) + void CSettingsNetworkServersComponent::ps_networkServerSelected(const QModelIndex &index) { const CServer clickedServer = this->ui->tvp_SettingsTnServers->at(index); this->ui->frp_ServerForm->setServer(clickedServer); diff --git a/src/blackgui/components/settingsnetworkserverscomponent.h b/src/blackgui/components/settingsnetworkserverscomponent.h index 98078fcf1..97ac086d5 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.h +++ b/src/blackgui/components/settingsnetworkserverscomponent.h @@ -44,7 +44,7 @@ namespace BlackGui private slots: //! Network server selected - void ps_networkServerSelected(QModelIndex index); + void ps_networkServerSelected(const QModelIndex &index); //! Alter traffic server void ps_alterTrafficServer(); diff --git a/src/blackgui/components/simulatorcomponent.cpp b/src/blackgui/components/simulatorcomponent.cpp index ed304fce3..222166cc0 100644 --- a/src/blackgui/components/simulatorcomponent.cpp +++ b/src/blackgui/components/simulatorcomponent.cpp @@ -14,10 +14,10 @@ #include "blackcore/context_ownaircraft.h" #include "blackcore/simulator.h" #include "blackmisc/iconlist.h" -#include "blackmisc/aviation/aircraft.h" using namespace BlackMisc; using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; using namespace BlackCore; namespace BlackGui @@ -90,7 +90,7 @@ namespace BlackGui this->clear(); } - CAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); + CSimulatedAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft(); CAircraftSituation s = ownAircraft.getSituation(); CComSystem c1 = ownAircraft.getCom1System(); CComSystem c2 = ownAircraft.getCom2System(); diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index dc25daec5..6ddf3e035 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -192,7 +192,7 @@ namespace BlackGui else { // frequency message - const CAircraft ownAircraft = this->getOwnAircraft(); + const CSimulatedAircraft ownAircraft = this->getOwnAircraft(); if (this->ui->tw_TextMessages->currentWidget() == this->ui->tb_TextMessagesAll) { return true; } if (textMessage.isSendToFrequency(ownAircraft.getCom1System().getFrequencyActive())) { @@ -213,7 +213,7 @@ namespace BlackGui void CTextMessageComponent::showCurrentFrequenciesFromCockpit() { - const CAircraft ownAircraft = this->getOwnAircraft(); + const CSimulatedAircraft ownAircraft = this->getOwnAircraft(); QString f1n, f2n; f1n.sprintf("%03.3f", ownAircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); f2n.sprintf("%03.3f", ownAircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3)); @@ -276,7 +276,7 @@ namespace BlackGui } } - const CAircraft CTextMessageComponent::getOwnAircraft() const + const CSimulatedAircraft CTextMessageComponent::getOwnAircraft() const { Q_ASSERT(this->getIContextOwnAircraft()); return this->getIContextOwnAircraft()->getOwnAircraft(); diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index d370f4f73..d09d4bfea 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -18,7 +18,6 @@ #include "blackgui/textmessagetextedit.h" #include "blackmisc/identifier.h" #include "blackmisc/network/textmessage.h" -#include "blackmisc/aviation/aircraft.h" #include "blackmisc/network/textmessagelist.h" #include "blackcore/context_network.h" #include "blackcore/context_ownaircraft.h" @@ -107,7 +106,7 @@ namespace BlackGui void addPrivateChannelTextMessage(const BlackMisc::Network::CTextMessage &textMessage); //! own aircraft - const BlackMisc::Aviation::CAircraft getOwnAircraft() const; + const BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const; //! For this text message's recepient, is the current tab selected? bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const; diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 0591773ff..fee7cd225 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -18,8 +18,6 @@ #include #include #include -#include -#include #include using namespace BlackMisc; @@ -240,7 +238,7 @@ namespace BlackGui void CInfoArea::paintEvent(QPaintEvent *event) { CStyleSheetUtility::useStyleSheetInDerivedWidget(this, QStyle::PE_FrameWindow); - QMainWindow::paintEvent(event); + Q_UNUSED(event); } void CInfoArea::keyPressEvent(QKeyEvent *event) @@ -793,7 +791,7 @@ namespace BlackGui void CInfoArea::ps_setTabBarPosition(QTabWidget::TabPosition position) { - Q_ASSERT(position == QTabWidget::North || position == QTabWidget::South); + Q_ASSERT_X(position == QTabWidget::North || position == QTabWidget::South, Q_FUNC_INFO, "Wrong tabbar position"); this->setTabPosition(Qt::TopDockWidgetArea, position); } diff --git a/src/blackgui/managedstatusbar.cpp b/src/blackgui/managedstatusbar.cpp index 41511cc1b..3a9acb6e3 100644 --- a/src/blackgui/managedstatusbar.cpp +++ b/src/blackgui/managedstatusbar.cpp @@ -89,6 +89,9 @@ namespace BlackGui void CManagedStatusBar::displayStatusMessage(const CStatusMessage &statusMessage) { + Q_ASSERT_X(this->m_statusBarIcon, Q_FUNC_INFO, "Missing status bar icon"); + Q_ASSERT_X(this->m_statusBar, Q_FUNC_INFO, "Missing status bar"); + if (statusMessage.isRedundant()) { return; } if (statusMessage.wasHandledBy(this)) { return; } statusMessage.markAsHandledBy(this);