ProjectExplorer: Split IRunConfigurationAspect

... into items that can be used generically in project configurations
(ProjectConfigurationAspect) and items that have a choice between
global and project settings (GlobalOrProjectAspect)

Change-Id: I94831237bdbb18c339eb76eba131bf7f928933d6
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2018-09-13 15:48:16 +02:00
parent d9275913d3
commit d421bc2fe3
19 changed files with 174 additions and 154 deletions

View File

@@ -25,6 +25,7 @@
#include "projectconfiguration.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
@@ -33,6 +34,26 @@ const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
// ProjectConfigurationAspect
ProjectConfigurationAspect::ProjectConfigurationAspect() = default;
ProjectConfigurationAspect::~ProjectConfigurationAspect() = default;
void ProjectConfigurationAspect::setConfigWidgetCreator
(const ConfigWidgetCreator &configWidgetCreator)
{
m_configWidgetCreator = configWidgetCreator;
}
QWidget *ProjectConfigurationAspect::createConfigWidget() const
{
return m_configWidgetCreator ? m_configWidgetCreator() : nullptr;
}
// ProjectConfiguration
ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
: QObject(parent), m_id(id)
{
@@ -40,6 +61,11 @@ ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
setObjectName(id.toString());
}
ProjectConfiguration::~ProjectConfiguration()
{
qDeleteAll(m_aspects);
}
Core::Id ProjectConfiguration::id() const
{
return m_id;
@@ -103,6 +129,10 @@ QVariantMap ProjectConfiguration::toMap() const
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.toSetting());
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
for (const auto &aspect : m_aspects)
aspect->toMap(map);
return map;
}
@@ -117,14 +147,25 @@ bool ProjectConfiguration::fromMap(const QVariantMap &map)
m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY),
m_defaultDisplayName.isEmpty() ?
m_displayName : m_defaultDisplayName).toString();
for (const auto &aspect : qAsConst(m_aspects))
aspect->fromMap(map);
return true;
}
ProjectConfigurationAspect *ProjectConfiguration::extraAspect(Core::Id id) const
{
return Utils::findOrDefault(m_aspects, Utils::equal(&ProjectConfigurationAspect::id, id));
}
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;