mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T246, functions to access values of model loader/models component
* direct access to simulator settings * load models for simulator
This commit is contained in:
@@ -98,6 +98,14 @@ namespace BlackGui
|
||||
return m_modelLoader.get();
|
||||
}
|
||||
|
||||
bool CDbOwnModelsComponent::requestModelsInBackground(const CSimulatorInfo &simulator, bool onlyIfNotEmpty)
|
||||
{
|
||||
this->setSimulator(simulator);
|
||||
if (onlyIfNotEmpty && this->getOwnModelsCount() > 0) { return false; }
|
||||
this->requestSimulatorModels(simulator, onlyIfNotEmpty ? IAircraftModelLoader::InBackgroundNoCache : IAircraftModelLoader::LoadInBackground);
|
||||
return true;
|
||||
}
|
||||
|
||||
CAircraftModel CDbOwnModelsComponent::getOwnModelForModelString(const QString &modelString) const
|
||||
{
|
||||
if (!m_modelLoader) { return CAircraftModel(); }
|
||||
@@ -134,6 +142,7 @@ namespace BlackGui
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->loadInstalledModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
|
||||
ui->le_Simulator->setText(simulator.toQString());
|
||||
}
|
||||
|
||||
int CDbOwnModelsComponent::getOwnModelsCount() const
|
||||
@@ -431,7 +440,7 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->initModelLoader(simulator))
|
||||
{
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simulator.toQString();
|
||||
CLogMessage(this).error("Cannot init model loader for %1") << simulator.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -490,6 +499,7 @@ namespace BlackGui
|
||||
const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue());
|
||||
ui->tvp_OwnAircraftModels->setSimulatorForLoading(simulator);
|
||||
this->requestSimulatorModelsWithCacheInBackground(simulator);
|
||||
ui->le_Simulator->setText(simulator.toQString());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -105,6 +105,9 @@ namespace BlackGui
|
||||
//! Access to model loader
|
||||
BlackMisc::Simulation::IAircraftModelLoader *modelLoader() const;
|
||||
|
||||
//! Forced read for given simulator
|
||||
bool requestModelsInBackground(const BlackMisc::Simulation::CSimulatorInfo &simulator, bool onlyIfNotEmpty);
|
||||
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Data;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Simulation::XPlane;
|
||||
|
||||
@@ -257,6 +258,11 @@ namespace BlackMisc
|
||||
return m_caches.getInfoStringFsFamily();
|
||||
}
|
||||
|
||||
CSimulatorSettings IAircraftModelLoader::getCurrentSimulatorSettings() const
|
||||
{
|
||||
return m_settings.getSettings(this->getSimulator());
|
||||
}
|
||||
|
||||
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Single simulator");
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BlackMisc
|
||||
CacheSkipped = 1 << 3, //!< ignore cache
|
||||
CacheOnly = 1 << 4, //!< only read cache, never load from disk
|
||||
InBackgroundWithCache = LoadInBackground | CacheFirst, //!< Background, cached
|
||||
InBackgroundNoCache = LoadInBackground | CacheSkipped //!< Background, not cached
|
||||
InBackgroundNoCache = LoadInBackground | CacheSkipped //!< Background, not checking cache
|
||||
};
|
||||
Q_DECLARE_FLAGS(LoadMode, LoadModeFlag)
|
||||
|
||||
@@ -150,6 +150,12 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
|
||||
QString getInfoStringFsFamily() const;
|
||||
|
||||
//! Current simulator settings
|
||||
Settings::CSimulatorSettings getCurrentSimulatorSettings() const;
|
||||
|
||||
//! Access to multi simulator settings
|
||||
const Settings::CMultiSimulatorSettings &multiSimulatorSettings() const { return m_settings; }
|
||||
|
||||
//! \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()); }
|
||||
|
||||
Reference in New Issue
Block a user