diff --git a/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp index cfc67f81e41..01b261313d4 100644 --- a/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp +++ b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp @@ -57,7 +57,8 @@ QStringList GenericRemoteLinuxDeployStepFactory::availableCreationIds(BuildStepL if (!dc || dc->id() != RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId()) return ids; ids << TarPackageCreationStep::stepId() << UploadAndInstallTarPackageStep::stepId() - << GenericDirectUploadStep::stepId() << RemoteLinuxCustomCommandDeploymentStep::stepId(); + << GenericDirectUploadStep::stepId() + << GenericRemoteLinuxCustomCommandDeploymentStep::stepId(); return ids; } @@ -69,8 +70,8 @@ QString GenericRemoteLinuxDeployStepFactory::displayNameForId(const QString &id) return UploadAndInstallTarPackageStep::displayName(); if (id == GenericDirectUploadStep::stepId()) return GenericDirectUploadStep::displayName(); - if (id == RemoteLinuxCustomCommandDeploymentStep::stepId()) - return RemoteLinuxCustomCommandDeploymentStep::stepDisplayName(); + if (id == GenericRemoteLinuxCustomCommandDeploymentStep::stepId()) + return GenericRemoteLinuxCustomCommandDeploymentStep::stepDisplayName(); return QString(); } @@ -89,8 +90,8 @@ BuildStep *GenericRemoteLinuxDeployStepFactory::create(BuildStepList *parent, co return new UploadAndInstallTarPackageStep(parent); if (id == GenericDirectUploadStep::stepId()) return new GenericDirectUploadStep(parent, GenericDirectUploadStep::stepId()); - if (id == RemoteLinuxCustomCommandDeploymentStep::stepId()) - return new RemoteLinuxCustomCommandDeploymentStep(parent); + if (id == GenericRemoteLinuxCustomCommandDeploymentStep::stepId()) + return new GenericRemoteLinuxCustomCommandDeploymentStep(parent); return 0; } @@ -126,8 +127,8 @@ BuildStep *GenericRemoteLinuxDeployStepFactory::clone(BuildStepList *parent, Bui return new UploadAndInstallTarPackageStep(parent, other); if (GenericDirectUploadStep * const other = qobject_cast(product)) return new GenericDirectUploadStep(parent, other); - if (RemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast(product)) - return new RemoteLinuxCustomCommandDeploymentStep(parent, other); + if (GenericRemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast(product)) + return new GenericRemoteLinuxCustomCommandDeploymentStep(parent, other); return 0; } diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp index d48e12fd0ba..4a125a94c0a 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp @@ -31,7 +31,6 @@ **************************************************************************/ #include "remotelinuxcustomcommanddeploymentstep.h" -#include "remotelinuxcustomcommanddeployservice.h" #include "remotelinuxdeploystepwidget.h" #include @@ -52,7 +51,8 @@ class ConfigWidget : public BuildStepConfigWidget { Q_OBJECT public: - ConfigWidget(RemoteLinuxCustomCommandDeploymentStep *step) : m_step(step), m_widget(step) + ConfigWidget(AbstractRemoteLinuxCustomCommandDeploymentStep *step) + : m_step(step), m_widget(step) { QVBoxLayout * const mainLayout = new QVBoxLayout(this); mainLayout->setMargin(0); @@ -78,50 +78,55 @@ private: m_step->setCommandLine(m_commandLineEdit.text().trimmed()); } - RemoteLinuxCustomCommandDeploymentStep * const m_step; + AbstractRemoteLinuxCustomCommandDeploymentStep * const m_step; QLineEdit m_commandLineEdit; RemoteLinuxDeployStepWidget m_widget; }; } // anonymous namespace -class RemoteLinuxCustomCommandDeploymentStepPrivate +class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate { public: - RemoteLinuxCustomCommandDeployservice service; QString commandLine; }; +class GenericRemoteLinuxCustomCommandDeploymentStepPrivate +{ +public: + RemoteLinuxCustomCommandDeployService service; +}; + } // namespace Internal using namespace Internal; -RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl) - : AbstractRemoteLinuxDeployStep(bsl, stepId()) +AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl, + const QString &id) + : AbstractRemoteLinuxDeployStep(bsl, id) { ctor(); } -RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl, - RemoteLinuxCustomCommandDeploymentStep *other) +AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl, + AbstractRemoteLinuxCustomCommandDeploymentStep *other) : AbstractRemoteLinuxDeployStep(bsl, other) { ctor(); } -RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep() +AbstractRemoteLinuxCustomCommandDeploymentStep::~AbstractRemoteLinuxCustomCommandDeploymentStep() { delete d; } -void RemoteLinuxCustomCommandDeploymentStep::ctor() +void AbstractRemoteLinuxCustomCommandDeploymentStep::ctor() { - d = new RemoteLinuxCustomCommandDeploymentStepPrivate; - setDisplayName(stepDisplayName()); + d = new AbstractRemoteLinuxCustomCommandDeploymentStepPrivate; } -bool RemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map) +bool AbstractRemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map) { if (!AbstractRemoteLinuxDeployStep::fromMap(map)) return false; @@ -129,45 +134,70 @@ bool RemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map) return true; } -QVariantMap RemoteLinuxCustomCommandDeploymentStep::toMap() const +QVariantMap AbstractRemoteLinuxCustomCommandDeploymentStep::toMap() const { QVariantMap map = AbstractRemoteLinuxDeployStep::toMap(); map.insert(QLatin1String(CommandLineKey), d->commandLine); return map; } -void RemoteLinuxCustomCommandDeploymentStep::setCommandLine(const QString &commandLine) +void AbstractRemoteLinuxCustomCommandDeploymentStep::setCommandLine(const QString &commandLine) { d->commandLine = commandLine; } -QString RemoteLinuxCustomCommandDeploymentStep::commandLine() const +QString AbstractRemoteLinuxCustomCommandDeploymentStep::commandLine() const { return d->commandLine; } -bool RemoteLinuxCustomCommandDeploymentStep::isDeploymentPossible(QString *whyNot) const +bool AbstractRemoteLinuxCustomCommandDeploymentStep::isDeploymentPossible(QString *whyNot) const { - d->service.setCommandLine(d->commandLine); + deployService()->setCommandLine(d->commandLine); return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); } -AbstractRemoteLinuxDeployService *RemoteLinuxCustomCommandDeploymentStep::deployService() const -{ - return &d->service; -} - -BuildStepConfigWidget *RemoteLinuxCustomCommandDeploymentStep::createConfigWidget() +BuildStepConfigWidget *AbstractRemoteLinuxCustomCommandDeploymentStep::createConfigWidget() { return new ConfigWidget(this); } -QString RemoteLinuxCustomCommandDeploymentStep::stepId() + +GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl) + : AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, stepId()) { - return QLatin1String("RemoteLinuxCustomCommandDeploymentStep"); + ctor(); } -QString RemoteLinuxCustomCommandDeploymentStep::stepDisplayName() +GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl, + GenericRemoteLinuxCustomCommandDeploymentStep *other) + : AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, other) +{ + ctor(); +} + +GenericRemoteLinuxCustomCommandDeploymentStep::~GenericRemoteLinuxCustomCommandDeploymentStep() +{ + delete d; +} + +void GenericRemoteLinuxCustomCommandDeploymentStep::ctor() +{ + d = new GenericRemoteLinuxCustomCommandDeploymentStepPrivate; + setDefaultDisplayName(stepDisplayName()); +} + +RemoteLinuxCustomCommandDeployService *GenericRemoteLinuxCustomCommandDeploymentStep::deployService() const +{ + return &d->service; +} + +QString GenericRemoteLinuxCustomCommandDeploymentStep::stepId() +{ + return QLatin1String("RemoteLinux.GenericRemoteLinuxCustomCommandDeploymentStep"); +} + +QString GenericRemoteLinuxCustomCommandDeploymentStep::stepDisplayName() { return tr("Run custom remote command"); } diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h index 43250146db9..0c38c1a4861 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h @@ -33,21 +33,21 @@ #define REMOTELINUXCUSTOMCOMMANDDEPLOYMENTSTEP_H #include "abstractremotelinuxdeploystep.h" +#include "remotelinuxcustomcommanddeployservice.h" namespace RemoteLinux { namespace Internal { -class RemoteLinuxCustomCommandDeploymentStepPrivate; +class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate; +class GenericRemoteLinuxCustomCommandDeploymentStepPrivate; } // namespace Internal -class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeploymentStep + +class REMOTELINUX_EXPORT AbstractRemoteLinuxCustomCommandDeploymentStep : public AbstractRemoteLinuxDeployStep { Q_OBJECT public: - RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl); - RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, - RemoteLinuxCustomCommandDeploymentStep *other); - ~RemoteLinuxCustomCommandDeploymentStep(); + ~AbstractRemoteLinuxCustomCommandDeploymentStep(); bool fromMap(const QVariantMap &map); QVariantMap toMap() const; @@ -55,19 +55,42 @@ public: void setCommandLine(const QString &commandLine); QString commandLine() const; - static QString stepId(); - static QString stepDisplayName(); - protected: + AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, + const QString &id); + AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, + AbstractRemoteLinuxCustomCommandDeploymentStep *other); + bool isDeploymentPossible(QString *whyNot = 0) const; private: void ctor(); - AbstractRemoteLinuxDeployService *deployService() const; + RemoteLinuxCustomCommandDeployService *deployService() const = 0; ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - Internal::RemoteLinuxCustomCommandDeploymentStepPrivate *d; + Internal::AbstractRemoteLinuxCustomCommandDeploymentStepPrivate *d; +}; + + +class REMOTELINUX_EXPORT GenericRemoteLinuxCustomCommandDeploymentStep + : public AbstractRemoteLinuxCustomCommandDeploymentStep +{ + Q_OBJECT +public: + GenericRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl); + GenericRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, + GenericRemoteLinuxCustomCommandDeploymentStep *other); + ~GenericRemoteLinuxCustomCommandDeploymentStep(); + + static QString stepId(); + static QString stepDisplayName(); + +private: + RemoteLinuxCustomCommandDeployService *deployService() const; + void ctor(); + + Internal::GenericRemoteLinuxCustomCommandDeploymentStepPrivate *d; }; } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp index 0bee7249fbe..18c7ba8cdf9 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp @@ -59,24 +59,24 @@ public: using namespace Internal; -RemoteLinuxCustomCommandDeployservice::RemoteLinuxCustomCommandDeployservice(QObject *parent) +RemoteLinuxCustomCommandDeployService::RemoteLinuxCustomCommandDeployService(QObject *parent) : AbstractRemoteLinuxDeployService(parent), d(new RemoteLinuxCustomCommandDeployservicePrivate) { } -RemoteLinuxCustomCommandDeployservice::~RemoteLinuxCustomCommandDeployservice() +RemoteLinuxCustomCommandDeployService::~RemoteLinuxCustomCommandDeployService() { delete d; } -void RemoteLinuxCustomCommandDeployservice::setCommandLine(const QString &commandLine) +void RemoteLinuxCustomCommandDeployService::setCommandLine(const QString &commandLine) { QTC_ASSERT(d->state == Inactive, return); d->commandLine = commandLine; } -bool RemoteLinuxCustomCommandDeployservice::isDeploymentPossible(QString *whyNot) const +bool RemoteLinuxCustomCommandDeployService::isDeploymentPossible(QString *whyNot) const { QTC_ASSERT(d->state == Inactive, return false); @@ -91,7 +91,7 @@ bool RemoteLinuxCustomCommandDeployservice::isDeploymentPossible(QString *whyNot return true; } -void RemoteLinuxCustomCommandDeployservice::doDeploy() +void RemoteLinuxCustomCommandDeployService::doDeploy() { QTC_ASSERT(d->state == Inactive, handleDeploymentDone()); @@ -107,7 +107,7 @@ void RemoteLinuxCustomCommandDeployservice::doDeploy() d->runner->run(d->commandLine.toUtf8()); } -void RemoteLinuxCustomCommandDeployservice::stopDeployment() +void RemoteLinuxCustomCommandDeployService::stopDeployment() { QTC_ASSERT(d->state == Running, return); @@ -118,17 +118,17 @@ void RemoteLinuxCustomCommandDeployservice::stopDeployment() handleDeploymentDone(); } -void RemoteLinuxCustomCommandDeployservice::handleStdout(const QByteArray &output) +void RemoteLinuxCustomCommandDeployService::handleStdout(const QByteArray &output) { emit stdOutData(QString::fromUtf8(output)); } -void RemoteLinuxCustomCommandDeployservice::handleStderr(const QByteArray &output) +void RemoteLinuxCustomCommandDeployService::handleStderr(const QByteArray &output) { emit stdErrData(QString::fromUtf8(output)); } -void RemoteLinuxCustomCommandDeployservice::handleProcessClosed(int exitStatus) +void RemoteLinuxCustomCommandDeployService::handleProcessClosed(int exitStatus) { QTC_ASSERT(d->state == Running, return); diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.h b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.h index 3cf324c41ae..c0f90ef45ef 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.h +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.h @@ -39,13 +39,13 @@ namespace Internal { class RemoteLinuxCustomCommandDeployservicePrivate; } // namespace Internal -class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeployservice +class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeployService : public AbstractRemoteLinuxDeployService { Q_OBJECT public: - explicit RemoteLinuxCustomCommandDeployservice(QObject *parent = 0); - ~RemoteLinuxCustomCommandDeployservice(); + explicit RemoteLinuxCustomCommandDeployService(QObject *parent = 0); + ~RemoteLinuxCustomCommandDeployService(); void setCommandLine(const QString &commandLine);