Commit 79e48237 authored by Tobias Hunger's avatar Tobias Hunger

RunConfigurationAspect: Simplify cloneing

Change-Id: I21366f932e372c1c0fa8c9d29184e71d1c0cf4a4
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 2c9d93a3
...@@ -89,14 +89,6 @@ IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect ...@@ -89,14 +89,6 @@ IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect
return new AnalyzerRunConfigurationAspect; 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) RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{ {
AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget; AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget;
......
...@@ -51,7 +51,6 @@ public: ...@@ -51,7 +51,6 @@ public:
ProjectExplorer::RunMode mode, ProjectExplorer::RunMode mode,
QString *errorMessage); QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(); ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
ProjectExplorer::IRunConfigurationAspect *cloneRunConfigurationAspect(ProjectExplorer::IRunConfigurationAspect *source);
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
}; };
......
...@@ -54,7 +54,7 @@ AnalyzerSettings::AnalyzerSettings(QObject *parent) ...@@ -54,7 +54,7 @@ AnalyzerSettings::AnalyzerSettings(QObject *parent)
{ {
} }
AnalyzerSettings::AnalyzerSettings(AnalyzerSettings *other) AnalyzerSettings::AnalyzerSettings(const AnalyzerSettings *other)
{ {
Q_UNUSED(other); Q_UNUSED(other);
} }
...@@ -168,7 +168,7 @@ AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect() ...@@ -168,7 +168,7 @@ AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect()
resetCustomToGlobalSettings(); resetCustomToGlobalSettings();
} }
AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(AnalyzerRunConfigurationAspect *other) AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(const AnalyzerRunConfigurationAspect *other)
: AnalyzerSettings(other), m_useGlobalSettings(other->m_useGlobalSettings) : AnalyzerSettings(other), m_useGlobalSettings(other->m_useGlobalSettings)
{ {
...@@ -204,6 +204,13 @@ QVariantMap AnalyzerRunConfigurationAspect::toMap() const ...@@ -204,6 +204,13 @@ QVariantMap AnalyzerRunConfigurationAspect::toMap() const
return map; return map;
} }
AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone(
ProjectExplorer::RunConfiguration *parent) const
{
Q_UNUSED(parent)
return new AnalyzerRunConfigurationAspect(this);
}
void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value) void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value)
{ {
if (value == m_useGlobalSettings) if (value == m_useGlobalSettings)
......
...@@ -118,7 +118,7 @@ protected: ...@@ -118,7 +118,7 @@ protected:
void fromMap(const QVariantMap &map, QList<AbstractAnalyzerSubConfig *> *subConfigs); void fromMap(const QVariantMap &map, QList<AbstractAnalyzerSubConfig *> *subConfigs);
AnalyzerSettings(QObject *parent); AnalyzerSettings(QObject *parent);
AnalyzerSettings(AnalyzerSettings *other); AnalyzerSettings(const AnalyzerSettings *other);
QList<AbstractAnalyzerSubConfig *> m_subConfigs; QList<AbstractAnalyzerSubConfig *> m_subConfigs;
}; };
...@@ -167,11 +167,12 @@ class ANALYZER_EXPORT AnalyzerRunConfigurationAspect ...@@ -167,11 +167,12 @@ class ANALYZER_EXPORT AnalyzerRunConfigurationAspect
public: public:
AnalyzerRunConfigurationAspect(); AnalyzerRunConfigurationAspect();
AnalyzerRunConfigurationAspect(AnalyzerRunConfigurationAspect *other); AnalyzerRunConfigurationAspect(const AnalyzerRunConfigurationAspect *other);
~AnalyzerRunConfigurationAspect(); ~AnalyzerRunConfigurationAspect();
QString displayName() const; QString displayName() const;
virtual QVariantMap toMap() const; virtual QVariantMap toMap() const;
AnalyzerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
bool isUsingGlobalSettings() const { return m_useGlobalSettings; } bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
void setUsingGlobalSettings(bool value); void setUsingGlobalSettings(bool value);
......
...@@ -121,7 +121,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration ...@@ -121,7 +121,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration
{} {}
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration, DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration,
DebuggerRunConfigurationAspect *other) const DebuggerRunConfigurationAspect *other)
: m_runConfiguration(runConfiguration), : m_runConfiguration(runConfiguration),
m_useCppDebugger(other->m_useCppDebugger), m_useCppDebugger(other->m_useCppDebugger),
m_useQmlDebugger(other->m_useQmlDebugger), m_useQmlDebugger(other->m_useQmlDebugger),
...@@ -251,6 +251,11 @@ void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map) ...@@ -251,6 +251,11 @@ void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool(); m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool();
} }
DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::clone(RunConfiguration *parent) const
{
return new DebuggerRunConfigurationAspect(parent, this);
}
/*! /*!
\class ProjectExplorer::RunConfiguration \class ProjectExplorer::RunConfiguration
...@@ -276,17 +281,13 @@ RunConfiguration::RunConfiguration(Target *target, const Core::Id id) : ...@@ -276,17 +281,13 @@ RunConfiguration::RunConfiguration(Target *target, const Core::Id id) :
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) : RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
ProjectConfiguration(target, source), ProjectConfiguration(target, source),
m_debuggerAspect(new DebuggerRunConfigurationAspect(this, source->debuggerAspect())) m_debuggerAspect(source->debuggerAspect()->clone(this))
{ {
Q_ASSERT(target); Q_ASSERT(target);
QList<IRunControlFactory *> factories = ExtensionSystem::PluginManager::getObjects<IRunControlFactory>();
foreach (IRunConfigurationAspect *aspect, source->m_aspects) { foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
foreach (IRunControlFactory *factory, factories) { IRunConfigurationAspect *clone = aspect->clone(this);
if (IRunConfigurationAspect *clone = factory->cloneRunConfigurationAspect(aspect)) { if (clone)
m_aspects.append(clone); m_aspects.append(clone);
break;
}
}
} }
} }
...@@ -516,12 +517,6 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect() ...@@ -516,12 +517,6 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect()
return 0; return 0;
} }
IRunConfigurationAspect *IRunControlFactory::cloneRunConfigurationAspect(IRunConfigurationAspect *source)
{
Q_UNUSED(source);
return 0;
}
RunConfigWidget *IRunControlFactory::createConfigurationWidget(RunConfiguration *) RunConfigWidget *IRunControlFactory::createConfigurationWidget(RunConfiguration *)
{ {
return 0; return 0;
......
...@@ -77,6 +77,9 @@ public: ...@@ -77,6 +77,9 @@ public:
virtual ~IRunConfigurationAspect() {} virtual ~IRunConfigurationAspect() {}
virtual QVariantMap toMap() const = 0; virtual QVariantMap toMap() const = 0;
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *clone(RunConfiguration *parent) const = 0;
protected: protected:
friend class RunConfiguration; friend class RunConfiguration;
virtual void fromMap(const QVariantMap &map) = 0; virtual void fromMap(const QVariantMap &map) = 0;
...@@ -89,7 +92,8 @@ class PROJECTEXPLORER_EXPORT DebuggerRunConfigurationAspect ...@@ -89,7 +92,8 @@ class PROJECTEXPLORER_EXPORT DebuggerRunConfigurationAspect
public: public:
DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration); DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration);
DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration, DebuggerRunConfigurationAspect *other); DebuggerRunConfigurationAspect(RunConfiguration *runConfiguration,
const DebuggerRunConfigurationAspect *other);
enum QmlDebuggerStatus { enum QmlDebuggerStatus {
DisableQmlDebugger = 0, DisableQmlDebugger = 0,
...@@ -100,6 +104,8 @@ public: ...@@ -100,6 +104,8 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
void fromMap(const QVariantMap &map); void fromMap(const QVariantMap &map);
DebuggerRunConfigurationAspect *clone(RunConfiguration *parent) const;
QString displayName() const; QString displayName() const;
bool useCppDebugger() const; bool useCppDebugger() const;
...@@ -234,7 +240,6 @@ public: ...@@ -234,7 +240,6 @@ public:
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *createRunConfigurationAspect(); virtual IRunConfigurationAspect *createRunConfigurationAspect();
virtual IRunConfigurationAspect *cloneRunConfigurationAspect(IRunConfigurationAspect *);
virtual RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); virtual RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment