From 2430168322f9046372fb92ecd177f5b6809d5eb1 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 3 Apr 2019 18:43:28 +0200 Subject: [PATCH] ProjectExplorer: Merge StatefulProjectConfiguration into RunConfiguration It's the only user, and single inheritance for feature reuse is an antipattern. Change-Id: I975861d111cec67fb2dbf94e38bd824d18a0c8d0 Reviewed-by: Christian Kandeler --- .../projectexplorer/projectconfiguration.cpp | 19 --------------- .../projectexplorer/projectconfiguration.h | 23 ------------------- .../projectexplorer/runconfiguration.cpp | 10 +++++++- .../projectexplorer/runconfiguration.h | 9 ++++++-- 4 files changed, 16 insertions(+), 45 deletions(-) diff --git a/src/plugins/projectexplorer/projectconfiguration.cpp b/src/plugins/projectexplorer/projectconfiguration.cpp index d51084f1eda..73c715f0724 100644 --- a/src/plugins/projectexplorer/projectconfiguration.cpp +++ b/src/plugins/projectexplorer/projectconfiguration.cpp @@ -185,22 +185,3 @@ Core::Id ProjectExplorer::idFromMap(const QVariantMap &map) { return Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY))); } - -// StatefulProjectConfiguration - -bool StatefulProjectConfiguration::isEnabled() const -{ - return m_isEnabled; -} - -StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent, Core::Id id) : - ProjectConfiguration(parent, id) -{ } - -void StatefulProjectConfiguration::setEnabled(bool enabled) -{ - if (enabled == m_isEnabled) - return; - m_isEnabled = enabled; - emit enabledChanged(); -} diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index 685661d4827..5e6952a1fb0 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -183,29 +183,6 @@ private: Utils::MacroExpander m_macroExpander; }; -class PROJECTEXPLORER_EXPORT StatefulProjectConfiguration : public ProjectConfiguration -{ - Q_OBJECT - -public: - StatefulProjectConfiguration() = default; - - bool isEnabled() const; - - virtual QString disabledReason() const = 0; - -signals: - void enabledChanged(); - -protected: - StatefulProjectConfiguration(QObject *parent, Core::Id id); - - void setEnabled(bool enabled); - -private: - bool m_isEnabled = false; -}; - // helper function: PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 18442dbfaaf..e74e8e78fa7 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -158,7 +158,7 @@ void GlobalOrProjectAspect::resetProjectToGlobalSettings() static std::vector theAspectFactories; RunConfiguration::RunConfiguration(Target *target, Core::Id id) - : StatefulProjectConfiguration(target, id) + : ProjectConfiguration(target, id) { connect(target->project(), &Project::parsingStarted, this, [this]() { updateEnabledState(); }); @@ -201,6 +201,14 @@ bool RunConfiguration::isActive() const return target()->isActive() && target()->activeRunConfiguration() == this; } +void RunConfiguration::setEnabled(bool enabled) +{ + if (enabled == m_isEnabled) + return; + m_isEnabled = enabled; + emit enabledChanged(); +} + QString RunConfiguration::disabledReason() const { if (!target()->hasBuildTarget(m_buildKey)) diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index c54b64ad96e..a1a8440ee69 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -130,7 +130,7 @@ private: }; // Documentation inside. -class PROJECTEXPLORER_EXPORT RunConfiguration : public StatefulProjectConfiguration +class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration { Q_OBJECT @@ -139,7 +139,10 @@ public: bool isActive() const override; - QString disabledReason() const override; + bool isEnabled() const { return m_isEnabled; } + void setEnabled(bool enabled); + + virtual QString disabledReason() const; virtual QWidget *createConfigurationWidget(); @@ -183,6 +186,7 @@ public: signals: void requestRunActionsUpdate(); void configurationFinished(); + void enabledChanged(); protected: RunConfiguration(Target *target, Core::Id id); @@ -204,6 +208,7 @@ private: friend class RunConfigurationCreationInfo; QString m_buildKey; + bool m_isEnabled = false; std::function m_outputFormatterCreator; };