forked from qt-creator/qt-creator
ProjectExplorer: Promote RemoteLinuxRunConfigFactory::availableBuildTargets
This was already almost the desired final pattern, so make it the default implementation of ProjectRunConfigurationFactory::availableBuildTargets. For the only remaining feature of "decorating" the build target names, introduce a property m_displayNamePattern. Un-adapted sub-classes still need (and are able) to overide. Change-Id: Ia7d2d2f7d53f8b1da487fa82c8265ad5deb47500 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -461,16 +461,26 @@ QList<RunConfigurationCreationInfo>
|
||||
: m_fixedBuildTargets;
|
||||
|
||||
for (const BuildTargetInfo &bt : buildTargets) {
|
||||
RunConfigurationCreationInfo rci(this, m_runConfigBaseId, bt.targetName, bt.displayName);
|
||||
QString displayName = bt.displayName;
|
||||
if (displayName.isEmpty())
|
||||
displayName = QFileInfo(bt.targetName).completeBaseName();
|
||||
if (displayName.isEmpty())
|
||||
displayName = bt.targetName;
|
||||
if (!m_displayNamePattern.isEmpty()) {
|
||||
displayName = m_displayNamePattern.contains("%1")
|
||||
? m_displayNamePattern.arg(bt.targetName)
|
||||
: m_displayNamePattern;
|
||||
}
|
||||
RunConfigurationCreationInfo rci(this, m_runConfigBaseId, bt.targetName, displayName);
|
||||
result.append(rci);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<BuildTargetInfo> IRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||
QList<BuildTargetInfo> IRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
||||
{
|
||||
return {};
|
||||
return parent->applicationTargets().list;
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +507,24 @@ void IRunConfigurationFactory::addFixedBuildTarget(const QString &displayName)
|
||||
m_fixedBuildTargets.append(bt);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Convenience function to specify a pattern for the name that is displayed for this
|
||||
RunConfiguration.
|
||||
|
||||
A fixed string is used as-is, a "%1" is replaced by the BuildTargetInfo's targetName.
|
||||
|
||||
This simplistic patterns covers all currently existing uses, if anything more
|
||||
complex is required, the display name can be set directly when creating the
|
||||
BuildTargetInfo objects as part of the RunConfiguration's availableBuildTarget()
|
||||
implementation.
|
||||
*/
|
||||
void IRunConfigurationFactory::setDisplayNamePattern(const QString &pattern)
|
||||
{
|
||||
m_displayNamePattern = pattern;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canHandle(Target *target) const
|
||||
{
|
||||
const Project *project = target->project();
|
||||
|
||||
Reference in New Issue
Block a user