From 1060bb76056c89e4f13839160191a85879091f41 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 21 Jul 2020 08:54:39 +0200 Subject: [PATCH] ProjectExplorer: Add a BaseIntegerAspect::defaultValue If the actual value equals that, the value key will be removed from the settings. This is useful for the job count in the MakeStep. This might be usable in this or similar form also for the other types, but I'd rather wait for more use cases. Change-Id: Ic4865ca2d4dc61c778f6b8c4c307f7fcf4243e43 Reviewed-by: Christian Kandeler --- .../projectexplorer/projectconfigurationaspects.cpp | 13 +++++++++++-- .../projectexplorer/projectconfigurationaspects.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index 79ad3217441..c32bf2850f2 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -127,6 +127,7 @@ class BaseIntegerAspectPrivate { public: qint64 m_value = 0; + qint64 m_defaultValue = 0; QVariant m_minimumValue; QVariant m_maximumValue; int m_displayIntegerBase = 10; @@ -684,12 +685,15 @@ void BaseIntegerAspect::addToLayout(LayoutBuilder &builder) void BaseIntegerAspect::fromMap(const QVariantMap &map) { - d->m_value = map.value(settingsKey()).toLongLong(); + d->m_value = map.value(settingsKey(), d->m_defaultValue).toLongLong(); } void BaseIntegerAspect::toMap(QVariantMap &data) const { - data.insert(settingsKey(), d->m_value); + if (d->m_value != d->m_defaultValue) + data.insert(settingsKey(), d->m_value); + else + data.remove(settingsKey()); } qint64 BaseIntegerAspect::value() const @@ -746,6 +750,11 @@ void BaseIntegerAspect::setEnabled(bool enabled) d->m_spinBox->setEnabled(enabled); } +void BaseIntegerAspect::setDefaultValue(qint64 defaultValue) +{ + d->m_defaultValue = defaultValue; +} + BaseTriStateAspect::BaseTriStateAspect() { setDisplayStyle(DisplayStyle::ComboBox); diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index aadaeda6fa7..857169b5346 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -190,6 +190,7 @@ public: void setDisplayIntegerBase(int base); void setDisplayScaleFactor(qint64 factor); void setEnabled(bool enabled); + void setDefaultValue(qint64 defaultValue); void fromMap(const QVariantMap &map) override; void toMap(QVariantMap &map) const override;