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;
|
: m_fixedBuildTargets;
|
||||||
|
|
||||||
for (const BuildTargetInfo &bt : buildTargets) {
|
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);
|
result.append(rci);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
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);
|
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
|
bool IRunConfigurationFactory::canHandle(Target *target) const
|
||||||
{
|
{
|
||||||
const Project *project = target->project();
|
const Project *project = target->project();
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ protected:
|
|||||||
void addSupportedProjectType(Core::Id id);
|
void addSupportedProjectType(Core::Id id);
|
||||||
void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids);
|
void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids);
|
||||||
void addFixedBuildTarget(const QString &displayName);
|
void addFixedBuildTarget(const QString &displayName);
|
||||||
|
void setDisplayNamePattern(const QString &pattern);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RunConfigurationCreator m_creator;
|
RunConfigurationCreator m_creator;
|
||||||
@@ -344,6 +345,7 @@ private:
|
|||||||
QList<Core::Id> m_supportedProjectTypes;
|
QList<Core::Id> m_supportedProjectTypes;
|
||||||
QList<Core::Id> m_supportedTargetDeviceTypes;
|
QList<Core::Id> m_supportedTargetDeviceTypes;
|
||||||
QList<BuildTargetInfo> m_fixedBuildTargets;
|
QList<BuildTargetInfo> m_fixedBuildTargets;
|
||||||
|
QString m_displayNamePattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget
|
class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ RemoteLinuxRunConfigurationFactory::RemoteLinuxRunConfigurationFactory(QObject *
|
|||||||
setObjectName("RemoteLinuxRunConfigurationFactory");
|
setObjectName("RemoteLinuxRunConfigurationFactory");
|
||||||
registerRunConfiguration<RemoteLinuxRunConfiguration>(RemoteLinuxRunConfiguration::IdPrefix);
|
registerRunConfiguration<RemoteLinuxRunConfiguration>(RemoteLinuxRunConfiguration::IdPrefix);
|
||||||
setSupportedTargetDeviceTypes({RemoteLinux::Constants::GenericLinuxOsType});
|
setSupportedTargetDeviceTypes({RemoteLinux::Constants::GenericLinuxOsType});
|
||||||
|
setDisplayNamePattern(tr("%1 (on Remote Generic Linux Host)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
bool RemoteLinuxRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
@@ -53,14 +54,6 @@ bool RemoteLinuxRunConfigurationFactory::canCreateHelper(Target *parent, const Q
|
|||||||
return parent->applicationTargets().hasTarget(buildTarget);
|
return parent->applicationTargets().hasTarget(buildTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BuildTargetInfo> RemoteLinuxRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
|
||||||
{
|
|
||||||
return Utils::transform(parent->applicationTargets().list, [](BuildTargetInfo bti) {
|
|
||||||
bti.displayName = bti.targetName + ' ' + tr("(on Remote Generic Linux Host)");
|
|
||||||
return bti;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoteLinuxCustomRunConfigurationFactory
|
// RemoteLinuxCustomRunConfigurationFactory
|
||||||
|
|
||||||
RemoteLinuxCustomRunConfigurationFactory::RemoteLinuxCustomRunConfigurationFactory(QObject *parent)
|
RemoteLinuxCustomRunConfigurationFactory::RemoteLinuxCustomRunConfigurationFactory(QObject *parent)
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ class RemoteLinuxRunConfigurationFactory : public ProjectExplorer::IRunConfigura
|
|||||||
public:
|
public:
|
||||||
explicit RemoteLinuxRunConfigurationFactory(QObject *parent = 0);
|
explicit RemoteLinuxRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QList<ProjectExplorer::BuildTargetInfo>
|
|
||||||
availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
|
||||||
|
|
||||||
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user