Commit 1650c22b authored by Tobias Hunger's avatar Tobias Hunger

RunConfigurationAspect: Add RunConfiguration parameter to factory method

Change-Id: I7fbb82dc3ff83593473a57c69d0eb89bc33f50f5
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 5d4c4a69
......@@ -81,8 +81,9 @@ RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration
return rc;
}
IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect()
IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
{
Q_UNUSED(rc);
return new AnalyzerRunConfigurationAspect;
}
......
......@@ -49,8 +49,8 @@ public:
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc);
ProjectExplorer::RunConfigWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
};
......
......@@ -102,10 +102,8 @@ QString AndroidRunConfigurationFactory::displayNameForId(const Core::Id id) cons
return QFileInfo(pathFromId(id)).completeBaseName();
}
RunConfiguration *AndroidRunConfigurationFactory::create(Target *parent, const Core::Id id)
RunConfiguration *AndroidRunConfigurationFactory::doCreate(Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
return new AndroidRunConfiguration(parent, id, pathFromId(id));
}
......
......@@ -54,7 +54,6 @@ public:
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
......@@ -65,6 +64,11 @@ public:
bool canHandle(ProjectExplorer::Target *t) const;
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
ProjectExplorer::Node *n);
private:
bool canHandle(ProjectExplorer::Target *t) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
class AndroidRunControlFactory : public ProjectExplorer::IRunControlFactory
......
......@@ -513,11 +513,9 @@ bool CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, co
return project->hasBuildTarget(buildTargetFromId(id));
}
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::create(ProjectExplorer::Target *parent,
const Core::Id id)
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent,
const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
const QString title(buildTargetFromId(id));
const CMakeBuildTarget &ct = project->buildTargetForTitle(title);
......
......@@ -162,7 +162,6 @@ public:
~CMakeRunConfigurationFactory();
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const;
......@@ -176,6 +175,8 @@ public:
private:
bool canHandle(ProjectExplorer::Target *parent) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
}
......
......@@ -132,10 +132,8 @@ QString MaemoRunConfigurationFactory::displayNameForId(const Core::Id id) const
+ QLatin1String(" (on remote Maemo device)");
}
RunConfiguration *MaemoRunConfigurationFactory::create(Target *parent, const Core::Id id)
RunConfiguration *MaemoRunConfigurationFactory::doCreate(Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
return new MaemoRunConfiguration(parent, id, pathFromId(id));
}
......
......@@ -59,7 +59,6 @@ public:
QList<Core::Id> availableCreationIds(Target *parent) const;
bool canCreate(Target *parent, const Core::Id id) const;
RunConfiguration *create(Target *parent, const Core::Id id);
bool canRestore(Target *parent, const QVariantMap &map) const;
RunConfiguration *restore(Target *parent, const QVariantMap &map);
......@@ -70,6 +69,9 @@ public:
bool canHandle(ProjectExplorer::Target *t) const;
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
ProjectExplorer::Node *n);
private:
RunConfiguration *doCreate(Target *parent, const Core::Id id);
};
class MaemoRunControlFactory : public IRunControlFactory
......
......@@ -37,7 +37,6 @@
#include "kitinformation.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <utils/outputformatter.h>
#include <utils/checkablemessagebox.h>
......@@ -273,15 +272,16 @@ DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::clone(RunConfigu
RunConfiguration::RunConfiguration(Target *target, const Core::Id id) :
ProjectConfiguration(target, id),
m_debuggerAspect(new DebuggerRunConfigurationAspect(this))
m_debuggerAspect(new DebuggerRunConfigurationAspect(this)),
m_aspectsInitialized(false)
{
Q_ASSERT(target);
addExtraAspects();
}
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
ProjectConfiguration(target, source),
m_debuggerAspect(source->debuggerAspect()->clone(this))
m_debuggerAspect(source->debuggerAspect()->clone(this)),
m_aspectsInitialized(true)
{
Q_ASSERT(target);
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
......@@ -299,9 +299,13 @@ RunConfiguration::~RunConfiguration()
void RunConfiguration::addExtraAspects()
{
if (m_aspectsInitialized)
return;
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
if (IRunConfigurationAspect *aspect = factory->createRunConfigurationAspect())
if (IRunConfigurationAspect *aspect = factory->createRunConfigurationAspect(this))
m_aspects.append(aspect);
m_aspectsInitialized = true;
}
/*!
......@@ -376,6 +380,7 @@ ProjectExplorer::Abi RunConfiguration::abi() const
bool RunConfiguration::fromMap(const QVariantMap &map)
{
addExtraAspects();
m_debuggerAspect->fromMap(map);
foreach (IRunConfigurationAspect *aspect, m_aspects)
......@@ -402,6 +407,7 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
{
QTC_ASSERT(m_aspectsInitialized, return QList<IRunConfigurationAspect *>());
return m_aspects;
}
......@@ -445,6 +451,17 @@ IRunConfigurationFactory::~IRunConfigurationFactory()
{
}
RunConfiguration *IRunConfigurationFactory::create(Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
RunConfiguration *rc = doCreate(parent, id);
if (!rc)
return 0;
rc->addExtraAspects();
return rc;
}
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
{
QList<IRunConfigurationFactory *> factories
......@@ -512,8 +529,9 @@ IRunControlFactory::~IRunControlFactory()
{
}
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect()
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
{
Q_UNUSED(rc);
return 0;
}
......
......@@ -35,6 +35,7 @@
#include "projectexplorerconstants.h"
#include <utils/outputformat.h>
#include <utils/qtcassert.h>
#include <QPointer>
#include <QWidget>
......@@ -170,6 +171,7 @@ public:
QList<IRunConfigurationAspect *> extraAspects() const;
template <typename T> T *extraAspect() const
{
QTC_ASSERT(m_aspectsInitialized, return 0);
IRunConfigurationAspect *typeCheck = static_cast<T *>(0);
Q_UNUSED(typeCheck);
T *result = 0;
......@@ -182,6 +184,8 @@ public:
virtual ProjectExplorer::Abi abi() const;
void addExtraAspects();
signals:
void enabledChanged();
......@@ -193,10 +197,9 @@ protected:
BuildConfiguration *activeBuildConfiguration() const;
private:
void addExtraAspects();
QList<IRunConfigurationAspect *> m_aspects;
DebuggerRunConfigurationAspect *m_debuggerAspect;
bool m_aspectsInitialized;
};
class PROJECTEXPLORER_EXPORT IRunConfigurationFactory : public QObject
......@@ -211,7 +214,7 @@ public:
virtual QString displayNameForId(const Core::Id id) const = 0;
virtual bool canCreate(Target *parent, const Core::Id id) const = 0;
virtual RunConfiguration *create(Target *parent, const Core::Id id) = 0;
RunConfiguration *create(Target *parent, const Core::Id id);
virtual bool canRestore(Target *parent, const QVariantMap &map) const = 0;
virtual RunConfiguration *restore(Target *parent, const QVariantMap &map) = 0;
virtual bool canClone(Target *parent, RunConfiguration *product) const = 0;
......@@ -223,6 +226,9 @@ public:
signals:
void availableCreationIdsChanged();
private:
virtual RunConfiguration *doCreate(Target *parent, const Core::Id id) = 0;
};
class RunConfigWidget;
......@@ -239,7 +245,7 @@ public:
virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *createRunConfigurationAspect();
virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc);
virtual RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
};
......
......@@ -400,6 +400,7 @@ void Target::addRunConfiguration(RunConfiguration* runConfiguration)
{
QTC_ASSERT(runConfiguration && !d->m_runConfigurations.contains(runConfiguration), return);
Q_ASSERT(runConfiguration->target() == this);
runConfiguration->addExtraAspects();
// Check that we don't have a configuration with the same displayName
QString configurationDisplayName = runConfiguration->displayName();
......
......@@ -110,10 +110,8 @@ bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *paren
return false;
}
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
return new QmlProjectRunConfiguration(parent, id);
}
......
......@@ -47,7 +47,6 @@ public:
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
......@@ -55,6 +54,8 @@ public:
private:
bool canHandle(ProjectExplorer::Target *parent) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
} // namespace Internal
......
......@@ -95,12 +95,9 @@ bool BlackBerryRunConfigurationFactory::canCreate(ProjectExplorer::Target *paren
return qt4Project->hasApplicationProFile(pathFromId(id));
}
ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::create(ProjectExplorer::Target *parent,
ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent,
const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
return new BlackBerryRunConfiguration(parent, id, pathFromId(id));
}
......
......@@ -47,7 +47,7 @@ public:
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent,
......
......@@ -82,7 +82,7 @@ QString QnxRunConfigurationFactory::displayNameForId(const Core::Id id) const
bool QnxRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
{
if (!canHandle(parent))
if (!canHandle(parent) || id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
return false;
Qt4ProjectManager::Qt4Project *qt4Project = qobject_cast<Qt4ProjectManager::Qt4Project *>(parent->project());
......@@ -92,15 +92,9 @@ bool QnxRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, cons
return qt4Project->hasApplicationProFile(pathFromId(id));
}
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
if (id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
return new QnxRunConfiguration(parent, id, pathFromId(id));
return 0;
return new QnxRunConfiguration(parent, id, pathFromId(id));
}
bool QnxRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
......
......@@ -47,7 +47,6 @@ public:
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent,
......@@ -57,7 +56,10 @@ public:
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::RunConfiguration *source);
private:
bool canHandle(ProjectExplorer::Target *t) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
} // namespace Internal
......
......@@ -735,11 +735,8 @@ bool Qt4RunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, cons
return project->hasApplicationProFile(pathFromId(id));
}
ProjectExplorer::RunConfiguration *Qt4RunConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
ProjectExplorer::RunConfiguration *Qt4RunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
Qt4RunConfiguration *rc = new Qt4RunConfiguration(parent, id);
QList<Qt4ProFileNode *> profiles = static_cast<Qt4Project *>(parent->project())->applicationProFiles();
foreach (Qt4ProFileNode *node, profiles) {
......
......@@ -213,7 +213,6 @@ public:
~Qt4RunConfigurationFactory();
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
......@@ -225,6 +224,9 @@ public:
bool canHandle(ProjectExplorer::Target *t) const;
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
ProjectExplorer::Node *n);
private:
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
} // namespace Internal
......
......@@ -400,11 +400,9 @@ bool CustomExecutableRunConfigurationFactory::canCreate(ProjectExplorer::Target
}
ProjectExplorer::RunConfiguration *
CustomExecutableRunConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
CustomExecutableRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
Q_UNUSED(id);
return new CustomExecutableRunConfiguration(parent);
}
......
......@@ -138,7 +138,6 @@ public:
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const;
......@@ -147,6 +146,8 @@ public:
private:
bool canHandle(ProjectExplorer::Target *parent) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
} // namespace QtSupport
......
......@@ -105,9 +105,8 @@ QString RemoteLinuxRunConfigurationFactory::displayNameForId(const Core::Id id)
+ tr(" (on Remote Generic Linux Host)");
}
RunConfiguration *RemoteLinuxRunConfigurationFactory::create(Target *parent, const Core::Id id)
RunConfiguration *RemoteLinuxRunConfigurationFactory::doCreate(Target *parent, const Core::Id id)
{
QTC_ASSERT(canCreate(parent, id), return 0);
return new RemoteLinuxRunConfiguration(parent, id, pathFromId(id));
}
......
......@@ -46,7 +46,6 @@ public:
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent,
......@@ -58,6 +57,8 @@ public:
private:
bool canHandle(const ProjectExplorer::Target *target) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
};
} // namespace Internal
......
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