diff --git a/src/blackcore/aircraftmatcher.cpp b/src/blackcore/aircraftmatcher.cpp index 37bbfa678..6c15eba89 100644 --- a/src/blackcore/aircraftmatcher.cpp +++ b/src/blackcore/aircraftmatcher.cpp @@ -50,6 +50,14 @@ namespace BlackCore CAircraftMatcher::~CAircraftMatcher() { } + bool CAircraftMatcher::setSetup(const CAircraftMatcherSetup &setup) + { + if (m_setup == setup) { return false; } + m_setup = setup; + emit this->setupChanged(); + return true; + } + CAirlineIcaoCode CAircraftMatcher::failoverValidAirlineIcaoDesignator( const CCallsign &callsign, const QString &primaryIcao, const QString &secondaryIcao, bool airlineFromCallsign, bool useWebServices, CStatusMessageList *log) diff --git a/src/blackcore/aircraftmatcher.h b/src/blackcore/aircraftmatcher.h index adf825e59..1827931a0 100644 --- a/src/blackcore/aircraftmatcher.h +++ b/src/blackcore/aircraftmatcher.h @@ -55,7 +55,7 @@ namespace BlackCore virtual ~CAircraftMatcher(); //! Set the setup - void setSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) { m_setup = setup; } + bool setSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup); //! Get the setup BlackMisc::Simulation::CAircraftMatcherSetup getSetup() const { return m_setup; } @@ -174,6 +174,10 @@ namespace BlackCore //! Evaluate if a statistics entry makes sense and add it void evaluateStatisticsEntry(const QString &sessionId, const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery); + signals: + //! Setup changed + void setupChanged(); + private: //! The search based implementation static BlackMisc::Simulation::CAircraftModel getClosestMatchStepwiseReduceImplementation(const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::Simulation::CAircraftModel &defaultModel, BlackMisc::CStatusMessageList *log = nullptr); diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index eb6cf36ef..c3c2c60dc 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -98,6 +98,9 @@ namespace BlackCore //! Setup changed void interpolationAndRenderingSetupChanged(); + //! Matching setup changed + void matchingSetupChanged(); + //! Model set ready or changed void modelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 4b1acbca2..44c014457 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -71,6 +71,7 @@ namespace BlackCore this->restoreSimulatorPlugins(); connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived); + connect(&m_aircraftMatcher, &CAircraftMatcher::setupChanged, this, &CContextSimulator::matchingSetupChanged); connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(), &CCentralMultiSimulatorModelSetCachesProvider::cacheChanged, this, &CContextSimulator::modelSetChanged); // deferred init of last model set, if no other data are set in meantime diff --git a/src/blackcore/context/contextsimulatorproxy.cpp b/src/blackcore/context/contextsimulatorproxy.cpp index 91c3ba99e..01553e515 100644 --- a/src/blackcore/context/contextsimulatorproxy.cpp +++ b/src/blackcore/context/contextsimulatorproxy.cpp @@ -65,6 +65,9 @@ namespace BlackCore s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), "interpolationAndRenderingSetupChanged", this, SIGNAL(interpolationAndRenderingSetupChanged())); Q_ASSERT(s); + s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), + "matchingSetupChanged", this, SIGNAL(matchingSetupChanged())); + Q_ASSERT(s); s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), "simulatorPluginChanged", this, SIGNAL(simulatorPluginChanged(BlackMisc::Simulation::CSimulatorPluginInfo))); Q_ASSERT(s); @@ -258,6 +261,11 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1String("parseCommandLine"), commandLine, originator); } + bool CContextSimulatorProxy::doMappingAgain(const CCallsign &callsign) + { + return m_dBusInterface->callDBusRet(QLatin1String("doMappingAgain"), callsign); + } + CMatchingStatistics CContextSimulatorProxy::getCurrentMatchingStatistics(bool missingOnly) const { return m_dBusInterface->callDBusRet(QLatin1String("getCurrentMatchingStatistics"), missingOnly); diff --git a/src/blackgui/components/settingsmatchingcomponent.cpp b/src/blackgui/components/settingsmatchingcomponent.cpp index 9cc9f9e4e..17d7b6ec7 100644 --- a/src/blackgui/components/settingsmatchingcomponent.cpp +++ b/src/blackgui/components/settingsmatchingcomponent.cpp @@ -28,6 +28,12 @@ namespace BlackGui ui->setupUi(this); connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed); connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed); + + IContextSimulator *simContext = simulatorContext(); + if (simContext) + { + connect(simContext, &IContextSimulator::matchingSetupChanged, this, &CSettingsMatchingComponent::onSetupChanged, Qt::QueuedConnection); + } this->deferredReload(5000); } @@ -47,6 +53,13 @@ namespace BlackGui this->deferredReload(0); } + void CSettingsMatchingComponent::onSetupChanged() + { + const IContextSimulator *simContext = simulatorContext(); + if (!simContext) { return; } + this->deferredReload(0); + } + void CSettingsMatchingComponent::deferredReload(int deferMs) { if (deferMs < 1) diff --git a/src/blackgui/components/settingsmatchingcomponent.h b/src/blackgui/components/settingsmatchingcomponent.h index acad9e834..b3c08d7e8 100644 --- a/src/blackgui/components/settingsmatchingcomponent.h +++ b/src/blackgui/components/settingsmatchingcomponent.h @@ -42,6 +42,9 @@ namespace BlackGui //! Reload pressed void onReloadPressed(); + //! Setup has been changed + void onSetupChanged(); + //! Deferred reload void deferredReload(int deferMs);