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.

This commit is contained in:
Klaus Basan
2017-09-19 00:57:04 +02:00
committed by Mathew Sutcliffe
parent 8b8bc9b994
commit 2f577b7209
3 changed files with 36 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
#include <QValidator>
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

View File

@@ -13,6 +13,7 @@
#define BLACKGUI_COMPONENTS_SETTINGSMODELCOMPONENT_H
#include "blackgui/settings/guisettings.h"
#include "blackmisc/simulation/settings/modelsettings.h"
#include <QFrame>
namespace Ui { class CSettingsModelComponent; }
@@ -43,12 +44,16 @@ namespace BlackGui
private:
QScopedPointer<Ui::CSettingsModelComponent> ui;
BlackMisc::CSetting<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time
BlackMisc::CSetting<Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModel> 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();
};

View File

@@ -2,6 +2,14 @@
<ui version="4.0">
<class>CSettingsModelComponent</class>
<widget class="QFrame" name="CSettingsModelComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>28</height>
</rect>
</property>
<property name="windowTitle">
<string>Models settings</string>
</property>
@@ -24,7 +32,7 @@
<string>Hint: This can cause wrong behaviour or violate 3rd parties copyright. You need to know what you are doing enabling the feature.</string>
</property>
<property name="text">
<string>allow &quot;exclude&quot; models in set</string>
<string>allow &quot;excluded&quot; models in set</string>
</property>
</widget>
</item>