mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Ref T529, own models UI component message sorting
* if errors sort by severity * timeout if there is no error * check connects
This commit is contained in:
committed by
Mat Sutcliffe
parent
02f638501e
commit
fb46947252
@@ -54,13 +54,20 @@ namespace BlackGui
|
|||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
|
||||||
ui->tvp_OwnAircraftModels->setSimulatorForLoading(ui->comp_SimulatorSelector->getValue());
|
ui->tvp_OwnAircraftModels->setSimulatorForLoading(ui->comp_SimulatorSelector->getValue());
|
||||||
|
|
||||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
bool c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
||||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::jsonLoadCompleted, this, &CDbOwnModelsComponent::onViewDiskLoadingFinished, Qt::QueuedConnection);
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorSelectorChanged);
|
c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::jsonLoadCompleted, this, &CDbOwnModelsComponent::onViewDiskLoadingFinished, Qt::QueuedConnection);
|
||||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this, &CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted, Qt::QueuedConnection);
|
c = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorSelectorChanged);
|
||||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingProgress, this, &CDbOwnModelsComponent::onModelLoadingProgress, Qt::QueuedConnection);
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
|
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this, &CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingProgress, this, &CDbOwnModelsComponent::onModelLoadingProgress, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
|
||||||
// Last selection isPinned -> no sync needed
|
// Last selection isPinned -> no sync needed
|
||||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||||
@@ -612,15 +619,16 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbOwnModelsComponent::onModelLoadingProgress(const CSimulatorInfo &simulator, const QString &message, int progress)
|
void CDbOwnModelsComponent::onModelLoadingProgress(const CSimulatorInfo &simulator, const QString &message, int progress)
|
||||||
{
|
{
|
||||||
CStatusMessage loadingMsg = CStatusMessage(this).info(u"%1 loading: %2") << simulator.toQString(true) << message;
|
const CStatusMessage loadingMsg = CStatusMessage(this).info(u"%1 loading: %2") << simulator.toQString(true) << message;
|
||||||
this->showOverlayHTMLMessage(loadingMsg, 5000);
|
this->showOverlayHTMLMessage(loadingMsg, 5000);
|
||||||
|
ui->tvp_OwnAircraftModels->showLoadIndicatorWithTimeout(5000); // trigger new load indicator
|
||||||
Q_UNUSED(progress);
|
Q_UNUSED(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbOwnModelsComponent::onModelLoaderLoadingFinished(const CStatusMessageList &statusMessages, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info)
|
void CDbOwnModelsComponent::onModelLoaderLoadingFinished(const CStatusMessageList &statusMessages, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
|
||||||
if (statusMessages.isSuccess() && m_modelLoader)
|
if (IAircraftModelLoader::isLoadedInfo(info) && m_modelLoader)
|
||||||
{
|
{
|
||||||
const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
|
const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
|
||||||
const int modelsLoaded = models.size();
|
const int modelsLoaded = models.size();
|
||||||
@@ -645,16 +653,28 @@ namespace BlackGui
|
|||||||
// signal
|
// signal
|
||||||
emit this->successfullyLoadedModels(simulator, modelsLoaded);
|
emit this->successfullyLoadedModels(simulator, modelsLoaded);
|
||||||
}
|
}
|
||||||
|
else if (info == IAircraftModelLoader::LoadingSkipped)
|
||||||
|
{
|
||||||
|
CLogMessage(this).error(u"Loading of models skipped, simulator '%1'") << simulator.toQString();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->tvp_OwnAircraftModels->clear();
|
ui->tvp_OwnAircraftModels->clear();
|
||||||
CLogMessage(this).error(u"Loading of models failed, simulator '%1'") << simulator.toQString();
|
CLogMessage(this).error(u"Loading of models failed, simulator '%1'") << simulator.toQString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusMessages.hasWarningOrErrorMessages())
|
// with errors we make sure errors are on top
|
||||||
|
int timeoutMs = -1;
|
||||||
|
if (statusMessages.hasErrorMessages())
|
||||||
{
|
{
|
||||||
this->showOverlayMessages(statusMessages);
|
this->setOverlayMessagesSorting(CStatusMessage::IndexSeverityAsIcon, Qt::DescendingOrder);
|
||||||
}
|
}
|
||||||
|
else if (!statusMessages.hasWarningOrErrorMessages())
|
||||||
|
{
|
||||||
|
// no issues
|
||||||
|
timeoutMs = 5000;
|
||||||
|
}
|
||||||
|
this->showOverlayMessages(statusMessages, false, timeoutMs);
|
||||||
|
|
||||||
// cache loads may occur in background, do not adjust UI settings
|
// cache loads may occur in background, do not adjust UI settings
|
||||||
if (info == IAircraftModelLoader::CacheLoaded) { return; }
|
if (info == IAircraftModelLoader::CacheLoaded) { return; }
|
||||||
|
|||||||
Reference in New Issue
Block a user