From 2f577b7209568d118a40551619faad76825b8cd6 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 19 Sep 2017 00:57:04 +0200 Subject: [PATCH] Ref T152, the fix for the issue reported: everything was prepared, but the setting not changed in the UI. Now excluded models can be added to model set. --- .../components/settingsmodelcomponent.cpp | 23 +++++++++++++++++-- .../components/settingsmodelcomponent.h | 7 +++++- .../components/settingsmodelcomponent.ui | 10 +++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/blackgui/components/settingsmodelcomponent.cpp b/src/blackgui/components/settingsmodelcomponent.cpp index 40e308535..5f3862449 100644 --- a/src/blackgui/components/settingsmodelcomponent.cpp +++ b/src/blackgui/components/settingsmodelcomponent.cpp @@ -15,6 +15,7 @@ #include using namespace BlackMisc; +using namespace BlackMisc::Simulation::Settings; using namespace BlackGui::Settings; namespace BlackGui @@ -29,12 +30,14 @@ namespace BlackGui ui->le_ConsolidateSecs->setValidator(new QIntValidator(0, TBackgroundConsolidation::maxSecs(), ui->le_ConsolidateSecs)); this->cacheChanged(); - connect(ui->le_ConsolidateSecs, &QLineEdit::returnPressed, this, &CSettingsModelComponent::consolidationEntered); const QString lbl("Consolidate (%1-%2s):"); ui->lbl_Consolidate->setText(lbl.arg(TBackgroundConsolidation::minSecs()).arg(TBackgroundConsolidation::maxSecs())); + connect(ui->le_ConsolidateSecs, &QLineEdit::returnPressed, this, &CSettingsModelComponent::consolidationEntered); + connect(ui->cb_AllowExcludeModels, &QCheckBox::toggled, this, &CSettingsModelComponent::allowExcludedModelsChanged); + // start updater if not yet done - QTimer::singleShot(2000, this, &CSettingsModelComponent::consolidationEntered); + QTimer::singleShot(2500, this, &CSettingsModelComponent::consolidationEntered); } CSettingsModelComponent::~CSettingsModelComponent() @@ -64,6 +67,15 @@ namespace BlackGui this->cacheChanged(); } + void CSettingsModelComponent::allowExcludedModelsChanged(bool allow) + { + CModelSettings ms = m_modelSettings.get(); + if (ms.getAllowExcludedModels() == allow) { return; } + ms.setAllowExcludedModels(allow); + const CStatusMessage msg = m_modelSettings.setAndSave(ms); + CLogMessage::preformatted(msg); + } + void CSettingsModelComponent::cacheChanged() { const int v = m_consolidationSetting.get(); @@ -76,6 +88,13 @@ namespace BlackGui sApp && !sApp->isShuttingDown() && this->m_updater && this->m_updater->isEnabled(); ui->comp_Led->setOn(updater); + + // avoid unnecessary roundtrips + const CModelSettings ms = m_modelSettings.get(); + if (ui->cb_AllowExcludeModels->isChecked() != ms.getAllowExcludedModels()) + { + ui->cb_AllowExcludeModels->setChecked(ms.getAllowExcludedModels()); + } } } // ns } // ns diff --git a/src/blackgui/components/settingsmodelcomponent.h b/src/blackgui/components/settingsmodelcomponent.h index 2f4912cb8..12a8b1ad5 100644 --- a/src/blackgui/components/settingsmodelcomponent.h +++ b/src/blackgui/components/settingsmodelcomponent.h @@ -13,6 +13,7 @@ #define BLACKGUI_COMPONENTS_SETTINGSMODELCOMPONENT_H #include "blackgui/settings/guisettings.h" +#include "blackmisc/simulation/settings/modelsettings.h" #include namespace Ui { class CSettingsModelComponent; } @@ -43,12 +44,16 @@ namespace BlackGui private: QScopedPointer ui; - BlackMisc::CSetting m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time + BlackMisc::CSetting m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time + BlackMisc::CSetting m_modelSettings { this, &CSettingsModelComponent::cacheChanged }; //!< model setting const BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr; //!< externally (i.e. other component) provided existing updater //! Consolidation time entered void consolidationEntered(); + //! Allow excluded models changed + void allowExcludedModelsChanged(bool allow); + //! Cache has been changed void cacheChanged(); }; diff --git a/src/blackgui/components/settingsmodelcomponent.ui b/src/blackgui/components/settingsmodelcomponent.ui index 1516ecb03..c3e47d8dc 100644 --- a/src/blackgui/components/settingsmodelcomponent.ui +++ b/src/blackgui/components/settingsmodelcomponent.ui @@ -2,6 +2,14 @@ CSettingsModelComponent + + + 0 + 0 + 390 + 28 + + Models settings @@ -24,7 +32,7 @@ Hint: This can cause wrong behaviour or violate 3rd parties copyright. You need to know what you are doing enabling the feature. - allow "exclude" models in set + allow "excluded" models in set