Commit edc776c2 authored by Christian Kandeler's avatar Christian Kandeler

RemoteLinux: Private implementation for all exported classes.

Change-Id: Id92eb156b027a4986788141845170105b3b1d9e5
Reviewed-on: http://codereview.qt.nokia.com/2507Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 7efb3c35
......@@ -33,6 +33,7 @@
#include "remotelinuxqmlprofilerrunner.h"
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <remotelinux/portlist.h>
#include <remotelinux/remotelinuxapplicationrunner.h>
#include <utils/qtcassert.h>
......
......@@ -45,6 +45,7 @@ class AbstractPackagingStepPrivate;
class REMOTELINUX_EXPORT AbstractPackagingStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
Q_DISABLE_COPY(AbstractPackagingStep)
public:
AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, const QString &id);
AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, AbstractPackagingStep *other);
......
......@@ -272,7 +272,7 @@ void AbstractRemoteLinuxDeployService::handleConnectionFailure()
break;
case Connecting: {
QString errorMsg = tr("Could not connect to host: %1").arg(m_d->connection->errorString());
if (deviceConfiguration()->type() == LinuxDeviceConfiguration::Emulator)
if (deviceConfiguration()->deviceType() == LinuxDeviceConfiguration::Emulator)
errorMsg += tr("\nDid the emulator fail to start?");
else
errorMsg += tr("\nIs the device connected and set up for network access?");
......
......@@ -57,6 +57,7 @@ class AbstractRemoteLinuxDeployServicePrivate;
class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployService : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(AbstractRemoteLinuxDeployService)
public:
explicit AbstractRemoteLinuxDeployService(QObject *parent);
~AbstractRemoteLinuxDeployService();
......
......@@ -49,6 +49,7 @@ class AbstractRemoteLinuxDeployStepPrivate;
class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
Q_DISABLE_COPY(AbstractRemoteLinuxDeployStep)
public:
bool fromMap(const QVariantMap &map);
......
......@@ -31,6 +31,8 @@
**************************************************************************/
#include "deployablefilesperprofile.h"
#include "deployablefile.h"
#include <utils/qtcassert.h>
#include <QtCore/QFileInfo>
......@@ -39,46 +41,70 @@
using namespace Qt4ProjectManager;
namespace RemoteLinux {
namespace Internal {
class DeployableFilesPerProFilePrivate
{
public:
DeployableFilesPerProFilePrivate(const Qt4ProFileNode *proFileNode)
: projectType(proFileNode->projectType()),
proFilePath(proFileNode->path()),
projectName(proFileNode->displayName()),
targetInfo(proFileNode->targetInformation()),
installsList(proFileNode->installsList()),
projectVersion(proFileNode->projectVersion()),
config(proFileNode->variableValue(ConfigVar)),
modified(true)
{
}
const Qt4ProjectType projectType;
const QString proFilePath;
const QString projectName;
const Qt4ProjectManager::TargetInformation targetInfo;
const Qt4ProjectManager::InstallsList installsList;
const Qt4ProjectManager::ProjectVersion projectVersion;
const QStringList config;
QList<DeployableFile> deployables;
bool modified;
};
} // namespace Internal
using namespace Internal;
DeployableFilesPerProFile::DeployableFilesPerProFile(const Qt4ProFileNode *proFileNode,
QObject *parent)
: QAbstractTableModel(parent),
m_projectType(proFileNode->projectType()),
m_proFilePath(proFileNode->path()),
m_projectName(proFileNode->displayName()),
m_targetInfo(proFileNode->targetInformation()),
m_installsList(proFileNode->installsList()),
m_projectVersion(proFileNode->projectVersion()),
m_config(proFileNode->variableValue(ConfigVar)),
m_modified(true)
: QAbstractTableModel(parent), m_d(new DeployableFilesPerProFilePrivate(proFileNode))
{
if (m_projectType == ApplicationTemplate) {
m_deployables.prepend(DeployableFile(localExecutableFilePath(),
m_installsList.targetPath));
} else if (m_projectType == LibraryTemplate) {
if (m_d->projectType == ApplicationTemplate) {
m_d->deployables.prepend(DeployableFile(localExecutableFilePath(),
m_d->installsList.targetPath));
} else if (m_d->projectType == LibraryTemplate) {
foreach (const QString &filePath, localLibraryFilePaths()) {
m_deployables.prepend(DeployableFile(filePath,
m_installsList.targetPath));
m_d->deployables.prepend(DeployableFile(filePath,
m_d->installsList.targetPath));
}
}
foreach (const InstallsItem &elem, m_installsList.items) {
foreach (const InstallsItem &elem, m_d->installsList.items) {
foreach (const QString &file, elem.files)
m_deployables << DeployableFile(file, elem.path);
m_d->deployables << DeployableFile(file, elem.path);
}
}
DeployableFilesPerProFile::~DeployableFilesPerProFile() {}
DeployableFilesPerProFile::~DeployableFilesPerProFile()
{
delete m_d;
}
DeployableFile DeployableFilesPerProFile::deployableAt(int row) const
{
Q_ASSERT(row >= 0 && row < rowCount());
return m_deployables.at(row);
return m_d->deployables.at(row);
}
int DeployableFilesPerProFile::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_deployables.count();
return parent.isValid() ? 0 : m_d->deployables.count();
}
int DeployableFilesPerProFile::columnCount(const QModelIndex &parent) const
......@@ -91,7 +117,7 @@ QVariant DeployableFilesPerProFile::data(const QModelIndex &index, int role) con
if (!index.isValid() || index.row() >= rowCount())
return QVariant();
if (m_projectType != AuxTemplate && !hasTargetPath() && index.row() == 0
if (m_d->projectType != AuxTemplate && !hasTargetPath() && index.row() == 0
&& index.column() == 1) {
if (role == Qt::DisplayRole)
return tr("<no target path set>");
......@@ -120,34 +146,34 @@ QVariant DeployableFilesPerProFile::headerData(int section,
QString DeployableFilesPerProFile::localExecutableFilePath() const
{
if (!m_targetInfo.valid || m_projectType != ApplicationTemplate)
if (!m_d->targetInfo.valid || m_d->projectType != ApplicationTemplate)
return QString();
return QDir::cleanPath(m_targetInfo.workingDir + '/' + m_targetInfo.target);
return QDir::cleanPath(m_d->targetInfo.workingDir + '/' + m_d->targetInfo.target);
}
QStringList DeployableFilesPerProFile::localLibraryFilePaths() const
{
if (!m_targetInfo.valid || m_projectType != LibraryTemplate)
if (!m_d->targetInfo.valid || m_d->projectType != LibraryTemplate)
return QStringList();
QString basePath = m_targetInfo.workingDir + QLatin1String("/lib");
const bool isStatic = m_config.contains(QLatin1String("static"))
|| m_config.contains(QLatin1String("staticlib"));
basePath += m_targetInfo.target + QLatin1String(isStatic ? ".a" : ".so");
QString basePath = m_d->targetInfo.workingDir + QLatin1String("/lib");
const bool isStatic = m_d->config.contains(QLatin1String("static"))
|| m_d->config.contains(QLatin1String("staticlib"));
basePath += m_d->targetInfo.target + QLatin1String(isStatic ? ".a" : ".so");
basePath = QDir::cleanPath(basePath);
const QChar dot(QLatin1Char('.'));
const QString filePathMajor = basePath + dot
+ QString::number(m_projectVersion.major);
+ QString::number(m_d->projectVersion.major);
const QString filePathMinor = filePathMajor + dot
+ QString::number(m_projectVersion.minor);
+ QString::number(m_d->projectVersion.minor);
const QString filePathPatch = filePathMinor + dot
+ QString::number(m_projectVersion.patch);
+ QString::number(m_d->projectVersion.patch);
return QStringList() << filePathPatch << filePathMinor << filePathMajor
<< basePath;
}
QString DeployableFilesPerProFile::remoteExecutableFilePath() const
{
return hasTargetPath() && m_projectType == ApplicationTemplate
return hasTargetPath() && m_d->projectType == ApplicationTemplate
? deployableAt(0).remoteDir + QLatin1Char('/')
+ QFileInfo(localExecutableFilePath()).fileName()
: QString();
......@@ -155,7 +181,18 @@ QString DeployableFilesPerProFile::remoteExecutableFilePath() const
QString DeployableFilesPerProFile::projectDir() const
{
return QFileInfo(m_proFilePath).dir().path();
return QFileInfo(m_d->proFilePath).dir().path();
}
bool DeployableFilesPerProFile::hasTargetPath() const
{
return !m_d->installsList.targetPath.isEmpty();
}
bool DeployableFilesPerProFile::isModified() const { return m_d->modified; }
void DeployableFilesPerProFile::setUnModified() { m_d->modified = false; }
QString DeployableFilesPerProFile::projectName() const { return m_d->projectName; }
QString DeployableFilesPerProFile::proFilePath() const { return m_d->proFilePath; }
Qt4ProjectType DeployableFilesPerProFile::projectType() const { return m_d->projectType; }
QString DeployableFilesPerProFile::applicationName() const { return m_d->targetInfo.target; }
} // namespace RemoteLinux
......@@ -33,8 +33,6 @@
#ifndef DEPLOYABLEFILESPERPROFILE_H
#define DEPLOYABLEFILESPERPROFILE_H
#include "deployablefile.h"
#include "remotelinux_export.h"
#include <qt4projectmanager/qt4nodes.h>
......@@ -44,6 +42,11 @@
#include <QtCore/QString>
namespace RemoteLinux {
class DeployableFile;
namespace Internal {
class DeployableFilesPerProFilePrivate;
}
class REMOTELINUX_EXPORT DeployableFilesPerProFile : public QAbstractTableModel
{
......@@ -56,17 +59,17 @@ public:
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
DeployableFile deployableAt(int row) const;
bool isModified() const { return m_modified; }
void setUnModified() { m_modified = false; }
bool isModified() const;
void setUnModified();
QString localExecutableFilePath() const;
QString remoteExecutableFilePath() const;
QString projectName() const { return m_projectName; }
QString projectName() const;
QString projectDir() const;
QString proFilePath() const { return m_proFilePath; }
Qt4ProjectManager::Qt4ProjectType projectType() const { return m_projectType; }
bool isApplicationProject() const { return m_projectType == Qt4ProjectManager::ApplicationTemplate; }
QString applicationName() const { return m_targetInfo.target; }
bool hasTargetPath() const { return !m_installsList.targetPath.isEmpty(); }
QString proFilePath() const;
Qt4ProjectManager::Qt4ProjectType projectType() const;
bool isApplicationProject() const { return projectType() == Qt4ProjectManager::ApplicationTemplate; }
QString applicationName() const;
bool hasTargetPath() const;
private:
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -77,15 +80,7 @@ private:
QStringList localLibraryFilePaths() const;
const Qt4ProjectManager::Qt4ProjectType m_projectType;
const QString m_proFilePath;
const QString m_projectName;
const Qt4ProjectManager::TargetInformation m_targetInfo;
const Qt4ProjectManager::InstallsList m_installsList;
const Qt4ProjectManager::ProjectVersion m_projectVersion;
const QStringList m_config;
QList<DeployableFile> m_deployables;
bool m_modified;
Internal::DeployableFilesPerProFilePrivate * const m_d;
};
} // namespace RemoteLinux
......
......@@ -39,60 +39,76 @@
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4target.h>
#include <QtCore/QList>
#include <QtCore/QTimer>
using namespace Qt4ProjectManager;
namespace RemoteLinux {
namespace Internal {
class DeploymentInfoPrivate
{
public:
DeploymentInfoPrivate(const Qt4BaseTarget *target) : target(target) {}
QList<DeployableFilesPerProFile *> listModels;
const Qt4ProjectManager::Qt4BaseTarget * const target;
QTimer updateTimer;
};
} // namespace Internal
using namespace Internal;
DeploymentInfo::DeploymentInfo(const Qt4BaseTarget *target)
: m_target(target), m_updateTimer(new QTimer(this))
DeploymentInfo::DeploymentInfo(const Qt4BaseTarget *target) : m_d(new DeploymentInfoPrivate(target))
{
Qt4Project * const pro = m_target->qt4Project();
Qt4Project * const pro = m_d->target->qt4Project();
connect(pro, SIGNAL(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)),
this, SLOT(startTimer(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
m_updateTimer->setInterval(1500);
m_updateTimer->setSingleShot(true);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(createModels()));
SLOT(startTimer(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
m_d->updateTimer.setInterval(1500);
m_d->updateTimer.setSingleShot(true);
connect(&m_d->updateTimer, SIGNAL(timeout()), this, SLOT(createModels()));
createModels();
}
DeploymentInfo::~DeploymentInfo() {}
DeploymentInfo::~DeploymentInfo()
{
delete m_d;
}
void DeploymentInfo::startTimer(Qt4ProjectManager::Qt4ProFileNode*, bool success, bool parseInProgress)
{
Q_UNUSED(success)
if (!parseInProgress)
m_updateTimer->start();
m_d->updateTimer.start();
}
void DeploymentInfo::createModels()
{
if (m_target->project()->activeTarget() != m_target)
if (m_d->target->project()->activeTarget() != m_d->target)
return;
if (!m_target->activeBuildConfiguration() || !m_target->activeBuildConfiguration()->qtVersion()
|| !m_target->activeBuildConfiguration()->qtVersion()->isValid()) {
if (!m_d->target->activeBuildConfiguration() || !m_d->target->activeBuildConfiguration()->qtVersion()
|| !m_d->target->activeBuildConfiguration()->qtVersion()->isValid()) {
beginResetModel();
qDeleteAll(m_listModels);
m_listModels.clear();
qDeleteAll(m_d->listModels);
m_d->listModels.clear();
endResetModel();
return;
}
const Qt4ProFileNode *const rootNode
= m_target->qt4Project()->rootProjectNode();
= m_d->target->qt4Project()->rootProjectNode();
if (!rootNode || rootNode->parseInProgress()) // Can be null right after project creation by wizard.
return;
m_updateTimer->stop();
disconnect(m_target->qt4Project(),
m_d->updateTimer.stop();
disconnect(m_d->target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)),
this, SLOT(startTimer(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
beginResetModel();
qDeleteAll(m_listModels);
m_listModels.clear();
qDeleteAll(m_d->listModels);
m_d->listModels.clear();
createModels(rootNode);
endResetModel();
connect(m_target->qt4Project(),
connect(m_d->target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)),
this, SLOT(startTimer(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
}
......@@ -103,12 +119,12 @@ void DeploymentInfo::createModels(const Qt4ProFileNode *proFileNode)
case ApplicationTemplate:
case LibraryTemplate:
case AuxTemplate:
m_listModels << new DeployableFilesPerProFile(proFileNode, this);
m_d->listModels << new DeployableFilesPerProFile(proFileNode, this);
break;
case SubDirsTemplate: {
const QList<ProjectExplorer::ProjectNode *> &subProjects
= proFileNode->subProjectNodes();
foreach (const ProjectExplorer::ProjectNode *subProject, subProjects) {
foreach (const ProjectExplorer::ProjectNode * const subProject, subProjects) {
const Qt4ProFileNode * const qt4SubProject
= qobject_cast<const Qt4ProFileNode *>(subProject);
if (qt4SubProject && !qt4SubProject->path()
......@@ -123,13 +139,13 @@ void DeploymentInfo::createModels(const Qt4ProFileNode *proFileNode)
void DeploymentInfo::setUnmodified()
{
foreach (DeployableFilesPerProFile *model, m_listModels)
foreach (DeployableFilesPerProFile * const model, m_d->listModels)
model->setUnModified();
}
bool DeploymentInfo::isModified() const
{
foreach (const DeployableFilesPerProFile *model, m_listModels) {
foreach (const DeployableFilesPerProFile * const model, m_d->listModels) {
if (model->isModified())
return true;
}
......@@ -139,14 +155,14 @@ bool DeploymentInfo::isModified() const
int DeploymentInfo::deployableCount() const
{
int count = 0;
foreach (const DeployableFilesPerProFile *model, m_listModels)
foreach (const DeployableFilesPerProFile * const model, m_d->listModels)
count += model->rowCount();
return count;
}
DeployableFile DeploymentInfo::deployableAt(int i) const
{
foreach (const DeployableFilesPerProFile *model, m_listModels) {
foreach (const DeployableFilesPerProFile * const model, m_d->listModels) {
Q_ASSERT(i >= 0);
if (i < model->rowCount())
return model->deployableAt(i);
......@@ -159,7 +175,7 @@ DeployableFile DeploymentInfo::deployableAt(int i) const
QString DeploymentInfo::remoteExecutableFilePath(const QString &localExecutableFilePath) const
{
foreach (const DeployableFilesPerProFile *model, m_listModels) {
foreach (const DeployableFilesPerProFile * const model, m_d->listModels) {
if (model->localExecutableFilePath() == localExecutableFilePath)
return model->remoteExecutableFilePath();
}
......@@ -176,7 +192,7 @@ QVariant DeploymentInfo::data(const QModelIndex &index, int role) const
if (!index.isValid() || index.row() < 0 || index.row() >= modelCount()
|| index.column() != 0)
return QVariant();
const DeployableFilesPerProFile *const model = m_listModels.at(index.row());
const DeployableFilesPerProFile * const model = m_d->listModels.at(index.row());
if (role == Qt::ForegroundRole && model->projectType() != AuxTemplate
&& !model->hasTargetPath()) {
QBrush brush;
......@@ -188,4 +204,7 @@ QVariant DeploymentInfo::data(const QModelIndex &index, int role) const
return QVariant();
}
int DeploymentInfo::modelCount() const { return m_d->listModels.count(); }
DeployableFilesPerProFile *DeploymentInfo::modelAt(int i) const { return m_d->listModels.at(i); }
} // namespace RemoteLinux
......@@ -35,9 +35,6 @@
#include "remotelinux_export.h"
#include <QtCore/QAbstractListModel>
#include <QtCore/QList>
QT_FORWARD_DECLARE_CLASS(QTimer)
namespace Qt4ProjectManager {
class Qt4BaseTarget;
......@@ -48,19 +45,24 @@ namespace RemoteLinux {
class DeployableFile;
class DeployableFilesPerProFile;
namespace Internal {
class DeploymentInfoPrivate;
}
class REMOTELINUX_EXPORT DeploymentInfo : public QAbstractListModel
{
Q_OBJECT
public:
DeploymentInfo(const Qt4ProjectManager::Qt4BaseTarget *target);
~DeploymentInfo();
void setUnmodified();
bool isModified() const;
int deployableCount() const;
DeployableFile deployableAt(int i) const;
QString remoteExecutableFilePath(const QString &localExecutableFilePath) const;
int modelCount() const { return m_listModels.count(); }
DeployableFilesPerProFile *modelAt(int i) const { return m_listModels.at(i); }
int modelCount() const;
DeployableFilesPerProFile *modelAt(int i) const;
private slots:
void startTimer(Qt4ProjectManager::Qt4ProFileNode *, bool success, bool parseInProgress);
......@@ -72,9 +74,7 @@ private:
Q_SLOT void createModels();
void createModels(const Qt4ProjectManager::Qt4ProFileNode *proFileNode);
QList<DeployableFilesPerProFile *> m_listModels;
const Qt4ProjectManager::Qt4BaseTarget * const m_target;
QTimer *const m_updateTimer;
Internal::DeploymentInfoPrivate * const m_d;
};
} // namespace RemoteLinux
......
......@@ -49,7 +49,7 @@ class REMOTELINUX_EXPORT GenericDirectUploadService : public AbstractRemoteLinux
{
Q_OBJECT
public:
GenericDirectUploadService(QObject *parent);
GenericDirectUploadService(QObject *parent = 0);
void setDeployableFiles(const QList<DeployableFile> &deployableFiles);
......
......@@ -40,6 +40,13 @@
#include <QtCore/QSharedPointer>
namespace RemoteLinux {
namespace Internal {
class GenericDirectUploadStepPrivate
{
public:
GenericDirectUploadService deployService;
};
} // namespace Internal
GenericDirectUploadStep::GenericDirectUploadStep(ProjectExplorer::BuildStepList *bsl, const QString &id)
: AbstractRemoteLinuxDeployStep(bsl, id)
......@@ -53,6 +60,11 @@ GenericDirectUploadStep::GenericDirectUploadStep(ProjectExplorer::BuildStepList
ctor();
}
GenericDirectUploadStep::~GenericDirectUploadStep()
{
delete m_d;
}
bool GenericDirectUploadStep::isDeploymentPossible(QString *whyNot) const
{
QList<DeployableFile> deployableFiles;
......@@ -60,19 +72,19 @@ bool GenericDirectUploadStep::isDeploymentPossible(QString *whyNot) const
const int deployableCount = deploymentInfo->deployableCount();
for (int i = 0; i < deployableCount; ++i)
deployableFiles << deploymentInfo->deployableAt(i);
m_deployService->setDeployableFiles(deployableFiles);
m_d->deployService.setDeployableFiles(deployableFiles);
return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot);
}
AbstractRemoteLinuxDeployService *GenericDirectUploadStep::deployService() const
{
return m_deployService;
return &m_d->deployService;
}
void GenericDirectUploadStep::ctor()
{
setDefaultDisplayName(displayName());
m_deployService = new GenericDirectUploadService(this);
m_d = new Internal::GenericDirectUploadStepPrivate;
}
QString GenericDirectUploadStep::stepId()
......
......@@ -36,7 +36,9 @@
#include "remotelinux_export.h"
namespace RemoteLinux {
class GenericDirectUploadService;
namespace Internal {
class GenericDirectUploadStepPrivate;
}
class REMOTELINUX_EXPORT GenericDirectUploadStep : public AbstractRemoteLinuxDeployStep
{
......@@ -45,6 +47,7 @@ class REMOTELINUX_EXPORT GenericDirectUploadStep : public AbstractRemoteLinuxDep
public: