Ref T514, signal/slot for model loading progress displayed in UI

This commit is contained in:
Klaus Basan
2019-01-16 01:34:54 +01:00
committed by Mat Sutcliffe
parent f8ee2acf5d
commit 474b1aad6c
4 changed files with 30 additions and 6 deletions

View File

@@ -57,9 +57,10 @@ namespace BlackGui
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::jsonLoadCompleted, this, &CDbOwnModelsComponent::onViewDiskLoadingFinished, Qt::QueuedConnection);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorSelectorChanged);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this, &CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted, Qt::QueuedConnection);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingProgress, this, &CDbOwnModelsComponent::onModelLoadingProgress, Qt::QueuedConnection);
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
// Last selection isPinned -> no sync needed
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
@@ -605,7 +606,14 @@ namespace BlackGui
void CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode)
{
const CStatusMessage msg = CLogMessage(this).info(u"Started disk loading for '%1' in mode '%2'") << simulator.toQString(true) << IAircraftModelLoader::enumToString(mode);
this->showOverlayMessage(msg, 5000);
this->showOverlayHTMLMessage(msg, 5000);
}
void CDbOwnModelsComponent::onModelLoadingProgress(const CSimulatorInfo &simulator, const QString &message, int progress)
{
CStatusMessage loadingMsg = CStatusMessage(this).info(u"%1 loading: %2") << simulator.toQString(true) << message;
this->showOverlayHTMLMessage(loadingMsg, 5000);
Q_UNUSED(progress);
}
void CDbOwnModelsComponent::onModelLoaderLoadingFinished(const CStatusMessageList &statusMessages, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info)
@@ -628,7 +636,10 @@ namespace BlackGui
}
// overlay
if (!m.isEmpty() && info == IAircraftModelLoader::ParsedData) { this->showOverlayMessage(m, 5000); }
if (!m.isEmpty() && info == IAircraftModelLoader::ParsedData)
{
this->showOverlayHTMLMessage(m, 5000);
}
// signal
emit this->successfullyLoadedModels(simulator, modelsLoaded);

View File

@@ -143,6 +143,9 @@ namespace BlackGui
//! On disk loading started
void onModelLoaderDiskLoadingStarted(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
//! Loading in progress
void onModelLoadingProgress(const BlackMisc::Simulation::CSimulatorInfo &simulator, const QString &message, int progress);
//! Model loading finished
void onModelLoaderLoadingFinished(const BlackMisc::CStatusMessageList &statusMessages, const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadFinishedInfo info);

View File

@@ -275,9 +275,10 @@ namespace BlackMisc
IAircraftModelLoader *CMultiAircraftModelLoaderProvider::initLoader(const CSimulatorInfo &simulator)
{
IAircraftModelLoader *loader = IAircraftModelLoader::createModelLoader(simulator, this);
connect(loader, &IAircraftModelLoader::loadingFinished, this, &CMultiAircraftModelLoaderProvider::loadingFinished);
connect(loader, &IAircraftModelLoader::loadingFinished, this, &CMultiAircraftModelLoaderProvider::loadingFinished);
connect(loader, &IAircraftModelLoader::diskLoadingStarted, this, &CMultiAircraftModelLoaderProvider::diskLoadingStarted);
connect(loader, &IAircraftModelLoader::cacheChanged, this, &CMultiAircraftModelLoaderProvider::cacheChanged);
connect(loader, &IAircraftModelLoader::cacheChanged, this, &CMultiAircraftModelLoaderProvider::cacheChanged);
connect(loader, &IAircraftModelLoader::loadingProgress, this, &CMultiAircraftModelLoaderProvider::loadingProgress);
return loader;
}

View File

@@ -138,6 +138,12 @@ namespace BlackMisc
//! \remark does to fire if the cache has been changed elsewhere and it has just been reloaded here!
void loadingFinished(const BlackMisc::CStatusMessageList &status, const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadFinishedInfo info);
//! Loading progress, normally from disk
//! \param simulator corresponding simulator
//! \param message a progress message which can be sent by each individual loader implementation as needed
//! \param progressPercentage 0-100 or -1 if not available
void loadingProgress(const BlackMisc::Simulation::CSimulatorInfo &simulator, const QString &message, int progressPercentage);
//! Relayed from centralized caches
//! \remark this can result from loading, the cache changed elsewhere or clearing data
void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
@@ -224,6 +230,9 @@ namespace BlackMisc
//! \copydoc IAircraftModelLoader::diskLoadingStarted
void diskLoadingStarted(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
//! \copydoc IAircraftModelLoader::loadingProgress
void loadingProgress(const BlackMisc::Simulation::CSimulatorInfo &simulator, const QString &message, int progressPercentage);
//! \copydoc IAircraftModelLoader::cacheChanged
void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);