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:
@@ -450,6 +450,25 @@ IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
QList<Core::Id> IRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return {};
|
||||
return Utils::transform(availableBuildTargets(parent, mode), [this](const QString &suffix) {
|
||||
return m_runConfigBaseId.withSuffix(suffix);
|
||||
});
|
||||
}
|
||||
|
||||
QString IRunConfigurationFactory::displayNameForId(Core::Id id) const
|
||||
{
|
||||
return displayNameForBuildTarget(id.suffixAfter(m_runConfigBaseId));
|
||||
}
|
||||
|
||||
QString IRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||
{
|
||||
return buildTarget;
|
||||
}
|
||||
|
||||
/*!
|
||||
Specifies a list of device types for which this RunConfigurationFactory
|
||||
can create RunConfiguration.
|
||||
@@ -477,6 +496,20 @@ bool IRunConfigurationFactory::canHandle(Target *target) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canCreateHelper(Target *, const QString &) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
if (!id.name().startsWith(m_runConfigBaseId.name()))
|
||||
return false;
|
||||
return canCreateHelper(parent, id.suffixAfter(m_runConfigBaseId));
|
||||
}
|
||||
|
||||
RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
@@ -489,6 +522,21 @@ RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canCloneHelper(Target *, RunConfiguration *) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
const Core::Id id = product->id();
|
||||
if (!id.name().startsWith(m_runConfigBaseId.name()))
|
||||
return false;
|
||||
return canCloneHelper(parent, product);
|
||||
}
|
||||
|
||||
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
@@ -504,6 +552,14 @@ RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVaria
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
const Core::Id id = idFromMap(map);
|
||||
return id.name().startsWith(m_runConfigBaseId.name());
|
||||
}
|
||||
|
||||
RunConfiguration *IRunConfigurationFactory::clone(Target *parent, RunConfiguration *product)
|
||||
{
|
||||
QTC_ASSERT(m_creator, return nullptr);
|
||||
|
||||
Reference in New Issue
Block a user