Commit eb6cee45 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Make custom command deployment step extensible.

Also fix typo in service class name.

Change-Id: Icd664d77b43fc63a59a94575529b1a1c272b500c
Reviewed-on: http://codereview.qt-project.org/5549

Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 5c746546
......@@ -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<GenericDirectUploadStep *>(product))
return new GenericDirectUploadStep(parent, other);
if (RemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast<RemoteLinuxCustomCommandDeploymentStep *>(product))
return new RemoteLinuxCustomCommandDeploymentStep(parent, other);
if (GenericRemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast<GenericRemoteLinuxCustomCommandDeploymentStep *>(product))
return new GenericRemoteLinuxCustomCommandDeploymentStep(parent, other);
return 0;
}
......
......@@ -31,7 +31,6 @@
**************************************************************************/
#include "remotelinuxcustomcommanddeploymentstep.h"
#include "remotelinuxcustomcommanddeployservice.h"
#include "remotelinuxdeploystepwidget.h"
#include <QtCore/QString>
......@@ -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
BuildStepConfigWidget *AbstractRemoteLinuxCustomCommandDeploymentStep::createConfigWidget()
{
return &d->service;
return new ConfigWidget(this);
}
BuildStepConfigWidget *RemoteLinuxCustomCommandDeploymentStep::createConfigWidget()
GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl)
: AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, stepId())
{
return new ConfigWidget(this);
ctor();
}
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 RemoteLinuxCustomCommandDeploymentStep::stepId()
QString GenericRemoteLinuxCustomCommandDeploymentStep::stepId()
{
return QLatin1String("RemoteLinuxCustomCommandDeploymentStep");
return QLatin1String("RemoteLinux.GenericRemoteLinuxCustomCommandDeploymentStep");
}
QString RemoteLinuxCustomCommandDeploymentStep::stepDisplayName()
QString GenericRemoteLinuxCustomCommandDeploymentStep::stepDisplayName()
{
return tr("Run custom remote command");
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment