forked from qt-creator/qt-creator
ProjectExplorer: Add a IRunConfigurationFactory::addFixedBuildTarget()
To be used for "special" build targets (Custom executables etc) that do not
depend on the project. This reduces user side boiler plate in a couple of
cases and is a bit clearer than the magic {QString()} result anyway.
Change-Id: I105b6ab952981143b2abf9b218fed30cee80b648
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -453,10 +453,26 @@ QList<RunConfigurationCreationInfo>
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return {};
|
||||
return Utils::transform(availableBuildTargets(parent, mode), [this](const QString &suffix) {
|
||||
return RunConfigurationCreationInfo{this, m_runConfigBaseId, suffix,
|
||||
this->displayNameForBuildTarget(suffix)};
|
||||
});
|
||||
|
||||
if (m_fixedBuildTargets.isEmpty()) {
|
||||
return Utils::transform(availableBuildTargets(parent, mode), [this](const QString &suffix) {
|
||||
return RunConfigurationCreationInfo{this, m_runConfigBaseId, suffix,
|
||||
this->displayNameForBuildTarget(suffix)};
|
||||
});
|
||||
}
|
||||
|
||||
QList<RunConfigurationCreationInfo> result;
|
||||
for (const BuildTargetInfo &bt : m_fixedBuildTargets) {
|
||||
RunConfigurationCreationInfo rci(this, m_runConfigBaseId, QString(), bt.displayName);
|
||||
result.append(rci);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<QString> IRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QString IRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||
@@ -480,6 +496,13 @@ void IRunConfigurationFactory::addSupportedProjectType(Core::Id id)
|
||||
m_supportedProjectTypes.append(id);
|
||||
}
|
||||
|
||||
void IRunConfigurationFactory::addFixedBuildTarget(const QString &displayName)
|
||||
{
|
||||
BuildTargetInfo bt;
|
||||
bt.displayName = displayName;
|
||||
m_fixedBuildTargets.append(bt);
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canHandle(Target *target) const
|
||||
{
|
||||
const Project *project = target->project();
|
||||
|
||||
Reference in New Issue
Block a user