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 <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-07-21 08:54:39 +02:00
parent de7c57b051
commit 1060bb7605
2 changed files with 12 additions and 2 deletions

View File

@@ -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
{
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);

View File

@@ -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;