forked from qt-creator/qt-creator
ProjectExplorer: Add a mechanism to specify initial steps
... in a deploy configuration. The idea is to replace DeployConfiguration-derived::initialize() functions by that. This can also be used to cut link-time ties of "derived plugins" by using step ids instead of creation of real class instances when specifying deploy config contents. Change-Id: Id7c613b054e37fe5d03463b9b0aa7dfef44a8e13 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -198,6 +198,10 @@ DeployConfiguration *DeployConfigurationFactory::create(Target *parent, Core::Id
|
||||
if (!dc)
|
||||
return nullptr;
|
||||
dc->initialize();
|
||||
for (const DeployStepCreationInfo &info : qAsConst(m_initialSteps)) {
|
||||
if (!info.condition || info.condition(parent))
|
||||
dc->stepList()->appendStep(info.deployStepId);
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
@@ -251,6 +255,11 @@ void DeployConfigurationFactory::setSupportedProjectType(Core::Id id)
|
||||
m_supportedProjectType = id;
|
||||
}
|
||||
|
||||
void DeployConfigurationFactory::addInitialStep(Core::Id stepId, const std::function<bool (Target *)> &condition)
|
||||
{
|
||||
m_initialSteps.append({stepId, condition});
|
||||
}
|
||||
|
||||
///
|
||||
// DefaultDeployConfigurationFactory
|
||||
///
|
||||
|
||||
@@ -96,6 +96,9 @@ public:
|
||||
void setDefaultDisplayName(const QString &defaultDisplayName);
|
||||
void setSupportedProjectType(Core::Id id);
|
||||
|
||||
// Step is only added if condition is not set, or returns true when called.
|
||||
void addInitialStep(Core::Id stepId, const std::function<bool(Target *)> &condition = {});
|
||||
|
||||
virtual bool canHandle(ProjectExplorer::Target *target) const;
|
||||
|
||||
protected:
|
||||
@@ -113,10 +116,15 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
struct DeployStepCreationInfo {
|
||||
Core::Id deployStepId;
|
||||
std::function<bool(Target *)> condition; // unset counts as unrestricted
|
||||
};
|
||||
DeployConfigurationCreator m_creator;
|
||||
Core::Id m_deployConfigBaseId;
|
||||
Core::Id m_supportedProjectType;
|
||||
QList<Core::Id> m_supportedTargetDeviceTypes;
|
||||
QList<DeployStepCreationInfo> m_initialSteps;
|
||||
QString m_defaultDisplayName;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user