From 6c06ff5d467c112328c367b710e7e2647236befb Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 28 May 2015 00:32:17 +0200 Subject: [PATCH] refs #432, adjusted originators --- samples/cli_client/client.cpp | 8 +++--- samples/cli_client/client.h | 6 ++++- src/blackcore/context_ownaircraft_impl.cpp | 7 ++--- src/blackcore/context_ownaircraft_impl.h | 4 ++- src/blackcore/simulator.cpp | 8 ------ src/blackcore/simulator.h | 22 +++++++++------- src/blackgui/commandinput.cpp | 26 ++++++------------- src/blackgui/commandinput.h | 23 +++++----------- .../components/atcstationcomponent.cpp | 9 +------ src/blackgui/components/atcstationcomponent.h | 9 +++---- .../components/cockpitcomcomponent.cpp | 17 +++++------- src/blackgui/components/cockpitcomcomponent.h | 9 +++---- .../cockpittranspondermodeledscomponent.cpp | 13 +++------- .../cockpittranspondermodeledscomponent.h | 13 ++++------ src/plugins/simulator/fs9/simulator_fs9.cpp | 24 ++++++++--------- .../simulator/fscommon/simulator_fscommon.cpp | 4 +-- src/plugins/simulator/fsx/simulator_fsx.cpp | 14 +++++----- .../simulator/xplane/simulator_xplane.cpp | 12 ++++----- src/swiftcore/swiftcore.cpp | 1 + src/swiftcore/swiftcore.h | 5 +++- 20 files changed, 96 insertions(+), 138 deletions(-) diff --git a/samples/cli_client/client.cpp b/samples/cli_client/client.cpp index a9ad2c22f..6934758aa 100644 --- a/samples/cli_client/client.cpp +++ b/samples/cli_client/client.cpp @@ -21,10 +21,11 @@ using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; Client::Client(QObject *parent) - : QObject(parent), COwnAircraftAware(COwnAircraftProviderDummy::instance()), + : QObject(parent), + COwnAircraftAware(COwnAircraftProviderDummy::instance()), + COriginatorAware("samples:cmdClient"), m_net(new BlackCore::CNetworkVatlib(COwnAircraftProviderDummy::instance(), this)) { - connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate); connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected); connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged); @@ -339,7 +340,8 @@ void Client::setOwnAircraftCmd(QTextStream &args) BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())), BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())), BlackMisc::Aviation::CTransponder(xpdrCode, xpdrMode), - COriginator("cmdClient")); + originator()); + Q_UNUSED(aircraft); } void Client::setOwnAircraftPositionCmd(QTextStream &args) diff --git a/samples/cli_client/client.h b/samples/cli_client/client.h index 0c0dbfaa7..b94974a5f 100644 --- a/samples/cli_client/client.h +++ b/samples/cli_client/client.h @@ -14,6 +14,7 @@ #include "blackcore/network.h" #include "blackmisc/simulation/ownaircraftproviderdummy.h" +#include "blackmisc/originatoraware.h" #include #include #include @@ -21,7 +22,8 @@ class Client : public QObject, - public BlackMisc::Simulation::COwnAircraftAware + public BlackMisc::Simulation::COwnAircraftAware, + public BlackMisc::COriginatorAware { Q_OBJECT @@ -29,9 +31,11 @@ public: Client(QObject *parent = nullptr); signals: + //! Terminated void quit(); public slots: + //! Handle command void command(QString line); private: //commands diff --git a/src/blackcore/context_ownaircraft_impl.cpp b/src/blackcore/context_ownaircraft_impl.cpp index a189c4f34..efe8ac9b0 100644 --- a/src/blackcore/context_ownaircraft_impl.cpp +++ b/src/blackcore/context_ownaircraft_impl.cpp @@ -28,10 +28,12 @@ using namespace BlackMisc::Simulation; namespace BlackCore { CContextOwnAircraft::CContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : - IContextOwnAircraft(mode, runtime) + IContextOwnAircraft(mode, runtime), + COriginatorAware(this) { Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getRuntime()->getIContextSettings()); + this->setObjectName("CContextOwnAircraft"); // Init own aircraft this->initOwnAircraft(); @@ -360,8 +362,7 @@ namespace BlackCore { if (CSelcal::isValidCode(parser.part(1))) { - // todo RW: replace originator - this->updateSelcal(parser.part(1), COriginator("commandline")); + this->updateSelcal(parser.part(1), this->originator()); return true; } } diff --git a/src/blackcore/context_ownaircraft_impl.h b/src/blackcore/context_ownaircraft_impl.h index 31fc01450..33b057314 100644 --- a/src/blackcore/context_ownaircraft_impl.h +++ b/src/blackcore/context_ownaircraft_impl.h @@ -19,6 +19,7 @@ #include "blackcore/dbus_server.h" #include "blackmisc/aviation/atcstation.h" #include "blackmisc/simulation/ownaircraftprovider.h" +#include "blackmisc/originatoraware.h" namespace BlackCore { @@ -27,7 +28,8 @@ namespace BlackCore //! Central instance of data for \sa IOwnAircraftProvider . class BLACKCORE_EXPORT CContextOwnAircraft : public IContextOwnAircraft, - public BlackMisc::Simulation::IOwnAircraftProvider + public BlackMisc::Simulation::IOwnAircraftProvider, + public BlackMisc::COriginatorAware { Q_OBJECT Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME) diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 9e8d4ba85..188ec502a 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -29,14 +29,6 @@ namespace BlackCore return status; } - COriginator ISimulator::simulatorOriginator() - { - if (m_originator.getName().isEmpty()) - m_originator = COriginator(QStringLiteral("SIMULATOR")); - - return m_originator; - } - QString ISimulator::statusToString(int status) { if (status > 0) diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 0ae1f0513..6f3f70780 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -26,19 +26,22 @@ #include "blackmisc/network/textmessage.h" #include "blackmisc/network/client.h" #include "blackmisc/pixmap.h" +#include "blackmisc/originatoraware.h" #include namespace BlackCore { //! Interface to a simulator. - class BLACKCORE_EXPORT ISimulator : public QObject + class BLACKCORE_EXPORT ISimulator : + public QObject, + public BlackMisc::COriginatorAware { Q_OBJECT public: //! ISimulator status - enum SimulatorStatus + enum SimulatorStatusFlag { Disconnected = 0, Connected = 1 << 0, //!< Is the plugin connected to the simulator? @@ -46,6 +49,8 @@ namespace BlackCore Paused = 1 << 2, //!< Is the simulator paused? }; + Q_DECLARE_FLAGS(SimulatorStatus, SimulatorStatusFlag) + //! Render all aircraft if number of aircraft >= MaxAircraftInfinite const int MaxAircraftInfinite = 100; @@ -169,9 +174,6 @@ namespace BlackCore //! Driver will be unloaded virtual void unload() = 0; - //! Originator - BlackMisc::COriginator simulatorOriginator(); - //! Status to string static QString statusToString(int status); @@ -196,7 +198,10 @@ namespace BlackCore protected: //! Default constructor - ISimulator(QObject *parent = nullptr) : QObject(parent) {} + ISimulator(QObject *parent = nullptr) : + QObject(parent), + BlackMisc::COriginatorAware(this) + {} //! Are we connected to the simulator? virtual bool isConnected() const = 0; @@ -223,10 +228,6 @@ namespace BlackCore //! Emit the combined status //! \sa simulatorStatusChanged; void emitSimulatorCombinedStatus(); - - private: - - BlackMisc::COriginator m_originator; }; //! Interface to a simulator listener. @@ -287,5 +288,6 @@ namespace BlackCore } // namespace Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift-project.blackcore.simulatorinterface") +Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::ISimulator::SimulatorStatus) #endif // guard diff --git a/src/blackgui/commandinput.cpp b/src/blackgui/commandinput.cpp index e9425b8a5..685c5f865 100644 --- a/src/blackgui/commandinput.cpp +++ b/src/blackgui/commandinput.cpp @@ -16,29 +16,19 @@ namespace BlackGui { CCommandInput::CCommandInput(QWidget *parent) : - QLineEdit(parent) + QLineEdit(parent), + COriginatorAware(this) { - connect(this, &CCommandInput::returnPressed, this, &CCommandInput::validateCommand); + connect(this, &CCommandInput::returnPressed, this, &CCommandInput::ps_validateCommand); } - void CCommandInput::validateCommand() + void CCommandInput::ps_validateCommand() { - QString commandLine = text(); - setText(QString()); - + QString commandLine(this->text().trimmed()); + this->setText(QString()); if (commandLine.startsWith('.')) { - emit commandEntered(commandLine, commandInputOriginator()); + emit commandEntered(commandLine, originator()); } } - - COriginator CCommandInput::commandInputOriginator() - { - if (m_originator.getName().isEmpty()) - m_originator = COriginator(QStringLiteral("COMMANDINPUT")); - - return m_originator; - } - -} - +} // ns diff --git a/src/blackgui/commandinput.h b/src/blackgui/commandinput.h index 2cfd9dde2..bddfc3b08 100644 --- a/src/blackgui/commandinput.h +++ b/src/blackgui/commandinput.h @@ -13,44 +13,33 @@ #define BLACKGUI_COMMANDINPUT_H #include "blackguiexport.h" -#include "blackmisc/originator.h" +#include "blackmisc/originatoraware.h" #include #include namespace BlackGui { - //! Specialized LineEdit for command inputs - class BLACKGUI_EXPORT CCommandInput : public QLineEdit + class BLACKGUI_EXPORT CCommandInput : + public QLineEdit, + public BlackMisc::COriginatorAware { Q_OBJECT public: - //! Constructor CCommandInput(QWidget *parent = nullptr); //! Destructor ~CCommandInput() {} - //! Originator - BlackMisc::COriginator commandInputOriginator(); - signals: - //! Command was entered void commandEntered(const QString &command, const BlackMisc::COriginator &originator); private slots: - //! Basic command validation - void validateCommand(); - - private: - - BlackMisc::COriginator m_originator; + void ps_validateCommand(); }; - } - -#endif // CCOMMANDINPUT_H +#endif // guard diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index 29b4752a6..e811f51b2 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -29,6 +29,7 @@ namespace BlackGui { CAtcStationComponent::CAtcStationComponent(QWidget *parent) : QTabWidget(parent), + COriginatorAware(this), ui(new Ui::CAtcStationComponent), m_updateTimer(new CUpdateTimer("CAtcStationComponent", &CAtcStationComponent::update, this)) { @@ -275,14 +276,6 @@ namespace BlackGui } } - COriginator CAtcStationComponent::originator() - { - if (m_originator.getName().isEmpty()) - m_originator = COriginator(QStringLiteral("ATCSTATIOCOMPONENT")); - - return m_originator; - } - void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index) { this->ui->te_AtcStationsOnlineInfo->setText(""); // reset diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 5edd86a7a..f80143acb 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -16,7 +16,7 @@ #include "blackgui/components/enableforruntime.h" #include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/components/updatetimer.h" -#include "blackmisc/originator.h" +#include "blackmisc/originatoraware.h" #include "blackmisc/aviation/atcstation.h" #include #include @@ -32,7 +32,8 @@ namespace BlackGui class BLACKGUI_EXPORT CAtcStationComponent : public QTabWidget, public CEnableForDockWidgetInfoArea, - public CEnableForRuntime + public CEnableForRuntime, + public BlackMisc::COriginatorAware { Q_OBJECT @@ -112,16 +113,12 @@ namespace BlackGui private: void updateTreeView(); - BlackMisc::COriginator originator(); - QScopedPointer ui; QScopedPointer m_updateTimer; QDateTime m_timestampLastReadOnlineStations = CUpdateTimer::epoch(); //!< stations read QDateTime m_timestampOnlineStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed QDateTime m_timestampLastReadBookedStations = CUpdateTimer::epoch(); //!< stations read QDateTime m_timestampBookedStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed - BlackMisc::COriginator m_originator; - }; } // namespace } // namespace diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp index 5f368fd82..23e9e9bf1 100644 --- a/src/blackgui/components/cockpitcomcomponent.cpp +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -33,6 +33,7 @@ namespace BlackGui { CCockpitComComponent::CCockpitComComponent(QWidget *parent) : QFrame(parent), + BlackMisc::COriginatorAware(this), ui(new Ui::CCockpitMainComponent) { ui->setupUi(this); @@ -62,7 +63,7 @@ namespace BlackGui // init from aircraft CAircraft ownAircraft = this->getOwnAircraft(); - this->ps_updateCockpitFromContext(ownAircraft, COriginator("dummyInitialValues")); + this->ps_updateCockpitFromContext(ownAircraft, COriginator("dummyInitialValues")); // intentionally different name here // SELCAL pairs in cockpit this->ui->frp_ComPanelSelcalBottom->clear(); @@ -111,12 +112,12 @@ namespace BlackGui void CCockpitComComponent::ps_guiChangedSelcal() { - this->getIContextOwnAircraft()->updateSelcal(this->getSelcal(), cockpitOriginator()); + this->getIContextOwnAircraft()->updateSelcal(this->getSelcal(), originator()); } void CCockpitComComponent::ps_updateCockpitFromContext(const CAircraft &ownAircraft, const COriginator &originator) { - if (originator == CCockpitComComponent::cockpitOriginator()) return; // comes from myself + if (isMyOriginator(originator)) { return; } // comes from myself // update GUI elements // avoid unnecessary change events as far as possible @@ -184,7 +185,7 @@ namespace BlackGui void CCockpitComComponent::ps_onChangedSelcal(const CSelcal &selcal, const COriginator &originator) { - if (originator == CCockpitComComponent::cockpitOriginator()) return; // comes from myself + if (isMyOriginator(originator)) { return; } // comes from myself this->ui->frp_ComPanelSelcalBottom->setSelcalCode(selcal); } @@ -246,7 +247,7 @@ namespace BlackGui bool CCockpitComComponent::updateOwnCockpitInContext(const CAircraft &ownAircraft) { - return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator()); + return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), originator()); } void CCockpitComComponent::updateFrequencyDisplaysFromComSystems(const CComSystem &com1, const CComSystem &com2) @@ -286,13 +287,7 @@ namespace BlackGui Q_UNUSED(connected); } - COriginator CCockpitComComponent::cockpitOriginator() - { - if (m_originator.getName().isEmpty()) - m_originator = COriginator(QStringLiteral("COCKPITCOMCOMPONENT")); - return m_originator; - } } // namespace } // namespace diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h index 99a2c3ee2..4839f7d26 100644 --- a/src/blackgui/components/cockpitcomcomponent.h +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -13,7 +13,7 @@ #include "blackgui/blackguiexport.h" #include "enablefordockwidgetinfoarea.h" #include "enableforruntime.h" -#include "blackmisc/originator.h" +#include "blackmisc/originatoraware.h" #include "blackmisc/aviation/aircraft.h" #include "blackmisc/aviation/transponder.h" #include "blackmisc/audio/voiceroomlist.h" @@ -29,6 +29,7 @@ namespace BlackGui //! The main cockpit area class BLACKGUI_EXPORT CCockpitComComponent : public QFrame, + public BlackMisc::COriginatorAware, public CEnableForDockWidgetInfoArea, public CEnableForRuntime { @@ -97,12 +98,8 @@ namespace BlackGui //! COM frequencies displayed void updateFrequencyDisplaysFromComSystems(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); - //! Identifies sender of cockpit updates - BlackMisc::COriginator cockpitOriginator(); - QScopedPointer ui; - BlackMisc::COriginator m_originator; - }; + }; } // namespace } // namespace diff --git a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp index 257896537..5abaaea22 100644 --- a/src/blackgui/components/cockpittranspondermodeledscomponent.cpp +++ b/src/blackgui/components/cockpittranspondermodeledscomponent.cpp @@ -22,6 +22,7 @@ namespace BlackGui { CCockpitTransponderModeLedsComponent::CCockpitTransponderModeLedsComponent(QWidget *parent) : QFrame(parent), + COriginatorAware(this), m_ledStandby(new CLedWidget(false, CLedWidget::Blue, CLedWidget::Black, CLedWidget::Rounded, "standby", "", LedWidth, this)), m_ledModes(new CLedWidget(false, CLedWidget::Green, CLedWidget::Black, CLedWidget::Rounded, "mode C", "", LedWidth, this)), m_ledIdent(new CLedWidget(false, CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Rounded, "ident", "", LedWidth, this)) @@ -38,7 +39,7 @@ namespace BlackGui void CCockpitTransponderModeLedsComponent::ps_onAircraftCockpitChanged(const CAircraft &aircraft, const BlackMisc::COriginator &originator) { - if (ledsOriginator() == originator) { return; } + if (isMyOriginator(originator)) { return; } this->setMode(aircraft.getTransponderMode()); } @@ -70,7 +71,7 @@ namespace BlackGui this->setMode(mode); CTransponder xpdr = ownAircraft.getTransponder(); xpdr.setTransponderMode(mode); - this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator()); + this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, originator()); } void CCockpitTransponderModeLedsComponent::init(bool horizontal) @@ -133,13 +134,5 @@ namespace BlackGui return getIContextOwnAircraft()->getOwnAircraft(); } - BlackMisc::COriginator CCockpitTransponderModeLedsComponent::ledsOriginator() - { - if (m_originator.getName().isEmpty()) - m_originator = COriginator(QStringLiteral("XPDRLEDSCOMCOMPONENT")); - - return m_originator; - } - } // namespace } // namespace diff --git a/src/blackgui/components/cockpittranspondermodeledscomponent.h b/src/blackgui/components/cockpittranspondermodeledscomponent.h index a5b4b237d..e795c4bd2 100644 --- a/src/blackgui/components/cockpittranspondermodeledscomponent.h +++ b/src/blackgui/components/cockpittranspondermodeledscomponent.h @@ -15,7 +15,7 @@ #include "blackgui/blackguiexport.h" #include "enableforruntime.h" #include "../led.h" -#include "blackmisc/originator.h" +#include "blackmisc/originatoraware.h" #include "blackmisc/aviation/aircraft.h" #include "blackmisc/aviation/transponder.h" #include @@ -26,7 +26,10 @@ namespace BlackGui { //! LEDs representing transponder mode state - class BLACKGUI_EXPORT CCockpitTransponderModeLedsComponent : public QFrame, public CEnableForRuntime + class BLACKGUI_EXPORT CCockpitTransponderModeLedsComponent : + public QFrame, + public CEnableForRuntime, + public BlackMisc::COriginatorAware { Q_OBJECT @@ -60,16 +63,10 @@ namespace BlackGui //! Own Aircraft BlackMisc::Aviation::CAircraft getOwnAircraft() const; - //! Identifies sender of cockpit updates - BlackMisc::COriginator ledsOriginator(); - QScopedPointer m_ledStandby; QScopedPointer m_ledModes; QScopedPointer m_ledIdent; - BlackMisc::COriginator m_originator; - }; - } // namespace } // namespace diff --git a/src/plugins/simulator/fs9/simulator_fs9.cpp b/src/plugins/simulator/fs9/simulator_fs9.cpp index 14963b2d4..77c486253 100644 --- a/src/plugins/simulator/fs9/simulator_fs9.cpp +++ b/src/plugins/simulator/fs9/simulator_fs9.cpp @@ -60,11 +60,11 @@ namespace BlackSimPlugin connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0)); this->m_interpolator = new BlackCore::CInterpolatorLinear(remoteAircraftProvider, this); m_modelMatcher.setDefaultModel(CAircraftModel( - "Boeing 737-400", - CAircraftModel::TypeModelMatchingDefaultModel, - "B737-400 default model", - CAircraftIcaoData(CAircraftIcaoCode("B734", "L2J"), CAirlineIcaoCode(), "FFFFFF") - )); + "Boeing 737-400", + CAircraftModel::TypeModelMatchingDefaultModel, + "B737-400 default model", + CAircraftIcaoData(CAircraftIcaoCode("B734", "L2J"), CAirlineIcaoCode(), "FFFFFF") + )); } bool CSimulatorFs9::isConnected() const @@ -124,9 +124,9 @@ namespace BlackSimPlugin // matched models CAircraftModel aircraftModel = getClosestMatch(newRemoteAircraftCopy); Q_ASSERT(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign()); - updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator()); - updateAircraftRendered(newRemoteAircraft.getCallsign(), true, simulatorOriginator()); - CSimulatedAircraft aircraftAfterModelApplied (getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign())); + updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, originator()); + updateAircraftRendered(newRemoteAircraft.getCallsign(), true, originator()); + CSimulatedAircraft aircraftAfterModelApplied(getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign())); aircraftAfterModelApplied.setRendered(true); emit modelMatchingCompleted(aircraftAfterModelApplied); @@ -136,7 +136,7 @@ namespace BlackSimPlugin client->start(); m_hashFs9Clients.insert(callsign, client); - updateAircraftRendered(callsign, true, this->simulatorOriginator()); + updateAircraftRendered(callsign, true, this->originator()); CLogMessage(this).info("FS9: Added aircraft %1") << callsign.toQString(); return true; } @@ -148,7 +148,7 @@ namespace BlackSimPlugin auto fs9Client = m_hashFs9Clients.value(callsign); fs9Client->quit(); m_hashFs9Clients.remove(callsign); - updateAircraftRendered(callsign, false, this->simulatorOriginator()); + updateAircraftRendered(callsign, false, this->originator()); CLogMessage(this).info("FS9: Removed aircraft %1") << callsign.toQString(); return true; } @@ -173,7 +173,7 @@ namespace BlackSimPlugin bool CSimulatorFs9::updateOwnSimulatorCockpit(const CAircraft &ownAircraft, const COriginator &originator) { - if (originator == this->simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } if (!this->isSimulating()) { return false; } // actually those data should be the same as ownAircraft @@ -307,7 +307,7 @@ namespace BlackSimPlugin simDataOwnAircraft.getCom1System(), simDataOwnAircraft.getCom2System(), simDataOwnAircraft.getTransponder(), - this->simulatorOriginator()); + this->originator()); } void CSimulatorFs9::disconnectAllClients() diff --git a/src/plugins/simulator/fscommon/simulator_fscommon.cpp b/src/plugins/simulator/fscommon/simulator_fscommon.cpp index 5acbe0950..2769692c8 100644 --- a/src/plugins/simulator/fscommon/simulator_fscommon.cpp +++ b/src/plugins/simulator/fscommon/simulator_fscommon.cpp @@ -179,7 +179,7 @@ namespace BlackSimPlugin bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft, const COriginator &originator) { - if (originator == simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } // remove upfront, and then enable / disable again this->physicallyRemoveRemoteAircraft(aircraft.getCallsign()); @@ -188,7 +188,7 @@ namespace BlackSimPlugin bool CSimulatorFsCommon::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft, const COriginator &originator) { - if (originator == simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } if (aircraft.isEnabled()) { this->physicallyAddRemoteAircraft(aircraft); diff --git a/src/plugins/simulator/fsx/simulator_fsx.cpp b/src/plugins/simulator/fsx/simulator_fsx.cpp index e102ad0e6..2bdf96ce1 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx.cpp @@ -166,7 +166,7 @@ namespace BlackSimPlugin CAircraftModel aircraftModel = getClosestMatch(newRemoteAircraft); Q_ASSERT_X(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns"); - this->updateAircraftModel(callsign, aircraftModel, simulatorOriginator()); + this->updateAircraftModel(callsign, aircraftModel, originator()); CSimulatedAircraft aircraftAfterModelApplied(getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign())); // create AI @@ -190,7 +190,7 @@ namespace BlackSimPlugin } aircraftAfterModelApplied.setRendered(rendered); - this->updateAircraftRendered(callsign, rendered, simulatorOriginator()); + this->updateAircraftRendered(callsign, rendered, originator()); emit modelMatchingCompleted(aircraftAfterModelApplied); return rendered; @@ -198,7 +198,7 @@ namespace BlackSimPlugin bool CSimulatorFsx::updateOwnSimulatorCockpit(const CAircraft &ownAircraft, const COriginator &originator) { - if (originator == this->simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } if (!this->isSimulating()) { return false; } // actually those data should be the same as ownAircraft @@ -435,7 +435,7 @@ namespace BlackSimPlugin if (changedCom1 || changedCom2 || changedXpr) { - this->updateCockpit(com1, com2, transponder, simulatorOriginator()); + this->updateCockpit(com1, com2, transponder, originator()); } } else @@ -460,7 +460,7 @@ namespace BlackSimPlugin if (!changed) { return; } CTransponder xpdr = myAircraft.getTransponder(); xpdr.setTransponderMode(newMode); - this->updateCockpit(myAircraft.getCom1System(), myAircraft.getCom2System(), xpdr, this->simulatorOriginator()); + this->updateCockpit(myAircraft.getCom1System(), myAircraft.getCom2System(), xpdr, this->originator()); } void CSimulatorFsx::setSimConnectObjectID(DWORD requestID, DWORD objectID) @@ -542,7 +542,7 @@ namespace BlackSimPlugin bool CSimulatorFsx::physicallyRemoveRemoteAircraft(const CCallsign &callsign) { // only remove from sim - Q_ASSERT(BlackCore::isCurrentThreadObjectThread(this)); + Q_ASSERT_X(BlackCore::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thred"); if (!m_simConnectObjects.contains(callsign)) { return false; } return physicallyRemoveRemoteAircraft(m_simConnectObjects.value(callsign)); } @@ -564,7 +564,7 @@ namespace BlackSimPlugin CCallsign callsign(simObject.getCallsign()); m_simConnectObjects.remove(callsign); SimConnect_AIRemoveObject(m_hSimConnect, static_cast(simObject.getObjectId()), static_cast(simObject.getRequestId())); - updateAircraftRendered(callsign, false, simulatorOriginator()); + updateAircraftRendered(callsign, false, originator()); CLogMessage(this).info("FSX: Removed aircraft %1") << simObject.getCallsign().toQString(); return true; } diff --git a/src/plugins/simulator/xplane/simulator_xplane.cpp b/src/plugins/simulator/xplane/simulator_xplane.cpp index 5b5fd5581..713c7467c 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.cpp +++ b/src/plugins/simulator/xplane/simulator_xplane.cpp @@ -110,7 +110,7 @@ namespace BlackSimPlugin Aviation::CComSystem::getCom1System({ m_xplaneData.com1Active, CFrequencyUnit::kHz() }, { m_xplaneData.com1Standby, CFrequencyUnit::kHz() }), Aviation::CComSystem::getCom2System({ m_xplaneData.com2Active, CFrequencyUnit::kHz() }, { m_xplaneData.com2Standby, CFrequencyUnit::kHz() }), Aviation::CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent)), - simulatorOriginator() + originator() ); } } @@ -319,7 +319,7 @@ namespace BlackSimPlugin bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft, const COriginator &originator) { Q_ASSERT(isConnected()); - if (originator == this->simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } auto com1 = Aviation::CComSystem::getCom1System({ m_xplaneData.com1Active, CFrequencyUnit::kHz() }, { m_xplaneData.com1Standby, CFrequencyUnit::kHz() }); auto com2 = Aviation::CComSystem::getCom2System({ m_xplaneData.com2Active, CFrequencyUnit::kHz() }, { m_xplaneData.com2Standby, CFrequencyUnit::kHz() }); auto xpdr = Aviation::CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent)); @@ -353,7 +353,7 @@ namespace BlackSimPlugin // Is there any model matching required ???? CAircraftIcaoData icao = newRemoteAircraft.getIcaoInfo(); m_traffic->addPlane(newRemoteAircraft.getCallsign().asString(), icao.getAircraftDesignator(), icao.getAirlineDesignator(), icao.getLivery()); - updateAircraftRendered(newRemoteAircraft.getCallsign(), true, simulatorOriginator()); + updateAircraftRendered(newRemoteAircraft.getCallsign(), true, originator()); CLogMessage(this).info("XP: Added aircraft %1") << newRemoteAircraft.getCallsign().toQString(); return true; } @@ -388,7 +388,7 @@ namespace BlackSimPlugin { Q_ASSERT(isConnected()); m_traffic->removePlane(callsign.asString()); - updateAircraftRendered(callsign, false, simulatorOriginator()); + updateAircraftRendered(callsign, false, originator()); CLogMessage(this).info("XP: Removed aircraft %1") << callsign.toQString(); return true; } @@ -398,7 +398,7 @@ namespace BlackSimPlugin //! \todo XP driver obtain number of removed aircraft int r = getAircraftInRangeCount(); m_traffic->removeAllPlanes(); - updateMarkAllAsNotRendered(simulatorOriginator()); + updateMarkAllAsNotRendered(originator()); CLogMessage(this).info("XP: Removed all aircraft"); return r; } @@ -422,7 +422,7 @@ namespace BlackSimPlugin bool CSimulatorXPlane::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft, const COriginator &originator) { - if (originator == simulatorOriginator()) { return false; } + if (originator == this->originator()) { return false; } if (aircraft.isEnabled()) { this->physicallyAddRemoteAircraft(aircraft); diff --git a/src/swiftcore/swiftcore.cpp b/src/swiftcore/swiftcore.cpp index f983f8700..f235dea44 100644 --- a/src/swiftcore/swiftcore.cpp +++ b/src/swiftcore/swiftcore.cpp @@ -27,6 +27,7 @@ using namespace BlackGui::Components; CSwiftCore::CSwiftCore(const SetupInfo &info, QWidget *parent) : CSystemTrayWindow(CIcons::swiftNova24(), parent), + COriginatorAware(this), ui(new Ui::CSwiftCore) { ui->setupUi(this); diff --git a/src/swiftcore/swiftcore.h b/src/swiftcore/swiftcore.h index d50022d08..dd6f0db50 100644 --- a/src/swiftcore/swiftcore.h +++ b/src/swiftcore/swiftcore.h @@ -12,10 +12,12 @@ #ifndef SWIFTCORE_H #define SWIFTCORE_H -#include "blackmisc/statusmessage.h" #include "blackcore/context_runtime.h" #include "blackgui/systemtraywindow.h" #include "blackgui/components/enableforruntime.h" +#include "blackmisc/statusmessage.h" +#include "blackmisc/originatoraware.h" + #include namespace Ui { class CSwiftCore; } @@ -23,6 +25,7 @@ namespace Ui { class CSwiftCore; } //! swift core control class CSwiftCore : public BlackGui::CSystemTrayWindow, + public BlackMisc::COriginatorAware, public BlackGui::Components::CEnableForRuntime { Q_OBJECT