mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Ref T292, Ref T285 added signal in loader for "disk loading" and fixed displaying of "already loading" messages
This commit is contained in:
@@ -52,6 +52,7 @@ namespace BlackGui
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorSelectorChanged);
|
||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onOwnModelsLoadingFinished, Qt::QueuedConnection);
|
||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this, &CDbOwnModelsComponent::onOwnModelsDiskLoadingStarted, Qt::QueuedConnection);
|
||||
|
||||
// Last selection isPinned -> no sync needed
|
||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||
@@ -477,26 +478,44 @@ namespace BlackGui
|
||||
void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode, const QStringList &modelDirectories)
|
||||
{
|
||||
if (!m_modelLoader) { return; }
|
||||
|
||||
// here m_modelLoader is still the "current" loader
|
||||
if (m_modelLoader->isLoadingInProgress())
|
||||
{
|
||||
CLogMessage(this).info("Loading for '%1' already in progress") << simulator.toQString();
|
||||
return;
|
||||
if (m_modelLoader->supportsSimulator(simulator))
|
||||
{
|
||||
const CStatusMessage msg = CLogMessage(this).warning("Loading for '%1' already in progress, will NOT load.") << simulator.toQString();
|
||||
this->showOverlayMessage(msg);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
const CStatusMessage msg = CLogMessage(this).warning("Loading for another simulator '%1' already in progress. Loading might be slow.") << simulator.toQString();
|
||||
this->showOverlayMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->initModelLoader(simulator))
|
||||
{
|
||||
CLogMessage(this).error("Cannot init model loader for %1") << simulator.toQString();
|
||||
const CStatusMessage msg = CLogMessage(this).error("Cannot init model loader for %1") << simulator.toQString();
|
||||
this->showOverlayMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not check for empty models die here, as depending on mode we could still load
|
||||
// will be checked in model loader
|
||||
CLogMessage(this).info("Starting loading for '%1'") << simulator.toQString();
|
||||
CLogMessage(this).info("Starting loading for '%1' in mode '%2'") << simulator.toQString() << IAircraftModelLoader::enumToString(mode);
|
||||
ui->tvp_OwnAircraftModels->showLoadIndicator();
|
||||
Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services");
|
||||
m_modelLoader->startLoading(mode, static_cast<int (*)(CAircraftModelList &, bool)>(&CDatabaseUtils::consolidateModelsWithDbData), modelDirectories);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::onOwnModelsDiskLoadingStarted(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
const CStatusMessage msg = CLogMessage(this).info("Started disk loading for '%1' in mode '%2'") << simulator.toQString(true) << IAircraftModelLoader::enumToString(mode);
|
||||
this->showOverlayMessage(msg, 5000);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::onOwnModelsLoadingFinished(const CStatusMessageList &statusMessages, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
|
||||
|
||||
@@ -136,6 +136,9 @@ namespace BlackGui
|
||||
//! Load the models
|
||||
void loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode, const QStringList &modelDirectories = {});
|
||||
|
||||
//! On disk loading started
|
||||
void onOwnModelsDiskLoadingStarted(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
//! Model loading finished
|
||||
void onOwnModelsLoadingFinished(const BlackMisc::CStatusMessageList &statusMessages, const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadFinishedInfo info);
|
||||
|
||||
|
||||
@@ -255,6 +255,7 @@ namespace BlackMisc
|
||||
{
|
||||
IAircraftModelLoader *loader = IAircraftModelLoader::createModelLoader(simulator, this);
|
||||
connect(loader, &IAircraftModelLoader::loadingFinished, this, &CMultiAircraftModelLoaderProvider::loadingFinished);
|
||||
connect(loader, &IAircraftModelLoader::diskLoadingStarted, this, &CMultiAircraftModelLoaderProvider::diskLoadingStarted);
|
||||
return loader;
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -129,6 +129,10 @@ namespace BlackMisc
|
||||
static IAircraftModelLoader *createModelLoader(const CSimulatorInfo &simulator, QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
//! Disk loading started
|
||||
//! \remark will only indicate loading from disk, not cache loading
|
||||
void diskLoadingStarted(const CSimulatorInfo &simulator, LoadMode loadMode);
|
||||
|
||||
//! Parsing is finished or cache has been loaded
|
||||
//! \remark does to fire if the cache has been changed elsewhere and it has just been reloaded here!
|
||||
void loadingFinished(const CStatusMessageList &status, const CSimulatorInfo &simulator, LoadFinishedInfo info);
|
||||
@@ -186,6 +190,9 @@ namespace BlackMisc
|
||||
//! \copydoc IAircraftModelLoader::loadingFinished
|
||||
void loadingFinished(const CStatusMessageList &status, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info);
|
||||
|
||||
//! \copydoc IAircraftModelLoader::diskLoadingStarted
|
||||
void diskLoadingStarted(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
private:
|
||||
IAircraftModelLoader *m_loaderFsx = nullptr;
|
||||
IAircraftModelLoader *m_loaderP3D = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user