diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index 135d8fcd8..7da62cda0 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -165,9 +165,7 @@ namespace BlackGui { this->m_modelSetDialog->setModal(true); this->m_modelSetDialog->reloadData(); - QDialog::DialogCode rc = static_cast( - this->m_modelSetDialog->exec() - ); + QDialog::DialogCode rc = static_cast(this->m_modelSetDialog->exec()); if (rc == QDialog::Accepted) { this->setModelSet(this->m_modelSetDialog->getModelSet(), this->m_modelSetDialog->getSimulatorInfo()); @@ -235,6 +233,16 @@ namespace BlackGui } } + void CDbOwnModelSetComponent::ps_preferencesChanged() + { + const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); + const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator(); + if (simuulator.isSingleSimulator()) + { + this->updateDistributorOrder(simuulator); + } + } + void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &sim) { Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); @@ -248,6 +256,24 @@ namespace BlackGui this->ui->le_Simulator->setText(sim.toQString(true)); } + void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator) + { + CAircraftModelList modelSet = this->m_modelSetLoader.getAircraftModels(simulator); + if (modelSet.isEmpty()) { return; } + const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); + const CDistributorList distributors = preferences.getDistributors(simulator); + if (distributors.isEmpty()) { return; } + modelSet.updateDistributorOrder(distributors); + this->m_modelSetLoader.setModels(modelSet, simulator); + + // display? + const CSimulatorInfo currentSimulator(this->getModelSetSimulator()); + if (simulator == currentSimulator) + { + ui->tvp_OwnModelSet->updateContainerAsync(modelSet); + } + } + void CDbOwnModelSetComponent::CLoadModelsMenu::customMenu(QMenu &menu) const { const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); diff --git a/src/blackgui/components/dbownmodelsetcomponent.h b/src/blackgui/components/dbownmodelsetcomponent.h index be4d2c27e..d5ea29194 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.h +++ b/src/blackgui/components/dbownmodelsetcomponent.h @@ -13,6 +13,7 @@ #define BLACKGUI_COMPONENTS_DBOWNMODELSETCOMPONENT_H #include "blackgui/menus/menudelegate.h" +#include "blackcore/settings/distributorpreferences.h" #include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/aircraftmodelsetloader.h" #include "dbmappingcomponentaware.h" @@ -105,6 +106,9 @@ namespace BlackGui //! JSON data have been loaded from disk void ps_onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator); + //! Preferences changed + void ps_preferencesChanged(); + private: //! Default file name void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim); @@ -112,10 +116,14 @@ namespace BlackGui //! Simulator void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &sim); + //! Update distributor order + void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator); + QScopedPointer ui; QScopedPointer m_modelSetDialog; BlackMisc::Simulation::CSimulatorInfo m_simulator; BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this }; + BlackMisc::CSetting m_distributorPreferences { this, &CDbOwnModelSetComponent::ps_preferencesChanged }; //! The menu for loading and handling own models for mapping tasks //! \note This is specific for that very component