summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2013-03-22 15:18:52 +0100
committerTobias Hunger <tobias.hunger@digia.com>2013-03-28 12:44:06 +0100
commit79e48237d6f3ab2fb2068ae89726841834d74ccb (patch)
tree13175b7c5ef87ea98d5b952f221a7b65da127ab9 /src/plugins
parent2c9d93a328b4bfb9337f9e7badeb7f95dcac8d86 (diff)
downloadqt-creator-79e48237d6f3ab2fb2068ae89726841834d74ccb.tar.gz
RunConfigurationAspect: Simplify cloneing
Change-Id: I21366f932e372c1c0fa8c9d29184e71d1c0cf4a4 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/analyzerbase/analyzerruncontrolfactory.cpp8
-rw-r--r--src/plugins/analyzerbase/analyzerruncontrolfactory.h1
-rw-r--r--src/plugins/analyzerbase/analyzersettings.cpp11
-rw-r--r--src/plugins/analyzerbase/analyzersettings.h5
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp25
-rw-r--r--src/plugins/projectexplorer/runconfiguration.h9
6 files changed, 29 insertions, 30 deletions
diff --git a/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp
index 9ee6da8447..6cfce7bc9f 100644
--- a/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp
+++ b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp
@@ -89,14 +89,6 @@ IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect
return new AnalyzerRunConfigurationAspect;
}
-IRunConfigurationAspect *AnalyzerRunControlFactory::cloneRunConfigurationAspect(IRunConfigurationAspect *source)
-{
- AnalyzerRunConfigurationAspect *s = dynamic_cast<AnalyzerRunConfigurationAspect *>(source);
- if (!s)
- return 0;
- return new AnalyzerRunConfigurationAspect(s);
-}
-
RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget;
diff --git a/src/plugins/analyzerbase/analyzerruncontrolfactory.h b/src/plugins/analyzerbase/analyzerruncontrolfactory.h
index 880b6e3253..fb4293e43d 100644
--- a/src/plugins/analyzerbase/analyzerruncontrolfactory.h
+++ b/src/plugins/analyzerbase/analyzerruncontrolfactory.h
@@ -51,7 +51,6 @@ public:
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
- ProjectExplorer::IRunConfigurationAspect *cloneRunConfigurationAspect(ProjectExplorer::IRunConfigurationAspect *source);
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
};
diff --git a/src/plugins/analyzerbase/analyzersettings.cpp b/src/plugins/analyzerbase/analyzersettings.cpp
index 5bc1699619..7c0a2afca2 100644
--- a/src/plugins/analyzerbase/analyzersettings.cpp
+++ b/src/plugins/analyzerbase/analyzersettings.cpp
@@ -54,7 +54,7 @@ AnalyzerSettings::AnalyzerSettings(QObject *parent)
{
}
-AnalyzerSettings::AnalyzerSettings(AnalyzerSettings *other)
+AnalyzerSettings::AnalyzerSettings(const AnalyzerSettings *other)
{
Q_UNUSED(other);
}
@@ -168,7 +168,7 @@ AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect()
resetCustomToGlobalSettings();
}
-AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(AnalyzerRunConfigurationAspect *other)
+AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(const AnalyzerRunConfigurationAspect *other)
: AnalyzerSettings(other), m_useGlobalSettings(other->m_useGlobalSettings)
{
@@ -204,6 +204,13 @@ QVariantMap AnalyzerRunConfigurationAspect::toMap() const
return map;
}
+AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone(
+ ProjectExplorer::RunConfiguration *parent) const
+{
+ Q_UNUSED(parent)
+ return new AnalyzerRunConfigurationAspect(this);
+}
+
void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value)
{
if (value == m_useGlobalSettings)
diff --git a/src/plugins/analyzerbase/analyzersettings.h b/src/plugins/analyzerbase/analyzersettings.h
index 81503dfb08..910743dcae 100644
--- a/src/plugins/analyzerbase/analyzersettings.h
+++ b/src/plugins/analyzerbase/analyzersettings.h
@@ -118,7 +118,7 @@ protected:
void fromMap(const QVariantMap &map, QList<AbstractAnalyzerSubConfig *> *subConfigs);
AnalyzerSettings(QObject *parent);
- AnalyzerSettings(AnalyzerSettings *other);
+ AnalyzerSettings(const AnalyzerSettings *other);
QList<AbstractAnalyzerSubConfig *> m_subConfigs;
};
@@ -167,11 +167,12 @@ class ANALYZER_EXPORT AnalyzerRunConfigurationAspect
public:
AnalyzerRunConfigurationAspect();
- AnalyzerRunConfigurationAspect(AnalyzerRunConfigurationAspect *other);
+ AnalyzerRunConfigurationAspect(const AnalyzerRunConfigurationAspect *other);
~AnalyzerRunConfigurationAspect();
QString displayName() const;
virtual QVariantMap toMap() const;
+ AnalyzerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
void setUsingGlobalSettings(bool value);
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index 2179276e11..22e881a3ac 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -121,7 +121,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration
{}
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration,
- DebuggerRunConfigurationAspect *other)
+ const DebuggerRunConfigurationAspect *other)
: m_runConfiguration(runConfiguration),
m_useCppDebugger(other->m_useCppDebugger),
m_useQmlDebugger(other->m_useQmlDebugger),
@@ -251,6 +251,11 @@ void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool();
}
+DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::clone(RunConfiguration *parent) const
+{
+ return new DebuggerRunConfigurationAspect(parent, this);
+}
+
/*!
\class ProjectExplorer::RunConfiguration
@@ -276,17 +281,13 @@ RunConfiguration::RunConfiguration(Target *target, const Core::Id id) :
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
ProjectConfiguration(target, source),
- m_debuggerAspect(new DebuggerRunConfigurationAspect(this, source->debuggerAspect()))
+ m_debuggerAspect(source->debuggerAspect()->clone(this))
{
Q_ASSERT(target);
- QList<IRunControlFactory *> factories = ExtensionSystem::PluginManager::getObjects<IRunControlFactory>();
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
- foreach (IRunControlFactory *factory, factories) {
- if (IRunConfigurationAspect *clone = factory->cloneRunConfigurationAspect(aspect)) {
- m_aspects.append(clone);
- break;
- }
- }
+ IRunConfigurationAspect *clone = aspect->clone(this);
+ if (clone)
+ m_aspects.append(clone);
}
}
@@ -516,12 +517,6 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect()
return 0;
}
-IRunConfigurationAspect *IRunControlFactory::cloneRunConfigurationAspect(IRunConfigurationAspect *source)
-{
- Q_UNUSED(source);
- return 0;
-}
-
RunConfigWidget *IRunControlFactory::createConfigurationWidget(RunConfiguration *)
{
return 0;
diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h
index da4aab77f0..2cfa6fbf05 100644
--- a/src/plugins/projectexplorer/runconfiguration.h
+++ b/src/plugins/projectexplorer/runconfiguration.h
@@ -77,6 +77,9 @@ public:
virtual ~IRunConfigurationAspect() {}
virtual QVariantMap toMap() const = 0;
virtual QString displayName() const = 0;
+
+ virtual IRunConfigurationAspect *clone(RunConfiguration *parent) const = 0;
+
protected:
friend class RunConfiguration;
virtual void fromMap(const QVariantMap &map) = 0;
@@ -89,7 +92,8 @@ class PROJECTEXPLORER_EXPORT DebuggerRunConfigurationAspect
public:
DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration);
- DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration, DebuggerRunConfigurationAspect *other);
+ DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration,
+ const DebuggerRunConfigurationAspect *other);
enum QmlDebuggerStatus {
DisableQmlDebugger = 0,
@@ -100,6 +104,8 @@ public:
QVariantMap toMap() const;
void fromMap(const QVariantMap &map);
+ DebuggerRunConfigurationAspect *clone(RunConfiguration *parent) const;
+
QString displayName() const;
bool useCppDebugger() const;
@@ -234,7 +240,6 @@ public:
virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *createRunConfigurationAspect();
- virtual IRunConfigurationAspect *cloneRunConfigurationAspect(IRunConfigurationAspect *);
virtual RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
};