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
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;
......
......@@ -51,7 +51,6 @@ public:
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
ProjectExplorer::IRunConfigurationAspect *cloneRunConfigurationAspect(ProjectExplorer::IRunConfigurationAspect *source);
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
};
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
};
......
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