From c04c5c1575e4ee425e6d2383e52a2b44e9c20fd2 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 22 Jan 2019 18:17:30 +0100 Subject: [PATCH] ProjectExplorer: Move part of deploy config initial step handling ... to BuildStepList so it can be re-used in BuildConfiguration when attempting to set up a similar system to specify initial population of step lists. Change-Id: I2301feb2b67a80a9d9e526e4065b4d4487b7fdbd Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/buildsteplist.cpp | 8 ++++++++ src/plugins/projectexplorer/buildsteplist.h | 7 +++++++ src/plugins/projectexplorer/deployconfiguration.cpp | 5 +---- src/plugins/projectexplorer/deployconfiguration.h | 8 ++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/plugins/projectexplorer/buildsteplist.cpp b/src/plugins/projectexplorer/buildsteplist.cpp index 40d4c3b9ac7..dab8d70311a 100644 --- a/src/plugins/projectexplorer/buildsteplist.cpp +++ b/src/plugins/projectexplorer/buildsteplist.cpp @@ -162,6 +162,14 @@ void BuildStepList::insertStep(int position, Core::Id stepId) QTC_ASSERT(false, qDebug() << "No factory for build step" << stepId.toString() << "found."); } +void BuildStepList::appendSteps(const QList &infos) +{ + for (const StepCreationInfo &info : infos) { + if (!info.condition || info.condition(target())) + appendStep(info.stepId); + } +} + bool BuildStepList::removeStep(int position) { BuildStep *bs = at(position); diff --git a/src/plugins/projectexplorer/buildsteplist.h b/src/plugins/projectexplorer/buildsteplist.h index 1c3ec4d4740..b9fce034dae 100644 --- a/src/plugins/projectexplorer/buildsteplist.h +++ b/src/plugins/projectexplorer/buildsteplist.h @@ -76,6 +76,13 @@ public: void insertStep(int position, Core::Id id); void appendStep(BuildStep *step) { insertStep(count(), step); } void appendStep(Core::Id stepId) { insertStep(count(), stepId); } + + struct StepCreationInfo { + Core::Id stepId; + std::function condition; // unset counts as unrestricted + }; + void appendSteps(const QList &infos); + bool removeStep(int position); void moveStepUp(int position); BuildStep *at(int position); diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index 83b793ff3b8..7619a06ca24 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -197,10 +197,7 @@ DeployConfiguration *DeployConfigurationFactory::create(Target *parent) QTC_ASSERT(canHandle(parent), return nullptr); DeployConfiguration *dc = createDeployConfiguration(parent); QTC_ASSERT(dc, return nullptr); - for (const DeployStepCreationInfo &info : qAsConst(m_initialSteps)) { - if (!info.condition || info.condition(parent)) - dc->stepList()->appendStep(info.deployStepId); - } + dc->stepList()->appendSteps(m_initialSteps); return dc; } diff --git a/src/plugins/projectexplorer/deployconfiguration.h b/src/plugins/projectexplorer/deployconfiguration.h index 3539d73cec7..1d9ff883383 100644 --- a/src/plugins/projectexplorer/deployconfiguration.h +++ b/src/plugins/projectexplorer/deployconfiguration.h @@ -102,15 +102,11 @@ protected: void setConfigBaseId(Core::Id deployConfigBaseId); private: - struct DeployStepCreationInfo { - Core::Id deployStepId; - std::function condition; // unset counts as unrestricted - }; - DeployConfiguration *createDeployConfiguration(Target *t); + DeployConfiguration *createDeployConfiguration(Target *target); Core::Id m_deployConfigBaseId; Core::Id m_supportedProjectType; QList m_supportedTargetDeviceTypes; - QList m_initialSteps; + QList m_initialSteps; QString m_defaultDisplayName; std::function m_configWidgetCreator; };