forked from qt-creator/qt-creator
RunConfigurationFactory: Centralize much of the restore code
Change-Id: I30c92dd5082eed050c2796a014919788710baafa Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -107,18 +107,11 @@ RunConfiguration *AndroidRunConfigurationFactory::doCreate(Target *parent, const
|
||||
return new AndroidRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *AndroidRunConfigurationFactory::restore(Target *parent,
|
||||
RunConfiguration *AndroidRunConfigurationFactory::doRestore(Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
Core::Id id = ProjectExplorer::idFromMap(map);
|
||||
AndroidRunConfiguration *rc = new AndroidRunConfiguration(parent, id, pathFromId(id));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
return new AndroidRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *AndroidRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
||||
|
@@ -56,12 +56,10 @@ public:
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
ProjectExplorer::Node *n);
|
||||
|
||||
@@ -69,6 +67,8 @@ private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
class AndroidRunControlFactory : public ProjectExplorer::IRunControlFactory
|
||||
|
@@ -544,16 +544,11 @@ bool CMakeRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, c
|
||||
return ProjectExplorer::idFromMap(map).name().startsWith(CMAKE_RC_PREFIX);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
CMakeRunConfiguration *rc(new CMakeRunConfiguration(parent, ProjectExplorer::idFromMap(map),
|
||||
QString(), QString(), QString()));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
return 0;
|
||||
return new CMakeRunConfiguration(parent, ProjectExplorer::idFromMap(map),
|
||||
QString(), QString(), QString());
|
||||
}
|
||||
|
||||
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
|
||||
|
@@ -163,7 +163,6 @@ public:
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product);
|
||||
|
||||
@@ -177,6 +176,8 @@ private:
|
||||
bool canHandle(ProjectExplorer::Target *parent) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -137,20 +137,11 @@ RunConfiguration *MaemoRunConfigurationFactory::doCreate(Target *parent, const C
|
||||
return new MaemoRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *MaemoRunConfigurationFactory::restore(Target *parent,
|
||||
RunConfiguration *MaemoRunConfigurationFactory::doRestore(Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
|
||||
Core::Id id = ProjectExplorer::idFromMap(map);
|
||||
MaemoRunConfiguration *rc
|
||||
= new MaemoRunConfiguration(parent, id, pathFromId(id));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
return new MaemoRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
||||
|
@@ -61,17 +61,18 @@ public:
|
||||
bool canCreate(Target *parent, const Core::Id id) const;
|
||||
|
||||
bool canRestore(Target *parent, const QVariantMap &map) const;
|
||||
RunConfiguration *restore(Target *parent, const QVariantMap &map);
|
||||
|
||||
bool canClone(Target *parent, RunConfiguration *source) const;
|
||||
RunConfiguration *clone(Target *parent, RunConfiguration *source);
|
||||
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
ProjectExplorer::Node *n);
|
||||
|
||||
private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
RunConfiguration *doCreate(Target *parent, const Core::Id id);
|
||||
RunConfiguration *doRestore(Target *parent, const QVariantMap &map);
|
||||
};
|
||||
|
||||
class MaemoRunControlFactory : public IRunControlFactory
|
||||
|
@@ -462,6 +462,18 @@ RunConfiguration *IRunConfigurationFactory::create(Target *parent, const Core::I
|
||||
return rc;
|
||||
}
|
||||
|
||||
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
RunConfiguration *rc = doRestore(parent, map);
|
||||
if (!rc->fromMap(map)) {
|
||||
delete rc;
|
||||
rc = 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
QList<IRunConfigurationFactory *> factories
|
||||
|
@@ -216,7 +216,7 @@ public:
|
||||
virtual bool canCreate(Target *parent, const Core::Id id) const = 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;
|
||||
RunConfiguration *restore(Target *parent, const QVariantMap &map);
|
||||
virtual bool canClone(Target *parent, RunConfiguration *product) const = 0;
|
||||
virtual RunConfiguration *clone(Target *parent, RunConfiguration *product) = 0;
|
||||
|
||||
@@ -229,6 +229,7 @@ signals:
|
||||
|
||||
private:
|
||||
virtual RunConfiguration *doCreate(Target *parent, const Core::Id id) = 0;
|
||||
virtual RunConfiguration *doRestore(Target *parent, const QVariantMap &map) = 0;
|
||||
};
|
||||
|
||||
class RunConfigWidget;
|
||||
|
@@ -120,17 +120,10 @@ bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *pare
|
||||
return parent && canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
|
||||
Core::Id id = ProjectExplorer::idFromMap(map);
|
||||
QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(parent, id);
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
return 0;
|
||||
return new QmlProjectRunConfiguration(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
bool QmlProjectRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
||||
|
@@ -48,7 +48,6 @@ public:
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
@@ -56,6 +55,8 @@ private:
|
||||
bool canHandle(ProjectExplorer::Target *parent) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -110,20 +110,12 @@ bool BlackBerryRunConfigurationFactory::canRestore(ProjectExplorer::Target *pare
|
||||
return ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::restore(
|
||||
ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::doRestore(
|
||||
ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
|
||||
ProjectExplorer::RunConfiguration *rc = 0;
|
||||
rc = new BlackBerryRunConfiguration(parent, Core::Id(Constants::QNX_BB_RUNCONFIGURATION_PREFIX), QString());
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
Q_UNUSED(map);
|
||||
return new BlackBerryRunConfiguration(parent, Core::Id(Constants::QNX_BB_RUNCONFIGURATION_PREFIX), QString());
|
||||
}
|
||||
|
||||
bool BlackBerryRunConfigurationFactory::canClone(ProjectExplorer::Target *parent,
|
||||
|
@@ -50,14 +50,16 @@ public:
|
||||
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,
|
||||
const QVariantMap &map);
|
||||
|
||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
|
||||
ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -103,18 +103,11 @@ bool QnxRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, con
|
||||
&& ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
|
||||
ProjectExplorer::RunConfiguration *rc = 0;
|
||||
rc = new QnxRunConfiguration(parent, Core::Id(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX), QString());
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
Q_UNUSED(map);
|
||||
return new QnxRunConfiguration(parent, Core::Id(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX), QString());
|
||||
}
|
||||
|
||||
bool QnxRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
||||
|
@@ -49,8 +49,6 @@ public:
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
|
||||
@@ -60,6 +58,8 @@ private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -757,16 +757,10 @@ bool Qt4RunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, con
|
||||
return ProjectExplorer::idFromMap(map).toString().startsWith(QLatin1String(QT4_RC_PREFIX));
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *Qt4RunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
ProjectExplorer::RunConfiguration *Qt4RunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
Qt4RunConfiguration *rc = new Qt4RunConfiguration(parent, ProjectExplorer::idFromMap(map));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
return new Qt4RunConfiguration(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
bool Qt4RunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
||||
|
@@ -214,19 +214,21 @@ public:
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
|
||||
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);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -416,15 +416,10 @@ bool CustomExecutableRunConfigurationFactory::canRestore(ProjectExplorer::Target
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfiguration *
|
||||
CustomExecutableRunConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
CustomExecutableRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
CustomExecutableRunConfiguration *rc(new CustomExecutableRunConfiguration(parent));
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
delete rc;
|
||||
return 0;
|
||||
Q_UNUSED(map);
|
||||
return new CustomExecutableRunConfiguration(parent);
|
||||
}
|
||||
|
||||
bool CustomExecutableRunConfigurationFactory::canClone(ProjectExplorer::Target *parent,
|
||||
|
@@ -139,7 +139,6 @@ public:
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
|
||||
ProjectExplorer::RunConfiguration *source);
|
||||
@@ -148,6 +147,8 @@ private:
|
||||
bool canHandle(ProjectExplorer::Target *parent) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace QtSupport
|
||||
|
@@ -110,17 +110,12 @@ RunConfiguration *RemoteLinuxRunConfigurationFactory::doCreate(Target *parent, c
|
||||
return new RemoteLinuxRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *RemoteLinuxRunConfigurationFactory::restore(Target *parent,
|
||||
RunConfiguration *RemoteLinuxRunConfigurationFactory::doRestore(Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
QTC_ASSERT(canRestore(parent, map), return 0);
|
||||
RemoteLinuxRunConfiguration *rc = new RemoteLinuxRunConfiguration(parent,
|
||||
Q_UNUSED(map);
|
||||
return new RemoteLinuxRunConfiguration(parent,
|
||||
Core::Id(RemoteLinuxRunConfiguration::IdPrefix), QString());
|
||||
if (rc->fromMap(map))
|
||||
return rc;
|
||||
|
||||
delete rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
RunConfiguration *RemoteLinuxRunConfigurationFactory::clone(Target *parent,
|
||||
|
@@ -48,8 +48,6 @@ public:
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
|
||||
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;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
|
||||
@@ -59,6 +57,8 @@ private:
|
||||
bool canHandle(const ProjectExplorer::Target *target) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user