mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #619, using latest selection cache in mapping component and init upon this
This commit is contained in:
@@ -84,6 +84,21 @@ namespace BlackGui
|
||||
|
||||
// vPilot
|
||||
this->initVPilotLoading();
|
||||
QTimer::singleShot(1000, this, &CDbMappingComponent::ps_deferredInit);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_deferredInit()
|
||||
{
|
||||
// deferred
|
||||
this->m_lastInteractions.synchronize();
|
||||
const CSimulatorInfo sim = this->m_lastInteractions.get().getLastSimulatorSelection();
|
||||
|
||||
if (sim.isSingleSimulator())
|
||||
{
|
||||
// if we have already use this before, use it again, but only from cache
|
||||
this->initModelLoader(sim);
|
||||
this->m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
|
||||
}
|
||||
}
|
||||
|
||||
CDbMappingComponent::~CDbMappingComponent()
|
||||
@@ -135,7 +150,11 @@ namespace BlackGui
|
||||
bool CDbMappingComponent::initModelLoader(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
// already loaded
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simInfo)) { return true; }
|
||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simInfo))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// unload old
|
||||
if (this->m_modelLoader) { this->m_modelLoader->cancelLoading(); }
|
||||
@@ -150,6 +169,7 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
bool c = connect(this->m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbMappingComponent::ps_onOwnModelsLoadingFinished);
|
||||
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
||||
Q_UNUSED(c);
|
||||
return true;
|
||||
@@ -547,7 +567,7 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_VPilot);
|
||||
const int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_VPilot);
|
||||
QString o = this->ui->tw_ModelsToBeMapped->tabText(i);
|
||||
QString f = this->ui->tvp_AircraftModelsForVPilot->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->tvp_AircraftModelsForVPilot->rowCount()) + f;
|
||||
@@ -558,8 +578,9 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_OwnModels);
|
||||
QString o = this->ui->tw_ModelsToBeMapped->tabText(i);
|
||||
const int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_OwnModels);
|
||||
static const QString ot(this->ui->tw_ModelsToBeMapped->tabText(i));
|
||||
QString o(ot);
|
||||
if (this->m_modelLoader)
|
||||
{
|
||||
QString sims(this->m_modelLoader->supportedSimulatorsAsString());
|
||||
@@ -659,7 +680,6 @@ namespace BlackGui
|
||||
|
||||
void CDbMappingComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
//! \todo, load correct loader
|
||||
if (!this->initModelLoader(simInfo))
|
||||
{
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simInfo.toQString();
|
||||
@@ -677,18 +697,26 @@ namespace BlackGui
|
||||
this->m_modelLoader->startLoading();
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_onOwnModelsLoadingFinished(bool success)
|
||||
void CDbMappingComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simInfo)
|
||||
{
|
||||
if (success && this->m_modelLoader)
|
||||
{
|
||||
const CAircraftModelList models(this->m_modelLoader->getAircraftModels());
|
||||
CLogMessage(this).info("Loading %1 of models completed") << models.size();
|
||||
this->ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
|
||||
CLogMessage(this).info("Loading %1 of models completed") << models.size();
|
||||
|
||||
// store for later
|
||||
Data::CDbMappingComponent mc(this->m_lastInteractions.get());
|
||||
if (simInfo.isSingleSimulator() && mc.getLastSimulatorSelection() != simInfo)
|
||||
{
|
||||
mc.setLastSimulatorSelection(simInfo);
|
||||
this->m_lastInteractions.set(mc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Loading of models failed, simulator");
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
CLogMessage(this).error("Loading of models failed, simulator %1") << simInfo.toQString();
|
||||
}
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/data/lastselections.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
@@ -179,7 +180,7 @@ namespace BlackGui
|
||||
void ps_loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! Model loading finished
|
||||
void ps_onOwnModelsLoadingFinished(bool success);
|
||||
void ps_onOwnModelsLoadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! Own model count changed
|
||||
void ps_onOwnModelsCountChanged(int count, bool withFilter);
|
||||
@@ -211,14 +212,18 @@ namespace BlackGui
|
||||
//! Open simulator file
|
||||
void ps_showSimulatorFile();
|
||||
|
||||
//! When main GUI application has been started
|
||||
void ps_deferredInit();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog;
|
||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
||||
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
|
||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing
|
||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
||||
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
|
||||
BlackMisc::CData<BlackGui::Components::Data::DbMappingComponent> m_lastInteractions {this}; //!< last interactions
|
||||
bool m_vPilot1stInit = true;
|
||||
bool m_withVPilot = false;
|
||||
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
|
||||
|
||||
Reference in New Issue
Block a user