mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #661, improved own model set handling
* fixed simulator selector * added simulator selector to own model set component * pinned last selections * fixed model cache to use "getCopy"
This commit is contained in:
@@ -59,7 +59,8 @@ namespace BlackMisc
|
||||
void CAircraftModelSetLoader::changeSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
||||
this->m_caches.syncronizeCache(simulator);
|
||||
if (this->getSimulator() == simulator) { return; }
|
||||
this->m_caches.syncronizeCache(simulator); // also changes current simulator of caches
|
||||
emit simulatorChanged(simulator);
|
||||
}
|
||||
|
||||
@@ -74,6 +75,11 @@ namespace BlackMisc
|
||||
return this->m_caches.getCachedModels(simulator);
|
||||
}
|
||||
|
||||
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
||||
{
|
||||
return getAircraftModels().size();
|
||||
}
|
||||
|
||||
CAircraftModel CAircraftModelSetLoader::getModelForModelString(const QString &modelString) const
|
||||
{
|
||||
if (modelString.isEmpty()) { return CAircraftModel(); }
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace BlackMisc
|
||||
//! Destructor
|
||||
virtual ~CAircraftModelSetLoader();
|
||||
|
||||
//! Make sure cache is syncronized
|
||||
bool syncronizeCache();
|
||||
|
||||
//! The loaded models
|
||||
//! \threadsafe
|
||||
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
||||
@@ -61,7 +64,7 @@ namespace BlackMisc
|
||||
|
||||
//! Count of loaded models
|
||||
//! \threadsafe
|
||||
int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
||||
int getAircraftModelsCount() const;
|
||||
|
||||
//! Model for given model string
|
||||
//! \threadsafe
|
||||
@@ -110,9 +113,6 @@ namespace BlackMisc
|
||||
//! Cache timestamp
|
||||
QDateTime getCacheTimestamp() const;
|
||||
|
||||
//! Make sure cache is syncronized
|
||||
bool syncronizeCache();
|
||||
|
||||
//! Any cached data?
|
||||
bool hasCachedData() const;
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ namespace BlackMisc
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
{
|
||||
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get();
|
||||
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get();
|
||||
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get();
|
||||
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get();
|
||||
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy();
|
||||
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy();
|
||||
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy();
|
||||
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy();
|
||||
default:
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
return CAircraftModelList();
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace BlackMisc
|
||||
//! Last selection
|
||||
struct ModelCacheLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||
{
|
||||
//! First load is synchronous
|
||||
static constexpr bool isPinned() { return true; }
|
||||
|
||||
//! Key
|
||||
static const char *key() { return "modelcachelastselection"; }
|
||||
};
|
||||
@@ -111,6 +114,9 @@ namespace BlackMisc
|
||||
//! Last selection
|
||||
struct ModelSetLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||
{
|
||||
//! First load is synchronous
|
||||
static constexpr bool isPinned() { return true; }
|
||||
|
||||
//! Key
|
||||
static const char *key() { return "modelsetlastselection"; }
|
||||
};
|
||||
@@ -231,7 +237,6 @@ namespace BlackMisc
|
||||
//! @}
|
||||
|
||||
private:
|
||||
//! \todo Why can`t I keep the changed functions in IMultiSimulatorModelCaches -> C2039 not a member
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFsx> m_modelCacheFsx {this, &CModelSetCaches::changedFsx }; //!< FSX cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFs9> m_modelCacheFs9 {this, &CModelSetCaches::changedFs9}; //!< FS9 cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this, &CModelSetCaches::changedP3D }; //!< P3D cache
|
||||
|
||||
Reference in New Issue
Block a user