forked from qt-creator/qt-creator
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 <christian.kandeler@qt.io>
This commit is contained in:
@@ -185,22 +185,3 @@ Core::Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
|||||||
{
|
{
|
||||||
return Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY)));
|
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();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -183,29 +183,6 @@ private:
|
|||||||
Utils::MacroExpander m_macroExpander;
|
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:
|
// helper function:
|
||||||
PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map);
|
PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map);
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ void GlobalOrProjectAspect::resetProjectToGlobalSettings()
|
|||||||
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
||||||
: StatefulProjectConfiguration(target, id)
|
: ProjectConfiguration(target, id)
|
||||||
{
|
{
|
||||||
connect(target->project(), &Project::parsingStarted,
|
connect(target->project(), &Project::parsingStarted,
|
||||||
this, [this]() { updateEnabledState(); });
|
this, [this]() { updateEnabledState(); });
|
||||||
@@ -201,6 +201,14 @@ bool RunConfiguration::isActive() const
|
|||||||
return target()->isActive() && target()->activeRunConfiguration() == this;
|
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
|
QString RunConfiguration::disabledReason() const
|
||||||
{
|
{
|
||||||
if (!target()->hasBuildTarget(m_buildKey))
|
if (!target()->hasBuildTarget(m_buildKey))
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
class PROJECTEXPLORER_EXPORT RunConfiguration : public StatefulProjectConfiguration
|
class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -139,7 +139,10 @@ public:
|
|||||||
|
|
||||||
bool isActive() const override;
|
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();
|
virtual QWidget *createConfigurationWidget();
|
||||||
|
|
||||||
@@ -183,6 +186,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void requestRunActionsUpdate();
|
void requestRunActionsUpdate();
|
||||||
void configurationFinished();
|
void configurationFinished();
|
||||||
|
void enabledChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RunConfiguration(Target *target, Core::Id id);
|
RunConfiguration(Target *target, Core::Id id);
|
||||||
@@ -204,6 +208,7 @@ private:
|
|||||||
friend class RunConfigurationCreationInfo;
|
friend class RunConfigurationCreationInfo;
|
||||||
|
|
||||||
QString m_buildKey;
|
QString m_buildKey;
|
||||||
|
bool m_isEnabled = false;
|
||||||
std::function<Utils::OutputFormatter *(Project *)> m_outputFormatterCreator;
|
std::function<Utils::OutputFormatter *(Project *)> m_outputFormatterCreator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user