aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectconfigurationaspects.h
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-11-15 16:20:33 +0100
committerhjk <hjk@qt.io>2019-12-03 12:08:52 +0000
commitce434ccb5d2d28452cd2906b547dbb5f2086801c (patch)
tree710b57254cc7aafe6ee22e98dacc21bf878fbdd9 /src/plugins/projectexplorer/projectconfigurationaspects.h
parent3b9ce988651b53563fddbb3927d747f23b48b923 (diff)
ProjectExplorer: Use full class for TriState value
Allows more compact code on the user side in most cases and can hide the internal 'int-ness' from user code by wrapping Variant conversions in the TriState class itself. Change-Id: I4c91e0cd798ee988a0b9cb057749251a4efebaff Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projectconfigurationaspects.h')
-rw-r--r--src/plugins/projectexplorer/projectconfigurationaspects.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h
index 67d5a40e5c8..5d6977fa022 100644
--- a/src/plugins/projectexplorer/projectconfigurationaspects.h
+++ b/src/plugins/projectexplorer/projectconfigurationaspects.h
@@ -190,15 +190,36 @@ private:
std::unique_ptr<Internal::BaseIntegerAspectPrivate> d;
};
+class PROJECTEXPLORER_EXPORT TriState
+{
+ enum Value { EnabledValue, DisabledValue, DefaultValue };
+ explicit TriState(Value v) : m_value(v) {}
+
+public:
+ TriState() = default;
+
+ QVariant toVariant() const { return int(m_value); }
+ static TriState fromVariant(const QVariant &variant);
+
+ static const TriState Enabled;
+ static const TriState Disabled;
+ static const TriState Default;
+
+ friend bool operator==(TriState a, TriState b) { return a.m_value == b.m_value; }
+ friend bool operator!=(TriState a, TriState b) { return a.m_value != b.m_value; }
+
+private:
+ Value m_value = DefaultValue;
+};
+
class PROJECTEXPLORER_EXPORT BaseTriStateAspect : public BaseSelectionAspect
{
Q_OBJECT
public:
BaseTriStateAspect();
- enum class Value { Enabled, Disabled, Default };
- Value setting() const;
- void setSetting(Value setting);
+ TriState setting() const;
+ void setSetting(TriState setting);
};
} // namespace ProjectExplorer