forked from qt-creator/qt-creator
ProjectExplorer: Register createes' base id in RunConfigurationFactory
This shifts the resposibility of creation/splitting of RunConfiguration ids into what are essentially "type ids" and "build targets" to the base implementation, possibly opening the path of abandoning the mangled ids in favor of explicitly storing their constituent parts. Take advantage of base id split in RunConfigurations for availableIds /displayNameForId and for canCreate/canRestore/canClone. Change-Id: I19fefb32757407ab5053a2ae0e5a79438659f6ec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com>
This commit is contained in:
@@ -232,57 +232,18 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
|
||||
IRunConfigurationFactory(parent)
|
||||
{
|
||||
setObjectName("CMakeRunConfigurationFactory");
|
||||
registerRunConfiguration<CMakeRunConfiguration>();
|
||||
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RC_PREFIX);
|
||||
setSupportedProjectType<CMakeProject>();
|
||||
}
|
||||
|
||||
// used to show the list of possible additons to a project, returns a list of ids
|
||||
QList<Core::Id> CMakeRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
||||
QList<QString> CMakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
||||
{
|
||||
Q_UNUSED(mode)
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
||||
QList<Core::Id> allIds;
|
||||
foreach (const QString &buildTarget, project->buildTargetTitles(true))
|
||||
allIds << idFromBuildTarget(buildTarget);
|
||||
return allIds;
|
||||
return project->buildTargetTitles(true);
|
||||
}
|
||||
|
||||
// used to translate the ids to names to display to the user
|
||||
QString CMakeRunConfigurationFactory::displayNameForId(Core::Id id) const
|
||||
bool CMakeRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||
{
|
||||
return buildTargetFromId(id);
|
||||
}
|
||||
|
||||
bool CMakeRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
||||
return project->hasBuildTarget(buildTargetFromId(id));
|
||||
}
|
||||
|
||||
bool CMakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return source->id().name().startsWith(CMAKE_RC_PREFIX);
|
||||
}
|
||||
|
||||
bool CMakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
if (!qobject_cast<CMakeProject *>(parent->project()))
|
||||
return false;
|
||||
return idFromMap(map).name().startsWith(CMAKE_RC_PREFIX);
|
||||
}
|
||||
|
||||
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
|
||||
{
|
||||
return id.suffixAfter(CMAKE_RC_PREFIX);
|
||||
}
|
||||
|
||||
Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target)
|
||||
{
|
||||
return Core::Id(CMAKE_RC_PREFIX).withSuffix(target);
|
||||
return project->hasBuildTarget(buildTarget);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user