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

RemoteLinux: Make incremental deployment configurable...

...for the direct upload step.

Change-Id: I369963556f0c72b692b802b30a0e43c03b8b2397
Reviewed-on: http://codereview.qt.nokia.com/4315

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent b0b35a35
......@@ -54,8 +54,10 @@ enum State { Inactive, InitializingSftp, Uploading };
class GenericDirectUploadServicePrivate
{
public:
GenericDirectUploadServicePrivate() : stopRequested(false), state(Inactive) {}
GenericDirectUploadServicePrivate()
: incremental(false), stopRequested(false), state(Inactive) {}
bool incremental;
bool stopRequested;
State state;
QList<DeployableFile> filesToUpload;
......@@ -79,6 +81,11 @@ void GenericDirectUploadService::setDeployableFiles(const QList<DeployableFile>
m_d->deployableFiles = deployableFiles;
}
void GenericDirectUploadService::setIncrementalDeployment(bool incremental)
{
m_d->incremental = incremental;
}
bool GenericDirectUploadService::isDeploymentNecessary() const
{
m_d->filesToUpload.clear();
......@@ -259,15 +266,13 @@ void GenericDirectUploadService::stopDeployment()
handleDeploymentDone();
}
// Note: time stamp checks disabled for now; it's too much hassle for the user to force
// deployment in case the device has changed.
void GenericDirectUploadService::checkDeploymentNeeded(const DeployableFile &deployable) const
{
QFileInfo fileInfo(deployable.localFilePath);
if (fileInfo.isDir()) {
const QStringList files = QDir(deployable.localFilePath)
.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
if (files.isEmpty() /* && hasChangedSinceLastDeployment(deployable) */)
if (files.isEmpty() && (!m_d->incremental || hasChangedSinceLastDeployment(deployable)))
m_d->filesToUpload << deployable;
foreach (const QString &fileName, files) {
const QString localFilePath = deployable.localFilePath
......@@ -276,7 +281,7 @@ void GenericDirectUploadService::checkDeploymentNeeded(const DeployableFile &dep
+ fileInfo.fileName();
checkDeploymentNeeded(DeployableFile(localFilePath, remoteDir));
}
} else /* if (hasChangedSinceLastDeployment(deployable)) */ {
} else if (!m_d->incremental || hasChangedSinceLastDeployment(deployable)) {
m_d->filesToUpload << deployable;
}
}
......
......@@ -52,6 +52,7 @@ public:
GenericDirectUploadService(QObject *parent = 0);
void setDeployableFiles(const QList<DeployableFile> &deployableFiles);
void setIncrementalDeployment(bool incremental);
private slots:
void handleSftpInitialized();
......
......@@ -35,17 +35,64 @@
#include "deploymentinfo.h"
#include "genericdirectuploadservice.h"
#include "remotelinuxdeployconfiguration.h"
#include "remotelinuxdeploystepwidget.h"
#include <QtGui/QCheckBox>
#include <QtGui/QVBoxLayout>
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
namespace {
const char IncrementalKey[] = "RemoteLinux.GenericDirectUploadStep.Incremental";
class ConfigWidget : public BuildStepConfigWidget
{
Q_OBJECT
public:
ConfigWidget(GenericDirectUploadStep *step) : m_widget(step)
{
m_incrementalCheckBox.setText(tr("Incremental deployment"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
mainLayout->addWidget(&m_widget);
mainLayout->addWidget(&m_incrementalCheckBox);
m_incrementalCheckBox.setChecked(step->incrementalDeployment());
connect(&m_widget, SIGNAL(updateSummary()), SIGNAL(updateSummary()));
connect(&m_incrementalCheckBox, SIGNAL(toggled(bool)),
SLOT(handleIncrementalChanged(bool)));
}
private:
QString summaryText() const { return m_widget.summaryText(); }
QString displayName() const { return m_widget.displayName(); }
GenericDirectUploadStep *myStep() const {
return qobject_cast<GenericDirectUploadStep *>(m_widget.step());
}
Q_SLOT void handleIncrementalChanged(bool incremental) {
myStep()->setIncrementalDeployment(incremental);
}
RemoteLinuxDeployStepWidget m_widget;
QCheckBox m_incrementalCheckBox;
};
} // anonymous namespace
class GenericDirectUploadStepPrivate
{
public:
GenericDirectUploadStepPrivate() : incremental(true) {}
GenericDirectUploadService deployService;
bool incremental;
};
} // namespace Internal
GenericDirectUploadStep::GenericDirectUploadStep(ProjectExplorer::BuildStepList *bsl, const QString &id)
......@@ -65,6 +112,11 @@ GenericDirectUploadStep::~GenericDirectUploadStep()
delete m_d;
}
BuildStepConfigWidget *GenericDirectUploadStep::createConfigWidget()
{
return new Internal::ConfigWidget(this);
}
bool GenericDirectUploadStep::isDeploymentPossible(QString *whyNot) const
{
QList<DeployableFile> deployableFiles;
......@@ -73,6 +125,7 @@ bool GenericDirectUploadStep::isDeploymentPossible(QString *whyNot) const
for (int i = 0; i < deployableCount; ++i)
deployableFiles << deploymentInfo->deployableAt(i);
m_d->deployService.setDeployableFiles(deployableFiles);
m_d->deployService.setIncrementalDeployment(incrementalDeployment());
return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot);
}
......@@ -81,12 +134,37 @@ AbstractRemoteLinuxDeployService *GenericDirectUploadStep::deployService() const
return &m_d->deployService;
}
bool GenericDirectUploadStep::fromMap(const QVariantMap &map)
{
if (!AbstractRemoteLinuxDeployStep::fromMap(map))
return false;
setIncrementalDeployment(map.value(QLatin1String(Internal::IncrementalKey), true).toBool());
return true;
}
QVariantMap GenericDirectUploadStep::toMap() const
{
QVariantMap map = AbstractRemoteLinuxDeployStep::toMap();
map.insert(QLatin1String(Internal::IncrementalKey), incrementalDeployment());
return map;
}
void GenericDirectUploadStep::ctor()
{
setDefaultDisplayName(displayName());
m_d = new Internal::GenericDirectUploadStepPrivate;
}
void GenericDirectUploadStep::setIncrementalDeployment(bool incremental)
{
m_d->incremental = incremental;
}
bool GenericDirectUploadStep::incrementalDeployment() const
{
return m_d->incremental;
}
QString GenericDirectUploadStep::stepId()
{
return QLatin1String("RemoteLinux.DirectUploadStep");
......@@ -98,3 +176,5 @@ QString GenericDirectUploadStep::displayName()
}
} //namespace RemoteLinux
#include "genericdirectuploadstep.moc"
......@@ -49,13 +49,19 @@ public:
GenericDirectUploadStep(ProjectExplorer::BuildStepList *bsl, GenericDirectUploadStep *other);
~GenericDirectUploadStep();
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
bool isDeploymentPossible(QString *whyNot = 0) const;
void setIncrementalDeployment(bool incremental);
bool incrementalDeployment() const;
static QString stepId();
static QString displayName();
private:
AbstractRemoteLinuxDeployService *deployService() const;
bool fromMap(const QVariantMap &map);
QVariantMap toMap() const;
void ctor();
......
......@@ -51,6 +51,8 @@ public:
QString summaryText() const;
QString displayName() const { return QString(); }
AbstractRemoteLinuxDeployStep *step() const { return m_step; }
private:
Q_SLOT void handleStepToBeRemoved(int step);
......
Supports Markdown
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