From e9d6c0f1546490816ed87735e699983ca1fbacaa Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 11 Aug 2022 13:50:36 +0200 Subject: [PATCH] RemoteLinux: Streamline RsyncDeployStep interface Change-Id: I5aa5ff477d1c654fd502575c32af667e436a2129 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/remotelinux/remotelinuxplugin.cpp | 2 +- src/plugins/remotelinux/rsyncdeploystep.cpp | 79 ++++++++++--------- src/plugins/remotelinux/rsyncdeploystep.h | 18 ++--- 3 files changed, 47 insertions(+), 52 deletions(-) diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 5034eb908cf..4da224be93a 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -58,7 +58,7 @@ public: TarPackageCreationStepFactory tarPackageCreationStepFactory; TarPackageDeployStepFactory tarPackageDeployStepFactory; GenericDeployStepFactory genericDirectUploadStepFactory; - GenericDeployStepFactory rsyncDeployStepFactory; + RsyncDeployStepFactory rsyncDeployStepFactory; CustomCommandDeployStepFactory customCommandDeployStepFactory; KillAppStepFactory killAppStepFactory; GenericDeployStepFactory makeInstallStepFactory; diff --git a/src/plugins/remotelinux/rsyncdeploystep.cpp b/src/plugins/remotelinux/rsyncdeploystep.cpp index b637ec2970e..02ec3e1919e 100644 --- a/src/plugins/remotelinux/rsyncdeploystep.cpp +++ b/src/plugins/remotelinux/rsyncdeploystep.cpp @@ -3,6 +3,7 @@ #include "rsyncdeploystep.h" +#include "abstractremotelinuxdeploystep.h" #include "abstractremotelinuxdeployservice.h" #include "remotelinux_constants.h" #include "remotelinuxtr.h" @@ -10,6 +11,7 @@ #include #include #include +#include #include #include @@ -20,13 +22,12 @@ using namespace ProjectExplorer; using namespace Utils; -namespace RemoteLinux { -namespace Internal { +namespace RemoteLinux::Internal { class RsyncDeployService : public AbstractRemoteLinuxDeployService { public: - RsyncDeployService(QObject *parent = nullptr) : AbstractRemoteLinuxDeployService(parent) + RsyncDeployService() { connect(&m_mkdir, &QtcProcess::done, this, [this] { if (m_mkdir.result() != ProcessResult::FinishedWithSuccess) { @@ -139,46 +140,48 @@ void RsyncDeployService::setFinished() handleDeploymentDone(); } -} // namespace Internal +// RsyncDeployStep -RsyncDeployStep::RsyncDeployStep(BuildStepList *bsl, Utils::Id id) - : AbstractRemoteLinuxDeployStep(bsl, id) +class RsyncDeployStep : public AbstractRemoteLinuxDeployStep { - auto service = createDeployService(); +public: + RsyncDeployStep(BuildStepList *bsl, Id id) + : AbstractRemoteLinuxDeployStep(bsl, id) + { + auto service = createDeployService(); - auto flags = addAspect(); - flags->setDisplayStyle(StringAspect::LineEditDisplay); - flags->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags"); - flags->setLabelText(Tr::tr("Flags:")); - flags->setValue(FileTransferSetupData::defaultRsyncFlags()); + auto flags = addAspect(); + flags->setDisplayStyle(StringAspect::LineEditDisplay); + flags->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags"); + flags->setLabelText(Tr::tr("Flags:")); + flags->setValue(FileTransferSetupData::defaultRsyncFlags()); - auto ignoreMissingFiles = addAspect(); - ignoreMissingFiles->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles"); - ignoreMissingFiles->setLabel(Tr::tr("Ignore missing files:"), - BoolAspect::LabelPlacement::InExtraLabel); - ignoreMissingFiles->setValue(false); + auto ignoreMissingFiles = addAspect(); + ignoreMissingFiles->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles"); + ignoreMissingFiles->setLabel(Tr::tr("Ignore missing files:"), + BoolAspect::LabelPlacement::InExtraLabel); + ignoreMissingFiles->setValue(false); - setInternalInitializer([service, flags, ignoreMissingFiles] { - service->setIgnoreMissingFiles(ignoreMissingFiles->value()); - service->setFlags(flags->value()); - return service->isDeploymentPossible(); - }); + setInternalInitializer([service, flags, ignoreMissingFiles] { + service->setIgnoreMissingFiles(ignoreMissingFiles->value()); + service->setFlags(flags->value()); + return service->isDeploymentPossible(); + }); - setRunPreparer([this, service] { - service->setDeployableFiles(target()->deploymentData().allFiles()); - }); + setRunPreparer([this, service] { + service->setDeployableFiles(target()->deploymentData().allFiles()); + }); + } +}; + +// RsyncDeployStepFactory + +RsyncDeployStepFactory::RsyncDeployStepFactory() +{ + registerStep(Constants::RsyncDeployStepId); + setDisplayName(Tr::tr("Deploy files via rsync")); + setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); } -RsyncDeployStep::~RsyncDeployStep() = default; - -Utils::Id RsyncDeployStep::stepId() -{ - return Constants::RsyncDeployStepId; -} - -QString RsyncDeployStep::displayName() -{ - return Tr::tr("Deploy files via rsync"); -} - -} // RemoteLinux +} // RemoteLinux::Internal diff --git a/src/plugins/remotelinux/rsyncdeploystep.h b/src/plugins/remotelinux/rsyncdeploystep.h index 214ac2abdb9..7816c58ba29 100644 --- a/src/plugins/remotelinux/rsyncdeploystep.h +++ b/src/plugins/remotelinux/rsyncdeploystep.h @@ -3,22 +3,14 @@ #pragma once -#include "remotelinux_export.h" +#include -#include "abstractremotelinuxdeploystep.h" +namespace RemoteLinux::Internal { -namespace RemoteLinux { - -class REMOTELINUX_EXPORT RsyncDeployStep : public AbstractRemoteLinuxDeployStep +class RsyncDeployStepFactory : public ProjectExplorer::BuildStepFactory { - Q_OBJECT - public: - RsyncDeployStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - ~RsyncDeployStep() override; - - static Utils::Id stepId(); - static QString displayName(); + RsyncDeployStepFactory(); }; -} // RemoteLinux +} // RemoteLinux::Internal