diff --git a/src/blackmisc/simulation/aircraftmodelloader.cpp b/src/blackmisc/simulation/aircraftmodelloader.cpp index 715ee43a9..57ecde5df 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.cpp +++ b/src/blackmisc/simulation/aircraftmodelloader.cpp @@ -30,7 +30,10 @@ namespace BlackMisc { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader"); this->m_caches.setCurrentSimulator(simulator); + + // first connect is an internal connection to log info about load status connect(this, &IAircraftModelLoader::loadingFinished, this, &IAircraftModelLoader::ps_loadFinished); + connect(&this->m_caches, &IMultiSimulatorModelCaches::cacheChanged, this, &IAircraftModelLoader::ps_cacheChanged); } IAircraftModelLoader::~IAircraftModelLoader() @@ -49,7 +52,7 @@ namespace BlackMisc if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); } const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator(); // support default values CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim)); - int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); + const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); if (c > 0) { return this->setCachedModels(allModels, sim); @@ -73,6 +76,11 @@ namespace BlackMisc } } + void IAircraftModelLoader::ps_cacheChanged(const CSimulatorInfo &simInfo) + { + emit this->loadingFinished(true, simInfo); + } + QStringList IAircraftModelLoader::getModelDirectoriesOrDefault() const { const QStringList mdirs = this->m_settings.getModelDirectoriesOrDefault(this->getSimulator()); @@ -136,8 +144,9 @@ namespace BlackMisc } if (mode.testFlag(CacheOnly)) { - // only cache, but we did not find any data - emit loadingFinished(false, this->getSimulator()); + // only cache, but we did not find any data yet (still in progress?) + // here we rely on the cache load slot, no need to emit here + // an alternative was to sync cache here return; } this->startLoadingFromDisk(mode, modelConsolidation, directory); diff --git a/src/blackmisc/simulation/aircraftmodelloader.h b/src/blackmisc/simulation/aircraftmodelloader.h index 81387302c..128a02396 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.h +++ b/src/blackmisc/simulation/aircraftmodelloader.h @@ -147,7 +147,7 @@ namespace BlackMisc BlackMisc::CStatusMessage replaceOrAddCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo()); signals: - //! Parsing is finished + //! Parsing is finished or cache has been loaded void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator); protected: @@ -175,6 +175,9 @@ namespace BlackMisc protected slots: //! Loading finished, also logs messages void ps_loadFinished(bool success); + + //! A cache has been changed + void ps_cacheChanged(const CSimulatorInfo &simInfo); }; } // ns } // ns diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp b/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp index 97b3b6919..e419fe2e6 100644 --- a/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp +++ b/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp @@ -125,14 +125,6 @@ namespace BlackMisc } } - void CAircraftCfgParser::ps_cacheChanged() - { - if (this->hasCachedData()) - { - emit this->loadingFinished(true, this->getSimulator()); - } - } - bool CAircraftCfgParser::isLoadingFinished() const { return !m_parserWorker || m_parserWorker->isFinished(); diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgparser.h b/src/blackmisc/simulation/fscommon/aircraftcfgparser.h index a027f68cd..72cd50c28 100644 --- a/src/blackmisc/simulation/fscommon/aircraftcfgparser.h +++ b/src/blackmisc/simulation/fscommon/aircraftcfgparser.h @@ -64,10 +64,6 @@ namespace BlackMisc virtual void startLoadingFromDisk(LoadMode mode, const ModelConsolidation &modelConsolidation, const QString &directory) override; //! @} - private slots: - //! Cache changed - void ps_cacheChanged(); - private: //! Section within file enum FileSection