2011-04-13 08:42:33 +02:00
|
|
|
/**************************************************************************
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file is part of Qt Creator
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-04-13 08:42:33 +02:00
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-07-06 12:04:53 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2010-07-06 12:04:53 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
**************************************************************************/
|
2010-07-06 12:04:53 +02:00
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
#include "deploymentinfo.h"
|
2010-07-06 12:04:53 +02:00
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
#include "deployablefile.h"
|
2011-08-01 16:44:59 +02:00
|
|
|
#include "deployablefilesperprofile.h"
|
2010-07-07 14:50:37 +02:00
|
|
|
|
2010-07-14 12:21:35 +02:00
|
|
|
#include <projectexplorer/buildstep.h>
|
2010-07-07 14:50:37 +02:00
|
|
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
|
|
|
|
#include <qt4projectmanager/qt4project.h>
|
2011-03-09 12:07:35 +01:00
|
|
|
#include <qt4projectmanager/qt4target.h>
|
2010-07-07 14:50:37 +02:00
|
|
|
|
2011-08-02 12:20:16 +02:00
|
|
|
#include <QtCore/QList>
|
2010-07-07 14:50:37 +02:00
|
|
|
#include <QtCore/QTimer>
|
2010-07-06 12:04:53 +02:00
|
|
|
|
2011-05-25 11:23:25 +02:00
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
2011-08-02 12:20:16 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
class DeploymentInfoPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DeploymentInfoPrivate(const Qt4BaseTarget *target) : target(target) {}
|
|
|
|
|
|
|
|
|
|
QList<DeployableFilesPerProFile *> listModels;
|
|
|
|
|
const Qt4ProjectManager::Qt4BaseTarget * const target;
|
|
|
|
|
};
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
using namespace Internal;
|
2010-07-06 12:04:53 +02:00
|
|
|
|
2011-09-15 09:10:10 +02:00
|
|
|
DeploymentInfo::DeploymentInfo(const Qt4BaseTarget *target) : d(new DeploymentInfoPrivate(target))
|
2010-07-07 14:50:37 +02:00
|
|
|
{
|
2011-09-19 12:40:27 +02:00
|
|
|
connect (d->target->qt4Project(), SIGNAL(proParsingDone()), SLOT(createModels()));
|
2011-06-24 09:25:13 +02:00
|
|
|
createModels();
|
2010-07-26 17:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-02 12:20:16 +02:00
|
|
|
DeploymentInfo::~DeploymentInfo()
|
|
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
delete d;
|
2011-08-02 12:20:16 +02:00
|
|
|
}
|
2010-07-27 17:27:04 +02:00
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
void DeploymentInfo::createModels()
|
2010-07-07 14:50:37 +02:00
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
if (d->target->project()->activeTarget() != d->target)
|
2010-10-11 15:40:25 +02:00
|
|
|
return;
|
2011-09-15 09:10:10 +02:00
|
|
|
const Qt4BuildConfiguration *bc = d->target->activeQt4BuildConfiguration();
|
2011-08-18 16:46:44 +02:00
|
|
|
if (!bc || !bc->qtVersion() || !bc->qtVersion()->isValid()) {
|
2011-07-08 13:51:32 +02:00
|
|
|
beginResetModel();
|
2011-09-15 09:10:10 +02:00
|
|
|
qDeleteAll(d->listModels);
|
|
|
|
|
d->listModels.clear();
|
2011-07-08 13:51:32 +02:00
|
|
|
endResetModel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-10-14 14:03:55 +02:00
|
|
|
const Qt4ProFileNode *const rootNode
|
2011-09-15 09:10:10 +02:00
|
|
|
= d->target->qt4Project()->rootQt4ProjectNode();
|
2011-06-23 16:13:42 +02:00
|
|
|
if (!rootNode || rootNode->parseInProgress()) // Can be null right after project creation by wizard.
|
2010-10-14 14:03:55 +02:00
|
|
|
return;
|
2011-09-19 12:40:27 +02:00
|
|
|
disconnect(d->target->qt4Project(), SIGNAL(proParsingDone()), this, SLOT(createModels()));
|
2010-10-14 14:03:55 +02:00
|
|
|
beginResetModel();
|
2011-09-15 09:10:10 +02:00
|
|
|
qDeleteAll(d->listModels);
|
|
|
|
|
d->listModels.clear();
|
2010-10-11 15:40:25 +02:00
|
|
|
createModels(rootNode);
|
2010-10-14 14:03:55 +02:00
|
|
|
endResetModel();
|
2011-09-19 12:40:27 +02:00
|
|
|
connect (d->target->qt4Project(), SIGNAL(proParsingDone()), SLOT(createModels()));
|
2010-07-07 14:50:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
void DeploymentInfo::createModels(const Qt4ProFileNode *proFileNode)
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
2010-10-11 15:40:25 +02:00
|
|
|
switch (proFileNode->projectType()) {
|
2010-07-07 14:50:37 +02:00
|
|
|
case ApplicationTemplate:
|
|
|
|
|
case LibraryTemplate:
|
2011-08-01 16:44:59 +02:00
|
|
|
case AuxTemplate:
|
2011-09-15 09:10:10 +02:00
|
|
|
d->listModels << new DeployableFilesPerProFile(proFileNode, this);
|
2010-07-07 14:50:37 +02:00
|
|
|
break;
|
|
|
|
|
case SubDirsTemplate: {
|
2011-09-07 15:48:10 +02:00
|
|
|
const QList<Qt4PriFileNode *> &subProjects = proFileNode->subProjectNodesExact();
|
2011-08-02 12:20:16 +02:00
|
|
|
foreach (const ProjectExplorer::ProjectNode * const subProject, subProjects) {
|
2010-07-07 14:50:37 +02:00
|
|
|
const Qt4ProFileNode * const qt4SubProject
|
|
|
|
|
= qobject_cast<const Qt4ProFileNode *>(subProject);
|
2011-09-07 15:48:10 +02:00
|
|
|
if (qt4SubProject && !qt4SubProject->path().endsWith(QLatin1String(".pri")))
|
2010-07-07 14:50:37 +02:00
|
|
|
createModels(qt4SubProject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-07-06 12:04:53 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
void DeploymentInfo::setUnmodified()
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
foreach (DeployableFilesPerProFile * const model, d->listModels)
|
2010-07-06 12:04:53 +02:00
|
|
|
model->setUnModified();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
bool DeploymentInfo::isModified() const
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
foreach (const DeployableFilesPerProFile * const model, d->listModels) {
|
2010-07-06 12:04:53 +02:00
|
|
|
if (model->isModified())
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
int DeploymentInfo::deployableCount() const
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
|
|
|
|
int count = 0;
|
2011-09-15 09:10:10 +02:00
|
|
|
foreach (const DeployableFilesPerProFile * const model, d->listModels)
|
2010-07-06 12:04:53 +02:00
|
|
|
count += model->rowCount();
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
DeployableFile DeploymentInfo::deployableAt(int i) const
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
foreach (const DeployableFilesPerProFile * const model, d->listModels) {
|
2010-07-06 12:04:53 +02:00
|
|
|
Q_ASSERT(i >= 0);
|
|
|
|
|
if (i < model->rowCount())
|
|
|
|
|
return model->deployableAt(i);
|
|
|
|
|
i -= model->rowCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(!"Invalid deployable number");
|
2011-06-27 10:11:17 +02:00
|
|
|
return DeployableFile(QString(), QString());
|
2010-07-06 12:04:53 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
QString DeploymentInfo::remoteExecutableFilePath(const QString &localExecutableFilePath) const
|
2010-07-06 12:04:53 +02:00
|
|
|
{
|
2011-09-15 09:10:10 +02:00
|
|
|
foreach (const DeployableFilesPerProFile * const model, d->listModels) {
|
2010-07-06 12:04:53 +02:00
|
|
|
if (model->localExecutableFilePath() == localExecutableFilePath)
|
|
|
|
|
return model->remoteExecutableFilePath();
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
int DeploymentInfo::rowCount(const QModelIndex &parent) const
|
2010-10-14 14:03:55 +02:00
|
|
|
{
|
|
|
|
|
return parent.isValid() ? 0 : modelCount();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 10:11:17 +02:00
|
|
|
QVariant DeploymentInfo::data(const QModelIndex &index, int role) const
|
2010-10-14 14:03:55 +02:00
|
|
|
{
|
|
|
|
|
if (!index.isValid() || index.row() < 0 || index.row() >= modelCount()
|
|
|
|
|
|| index.column() != 0)
|
|
|
|
|
return QVariant();
|
2011-09-15 09:10:10 +02:00
|
|
|
const DeployableFilesPerProFile * const model = d->listModels.at(index.row());
|
2011-05-05 17:43:52 +02:00
|
|
|
if (role == Qt::ForegroundRole && model->projectType() != AuxTemplate
|
|
|
|
|
&& !model->hasTargetPath()) {
|
2010-10-14 14:03:55 +02:00
|
|
|
QBrush brush;
|
|
|
|
|
brush.setColor(Qt::red);
|
|
|
|
|
return brush;
|
|
|
|
|
}
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
|
return QFileInfo(model->proFilePath()).fileName();
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-15 09:10:10 +02:00
|
|
|
int DeploymentInfo::modelCount() const { return d->listModels.count(); }
|
|
|
|
|
DeployableFilesPerProFile *DeploymentInfo::modelAt(int i) const { return d->listModels.at(i); }
|
2011-08-02 12:20:16 +02:00
|
|
|
|
2011-05-25 11:23:25 +02:00
|
|
|
} // namespace RemoteLinux
|