diff --git a/src/blackcore/aircraftmatcher.cpp b/src/blackcore/aircraftmatcher.cpp index 3ab6d504a..6dd9f0b58 100644 --- a/src/blackcore/aircraftmatcher.cpp +++ b/src/blackcore/aircraftmatcher.cpp @@ -35,7 +35,7 @@ namespace BlackCore { const CLogCategoryList &CAircraftMatcher::getLogCategories() { - static const BlackMisc::CLogCategoryList cats { BlackMisc::CLogCategory::matching() }; + static const BlackMisc::CLogCategoryList cats { CLogCategory::matching() }; return cats; } @@ -545,7 +545,7 @@ namespace BlackCore return inList; } - const CAircraftModelList outList(inList.findByManunfacturer(m)); + const CAircraftModelList outList(inList.findByManufacturer(m)); if (outList.isEmpty()) { if (log) { CMatchingUtils::addLogDetailsToList(log , remoteAircraft, info + " Not found " + m + ", cannot reduce", getLogCategories()); } diff --git a/src/blackmisc/simulation/aircraftmodel.cpp b/src/blackmisc/simulation/aircraftmodel.cpp index 1a6028c0b..de68ab2c3 100644 --- a/src/blackmisc/simulation/aircraftmodel.cpp +++ b/src/blackmisc/simulation/aircraftmodel.cpp @@ -417,6 +417,11 @@ namespace BlackMisc return (static_cast(simulator.getSimulator()) & static_cast(this->getSimulator().getSimulator())) > 0; } + bool CAircraftModel::matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const + { + return (static_cast(simulator) & static_cast(this->getSimulator().getSimulator())) > 0; + } + CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const { static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon"); diff --git a/src/blackmisc/simulation/aircraftmodel.h b/src/blackmisc/simulation/aircraftmodel.h index 60336d5c1..42fc0dab3 100644 --- a/src/blackmisc/simulation/aircraftmodel.h +++ b/src/blackmisc/simulation/aircraftmodel.h @@ -276,6 +276,9 @@ namespace BlackMisc //! Matches given simulator? bool matchesSimulator(const CSimulatorInfo &simulator) const; + //! Matches given simulator? + bool matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const; + //! File name (corresponding data for simulator, only available if representing simulator model QString getFileName() const { return m_fileName; } diff --git a/src/blackmisc/simulation/aircraftmodellist.cpp b/src/blackmisc/simulation/aircraftmodellist.cpp index 094612373..1d2249008 100644 --- a/src/blackmisc/simulation/aircraftmodellist.cpp +++ b/src/blackmisc/simulation/aircraftmodellist.cpp @@ -160,7 +160,7 @@ namespace BlackMisc }); } - CAircraftModelList CAircraftModelList::findByManunfacturer(const QString &manufacturer) const + CAircraftModelList CAircraftModelList::findByManufacturer(const QString &manufacturer) const { if (manufacturer.isEmpty()) { return CAircraftModelList(); } const QString m(manufacturer.toUpper().trimmed()); @@ -201,6 +201,14 @@ namespace BlackMisc }); } + CAircraftModelList CAircraftModelList::getAllFsFamilyModels() const + { + return this->findBy([ = ](const CAircraftModel & model) + { + return model.getSimulator().isMicrosoftOrPrepare3DSimulator(); + }); + } + QString CAircraftModelList::findModelIconPathByModelString(const QString &modelString) const { if (modelString.isEmpty()) { return ""; } diff --git a/src/blackmisc/simulation/aircraftmodellist.h b/src/blackmisc/simulation/aircraftmodellist.h index 305575cbe..4491102f2 100644 --- a/src/blackmisc/simulation/aircraftmodellist.h +++ b/src/blackmisc/simulation/aircraftmodellist.h @@ -109,7 +109,7 @@ namespace BlackMisc CAircraftModelList findWithKnownAircraftDesignator() const; //! Find by manufacturer - CAircraftModelList findByManunfacturer(const QString &manufacturer) const; + CAircraftModelList findByManufacturer(const QString &manufacturer) const; //! Models with aircraft family CAircraftModelList findByFamily(const QString &family) const; @@ -120,6 +120,9 @@ namespace BlackMisc //! Find by military flag CAircraftModelList findByMilitaryFlag(bool military) const; + //! All models of the FS (FSX, P3D, FS9) family + CAircraftModelList getAllFsFamilyModels() const; + //! Model icon path QString findModelIconPathByModelString(const QString &modelString) const; @@ -174,7 +177,7 @@ namespace BlackMisc //! Simulator counts CCountPerSimulator countPerSimulator() const; - //! Which simulator(s) have the most entries + //! Which simulator(s) have the most entries? CSimulatorInfo simulatorsWithMaxEntries() const; //! Update distributor, all models in list are set to given distributor diff --git a/src/blackmisc/simulation/aircraftmodelloader.cpp b/src/blackmisc/simulation/aircraftmodelloader.cpp index 85db93854..715ee43a9 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.cpp +++ b/src/blackmisc/simulation/aircraftmodelloader.cpp @@ -48,7 +48,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.getSyncronizedCachedModels(sim)); + CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim)); int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); if (c > 0) { @@ -95,6 +95,11 @@ namespace BlackMisc return this->m_caches.getCurrentCachedModels(); } + CAircraftModelList IAircraftModelLoader::getCachedAircraftModels(const CSimulatorInfo &simulator) const + { + return this->m_caches.getCachedModels(simulator); + } + QDateTime IAircraftModelLoader::getCacheTimestamp() const { return this->m_caches.getCurrentCacheTimestamp(); @@ -164,6 +169,16 @@ namespace BlackMisc this->cancelLoading(); } + QString IAircraftModelLoader::getInfoString() const + { + return this->m_caches.getInfoString(); + } + + QString IAircraftModelLoader::getInfoStringFsFamily() const + { + return this->m_caches.getInfoStringFsFamily(); + } + std::unique_ptr IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simulator) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Single simulator"); diff --git a/src/blackmisc/simulation/aircraftmodelloader.h b/src/blackmisc/simulation/aircraftmodelloader.h index 3edd51bd4..b6cc65a17 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.h +++ b/src/blackmisc/simulation/aircraftmodelloader.h @@ -80,10 +80,14 @@ namespace BlackMisc //! Loading finished? virtual bool isLoadingFinished() const = 0; - //! The loaded models + //! Get the loaded models //! \threadsafe BlackMisc::Simulation::CAircraftModelList getAircraftModels() const; + //! Get the cached models + //! \threadsafe + BlackMisc::Simulation::CAircraftModelList getCachedAircraftModels(const CSimulatorInfo &simulator) const; + //! Count of loaded models int getAircraftModelsCount() const { return getAircraftModels().size(); } @@ -114,6 +118,12 @@ namespace BlackMisc //! Shutdown void gracefulShutdown(); + //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoString + QString getInfoString() const; + + //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily + QString getInfoStringFsFamily() const; + //! \name Implementations of the model interfaces (allows to set models modified in utility functions) //! @{ virtual void setModels(const CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); } diff --git a/src/blackmisc/simulation/aircraftmodelsetloader.cpp b/src/blackmisc/simulation/aircraftmodelsetloader.cpp index 40e74b7d0..469bd13c1 100644 --- a/src/blackmisc/simulation/aircraftmodelsetloader.cpp +++ b/src/blackmisc/simulation/aircraftmodelsetloader.cpp @@ -42,8 +42,8 @@ namespace BlackMisc if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); } const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->m_caches.getCurrentSimulator(); if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); } - this->m_caches.syncronizeCache(sim); - CAircraftModelList allModels(this->m_caches.getSyncronizedCachedModels(sim)); + this->m_caches.synchronizeCache(sim); + CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim)); const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); if (c > 0) { @@ -60,7 +60,7 @@ namespace BlackMisc Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader"); if (this->getSimulator() == simulator) { return; } this->m_caches.setCurrentSimulator(simulator); - this->m_caches.syncronizeCurrentCache(); + this->m_caches.synchronizeCurrentCache(); emit simulatorChanged(simulator); } @@ -72,7 +72,7 @@ namespace BlackMisc CAircraftModelList CAircraftModelSetLoader::getAircraftModels(const CSimulatorInfo &simulator) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); - return this->m_caches.getSyncronizedCachedModels(simulator); + return this->m_caches.getSynchronizedCachedModels(simulator); } int CAircraftModelSetLoader::getAircraftModelsCount() const @@ -86,14 +86,19 @@ namespace BlackMisc return this->getAircraftModels().findFirstByModelStringOrDefault(modelString); } + CAircraftModelList CAircraftModelSetLoader::getCachedModels(const CSimulatorInfo &simulator) const + { + return this->m_caches.getCachedModels(simulator); + } + QDateTime CAircraftModelSetLoader::getCacheTimestamp() const { return this->m_caches.getCurrentCacheTimestamp(); } - bool CAircraftModelSetLoader::syncronizeCache() + bool CAircraftModelSetLoader::synchronizeCache() { - return this->m_caches.syncronizeCurrentCache(); + return this->m_caches.synchronizeCurrentCache(); } bool CAircraftModelSetLoader::hasCachedData() const @@ -118,12 +123,22 @@ namespace BlackMisc bool CAircraftModelSetLoader::supportsSimulator(const CSimulatorInfo &info) { - return getSimulator().matchesAny(info); + return this->getSimulator().matchesAny(info); } void CAircraftModelSetLoader::gracefulShutdown() { // void } + + QString CAircraftModelSetLoader::getInfoString() const + { + return this->m_caches.getInfoString(); + } + + QString CAircraftModelSetLoader::getInfoStringFsFamily() const + { + return this->m_caches.getInfoStringFsFamily(); + } } // ns } // ns diff --git a/src/blackmisc/simulation/aircraftmodelsetloader.h b/src/blackmisc/simulation/aircraftmodelsetloader.h index 11dfdd8a8..2b5df17a3 100644 --- a/src/blackmisc/simulation/aircraftmodelsetloader.h +++ b/src/blackmisc/simulation/aircraftmodelsetloader.h @@ -51,8 +51,8 @@ namespace BlackMisc //! Destructor virtual ~CAircraftModelSetLoader(); - //! Make sure cache is syncronized - bool syncronizeCache(); + //! Make sure cache is synchronized + bool synchronizeCache(); //! The loaded models //! \threadsafe @@ -60,7 +60,7 @@ namespace BlackMisc //! The loaded models for given simulator //! \threadsafe - //! \remark non-const because it syncronizes cache + //! \remark non-const because it synchronizes cache BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator); //! Count of loaded models @@ -71,6 +71,10 @@ namespace BlackMisc //! \threadsafe BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelString) const; + //! Models from cache + //! \threadsafe + BlackMisc::Simulation::CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const; + //! Which simulator is supported by that very loader CSimulatorInfo getSimulator() const; @@ -83,6 +87,12 @@ namespace BlackMisc //! Shutdown void gracefulShutdown(); + //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoString + QString getInfoString() const; + + //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily + QString getInfoStringFsFamily() const; + //! \name Implementations of the models interfaces //! @{ virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); } diff --git a/src/blackmisc/simulation/data/modelcaches.cpp b/src/blackmisc/simulation/data/modelcaches.cpp index 748442426..bc03a84ff 100644 --- a/src/blackmisc/simulation/data/modelcaches.cpp +++ b/src/blackmisc/simulation/data/modelcaches.cpp @@ -26,15 +26,32 @@ namespace BlackMisc this->setCachedModels(models, simulator); } - void IMultiSimulatorModelCaches::emitCacheChanged(const CSimulatorInfo &simulator) + QString IMultiSimulatorModelCaches::getInfoString() const { - emit cacheChanged(simulator); + static const QString is("FSX: %1 P3D: %2 FS9: %3 XP: %4"); + return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9)).arg(this->getCachedModelsCount(CSimulatorInfo::XPLANE)); } - CAircraftModelList IMultiSimulatorModelCaches::getSyncronizedCachedModels(const CSimulatorInfo &simulator) + QString IMultiSimulatorModelCaches::getInfoStringFsFamily() const + { + static const QString is("FSX: %1 P3D: %2 FS9: %3"); + return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9)); + } + + void IMultiSimulatorModelCaches::emitCacheChanged(const CSimulatorInfo &simulator) + { + emit this->cacheChanged(simulator); + } + + int IMultiSimulatorModelCaches::getCachedModelsCount(const CSimulatorInfo &simulator) const + { + return this->getCachedModels(simulator).size(); + } + + CAircraftModelList IMultiSimulatorModelCaches::getSynchronizedCachedModels(const CSimulatorInfo &simulator) { BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator"); - this->syncronizeCache(simulator); + this->synchronizeCache(simulator); return this->getCachedModels(simulator); } @@ -46,19 +63,19 @@ namespace BlackMisc return this->getCachedModels(sim); } - QDateTime IMultiSimulatorModelCaches::getSyncronizedTimestamp(const CSimulatorInfo &simulator) + QDateTime IMultiSimulatorModelCaches::getSynchronizedTimestamp(const CSimulatorInfo &simulator) { BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator"); - this->syncronizeCache(simulator); + this->synchronizeCache(simulator); return this->getCacheTimestamp(simulator); } - bool IMultiSimulatorModelCaches::syncronizeCurrentCache() + bool IMultiSimulatorModelCaches::synchronizeCurrentCache() { const CSimulatorInfo sim(this->getCurrentSimulator()); BLACK_VERIFY_X(sim.isSingleSimulator(), Q_FUNC_INFO, "need single simulator"); if (!sim.isSingleSimulator()) { return false; } - this->syncronizeCache(sim); + this->synchronizeCache(sim); return true; } @@ -72,7 +89,7 @@ namespace BlackMisc this->m_currentSimulator.set(sim); CLogMessage(this).warning("Invalid simulator, reseting"); } - this->syncronizeCacheImpl(sim); + this->synchronizeCacheImpl(sim); const QString simStr(sim.toQString(true)); CLogMessage(this).info("Initialized model caches to %1") << simStr; } @@ -130,9 +147,9 @@ namespace BlackMisc } } - void CModelCaches::syncronizeCache(const CSimulatorInfo &simulator) + void CModelCaches::synchronizeCache(const CSimulatorInfo &simulator) { - this->syncronizeCacheImpl(simulator); + this->synchronizeCacheImpl(simulator); } CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator) @@ -141,11 +158,11 @@ namespace BlackMisc const CSimulatorInfo s = this->m_currentSimulator.get(); if (s == simulator) { return sameSimMsg; } const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); - this->syncronizeCache(simulator); + this->synchronizeCache(simulator); return m; } - void CModelCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator) + void CModelCaches::synchronizeCacheImpl(const CSimulatorInfo &simulator) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); switch (simulator.getSimulator()) @@ -170,7 +187,7 @@ namespace BlackMisc this->m_currentSimulator.set(sim); CLogMessage(this).warning("Invalid simulator, reseting"); } - this->syncronizeCacheImpl(sim); + this->synchronizeCacheImpl(sim); const QString simStr(sim.toQString(true)); CLogMessage(this).info("Initialized model caches to %1") << simStr; } @@ -230,9 +247,9 @@ namespace BlackMisc } } - void CModelSetCaches::syncronizeCache(const CSimulatorInfo &simulator) + void CModelSetCaches::synchronizeCache(const CSimulatorInfo &simulator) { - this->syncronizeCacheImpl(simulator); + this->synchronizeCacheImpl(simulator); } CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator) @@ -241,11 +258,11 @@ namespace BlackMisc const CSimulatorInfo s = this->m_currentSimulator.get(); if (s == simulator) { return sameSimMsg; } const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); - this->syncronizeCache(simulator); + this->synchronizeCache(simulator); return m; } - void CModelSetCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator) + void CModelSetCaches::synchronizeCacheImpl(const CSimulatorInfo &simulator) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); switch (simulator.getSimulator()) diff --git a/src/blackmisc/simulation/data/modelcaches.h b/src/blackmisc/simulation/data/modelcaches.h index ce3355848..a37217fb4 100644 --- a/src/blackmisc/simulation/data/modelcaches.h +++ b/src/blackmisc/simulation/data/modelcaches.h @@ -151,13 +151,16 @@ namespace BlackMisc IMultiSimulatorModelCaches(QObject *parent = nullptr) : QObject(parent) { } - //! Models + //! Models for simulator //! \threadsafe virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0; + //! Count of models for simulator + int getCachedModelsCount(const BlackMisc::Simulation::CSimulatorInfo &simulator) const; + //! Models //! \todo is that threadsafe? - CAircraftModelList getSyncronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator); + CAircraftModelList getSynchronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator); //! Models //! \threadsafe @@ -169,7 +172,7 @@ namespace BlackMisc //! Timestamp //! \todo is that threadsafe? - QDateTime getSyncronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator); + QDateTime getSynchronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator); //! Last selection`s timestamp //! \threadsafe @@ -178,12 +181,12 @@ namespace BlackMisc //! Set cache virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0; - //! Syncronize + //! Synchronize //! \todo is that threadsafe? - virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0; + virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0; //! Last cache - bool syncronizeCurrentCache(); + bool synchronizeCurrentCache(); //! Selected simulator //! \threadsafe @@ -195,6 +198,12 @@ namespace BlackMisc //! \copydoc IModelsPerSimulatorSetable::setModels virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; + //! Info string about models in cache + QString getInfoString() const; + + //! Info string without XPlane (FSX,P3D, FS9) + QString getInfoStringFsFamily() const; + signals: //! Cache has been changed void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); @@ -228,7 +237,7 @@ namespace BlackMisc virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; - virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; + virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); } virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; //! @} @@ -241,7 +250,7 @@ namespace BlackMisc BlackMisc::CData m_currentSimulator { this }; //!< current simulator //! Non virtaul version (used in ctor) - void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator); + void synchronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator); }; //! Bundle of caches for model sets of all simulators @@ -259,7 +268,7 @@ namespace BlackMisc virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; - virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; + virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); } virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; //! @} @@ -272,7 +281,7 @@ namespace BlackMisc BlackMisc::CData m_currentSimulator { this }; //!< current simulator //! Non virtaul version (used in ctor) - void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator); + void synchronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator); }; } // ns } // ns diff --git a/src/blackmisc/simulation/simulatorinfo.cpp b/src/blackmisc/simulation/simulatorinfo.cpp index f92cb50ea..decad694d 100644 --- a/src/blackmisc/simulation/simulatorinfo.cpp +++ b/src/blackmisc/simulation/simulatorinfo.cpp @@ -145,6 +145,16 @@ namespace BlackMisc this->setSimulator(this->getSimulator() | other.getSimulator()); } + QSet CSimulatorInfo::asSingleSimulatorSet() const + { + QSet set; + if (this->m_simulator & FSX) { set.insert(CSimulatorInfo(FSX)); } + if (this->m_simulator & FS9) { set.insert(CSimulatorInfo(FS9)); } + if (this->m_simulator & P3D) { set.insert(CSimulatorInfo(P3D)); } + if (this->m_simulator & XPLANE) { set.insert(CSimulatorInfo(XPLANE)); } + return set; + } + CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d) { Simulator s = fsx ? FSX : None; @@ -185,6 +195,12 @@ namespace BlackMisc return s; } + const CSimulatorInfo &CSimulatorInfo::allFsFamilySimulators() + { + static const CSimulatorInfo s(CSimulatorInfo::AllFsFamily); + return s; + } + const CSimulatorInfo CSimulatorInfo::getLocallyInstalledSimulators() { //! \todo add XP, ... diff --git a/src/blackmisc/simulation/simulatorinfo.h b/src/blackmisc/simulation/simulatorinfo.h index 3d080c2f5..061685f8b 100644 --- a/src/blackmisc/simulation/simulatorinfo.h +++ b/src/blackmisc/simulation/simulatorinfo.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -45,14 +46,14 @@ namespace BlackMisc //! Simulator enum SimulatorFlag { - None = 0, - FSX = 1 << 0, - FS9 = 1 << 1, - XPLANE = 1 << 2, - P3D = 1 << 3, - FSX_P3D = FSX | P3D, - AllMS = FSX | FS9 | P3D, - All = FSX | FS9 | XPLANE | P3D + None = 0, + FSX = 1 << 0, + FS9 = 1 << 1, + XPLANE = 1 << 2, + P3D = 1 << 3, + FSX_P3D = FSX | P3D, + AllFsFamily = FSX | FS9 | P3D, + All = FSX | FS9 | XPLANE | P3D }; Q_DECLARE_FLAGS(Simulator, SimulatorFlag) @@ -143,6 +144,9 @@ namespace BlackMisc //! Add simulator void add(const CSimulatorInfo &other); + //! As a set of single simulator info objects + QSet asSingleSimulatorSet() const; + //! Bool flags to enum static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d); @@ -152,6 +156,9 @@ namespace BlackMisc //! All simulators static const CSimulatorInfo &allSimulators(); + //! All simulators of the FS family (P3D FSX, FS9) + static const CSimulatorInfo &allFsFamilySimulators(); + //! Locally installed simulators static const CSimulatorInfo getLocallyInstalledSimulators();