Ref T292, Ref T285 added signal in loader for "disk loading" and fixed displaying of "already loading" messages

This commit is contained in:
Klaus Basan
2018-07-25 02:28:26 +02:00
parent 74fa7d7289
commit 94bf4b2249
4 changed files with 34 additions and 4 deletions

View File

@@ -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");

View File

@@ -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);