forked from qt-creator/qt-creator
Maemo: Add model for future package contents view.
No functional changes for now. Reviewed-by: kh1
This commit is contained in:
@@ -0,0 +1,74 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "maemopackagecontents.h"
|
||||||
|
|
||||||
|
#include "maemopackagecreationstep.h"
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
MaemoPackageContents::MaemoPackageContents(MaemoPackageCreationStep *packageStep)
|
||||||
|
: QAbstractTableModel(packageStep),
|
||||||
|
m_packageStep(packageStep),
|
||||||
|
m_modified(true) // TODO: Has to come from settings
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MaemoPackageContents::Deployable MaemoPackageContents::deployableAt(int row) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(row >= 0 && row < rowCount());
|
||||||
|
return row == 0
|
||||||
|
? Deployable(m_packageStep->localExecutableFilePath(),
|
||||||
|
m_packageStep->remoteExecutableFilePath())
|
||||||
|
: m_deployables.at(row - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MaemoPackageContents::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return parent.isValid() ? 0 : m_deployables.count() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MaemoPackageContents::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return parent.isValid() ? 0 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant MaemoPackageContents::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid() || role != Qt::DisplayRole
|
||||||
|
|| index.row() >= rowCount())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
const Deployable &d = deployableAt(index.row());
|
||||||
|
return index.column() == 0 ? d.localFilePath : d.remoteFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
|
} // namespace Internal
|
@@ -0,0 +1,80 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef MAEMOPACKAGECONTENTS_H
|
||||||
|
#define MAEMOPACKAGECONTENTS_H
|
||||||
|
|
||||||
|
#include <QtCore/QAbstractTableModel>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class MaemoPackageCreationStep;
|
||||||
|
|
||||||
|
class MaemoPackageContents : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Deployable
|
||||||
|
{
|
||||||
|
Deployable(const QString &localFilePath, const QString &remoteFilePath)
|
||||||
|
: localFilePath(localFilePath), remoteFilePath(remoteFilePath) {}
|
||||||
|
QString localFilePath;
|
||||||
|
QString remoteFilePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
||||||
|
|
||||||
|
Deployable deployableAt(int row) const;
|
||||||
|
bool isModified() const { return m_modified; }
|
||||||
|
void setUnModified() { m_modified = false; }
|
||||||
|
|
||||||
|
// TODO: to/from map
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
virtual QVariant data(const QModelIndex &index,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
// TODO: setData
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
const MaemoPackageCreationStep * const m_packageStep;
|
||||||
|
QList<Deployable> m_deployables;
|
||||||
|
bool m_modified;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
#endif // MAEMOPACKAGECONTENTS_H
|
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
#include "maemoconstants.h"
|
#include "maemoconstants.h"
|
||||||
#include "maemopackagecreationwidget.h"
|
#include "maemopackagecreationwidget.h"
|
||||||
|
#include "maemopackagecontents.h"
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
@@ -67,13 +68,16 @@ namespace Qt4ProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig)
|
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig)
|
||||||
: ProjectExplorer::BuildStep(buildConfig, CreatePackageId)
|
: ProjectExplorer::BuildStep(buildConfig, CreatePackageId),
|
||||||
|
m_packageContents(new MaemoPackageContents(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig,
|
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig,
|
||||||
MaemoPackageCreationStep *other)
|
MaemoPackageCreationStep *other)
|
||||||
: BuildStep(buildConfig, other)
|
: BuildStep(buildConfig, other),
|
||||||
|
m_packageContents(new MaemoPackageContents(this))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -119,7 +123,7 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
env.insert(key, path % QLatin1String("madbin") % colon % env.value(key));
|
env.insert(key, path % QLatin1String("madbin") % colon % env.value(key));
|
||||||
env.insert(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5"));
|
env.insert(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5"));
|
||||||
|
|
||||||
const QString projectDir = QFileInfo(executable()).absolutePath();
|
const QString projectDir = QFileInfo(localExecutableFilePath()).absolutePath();
|
||||||
env.insert(QLatin1String("PWD"), projectDir);
|
env.insert(QLatin1String("PWD"), projectDir);
|
||||||
|
|
||||||
const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*"));
|
const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*"));
|
||||||
@@ -161,7 +165,7 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString targetFile(projectDir % QLatin1String("/debian/")
|
const QString targetFile(projectDir % QLatin1String("/debian/")
|
||||||
% executableFileName().toLower() % executableFilePathOnTarget());
|
% executableFileName().toLower() % remoteExecutableFilePath());
|
||||||
if (QFile::exists(targetFile)) {
|
if (QFile::exists(targetFile)) {
|
||||||
if (!QFile::remove(targetFile)) {
|
if (!QFile::remove(targetFile)) {
|
||||||
raiseError(tr("Packaging Error: Could not replace file '%1'.")
|
raiseError(tr("Packaging Error: Could not replace file '%1'.")
|
||||||
@@ -169,9 +173,9 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!QFile::copy(executable(), targetFile)) {
|
if (!QFile::copy(localExecutableFilePath(), targetFile)) {
|
||||||
raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
|
raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
|
||||||
.arg(QDir::toNativeSeparators(executable()))
|
.arg(QDir::toNativeSeparators(localExecutableFilePath()))
|
||||||
.arg(QDir::toNativeSeparators(targetFile)));
|
.arg(QDir::toNativeSeparators(targetFile)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -186,6 +190,7 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit addOutput(tr("Package created."));
|
emit addOutput(tr("Package created."));
|
||||||
|
m_packageContents->setUnModified();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +224,7 @@ const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() c
|
|||||||
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoPackageCreationStep::executable() const
|
QString MaemoPackageCreationStep::localExecutableFilePath() const
|
||||||
{
|
{
|
||||||
const TargetInformation &ti = qt4BuildConfiguration()->qt4Target()
|
const TargetInformation &ti = qt4BuildConfiguration()->qt4Target()
|
||||||
->qt4Project()->rootProjectNode()->targetInformation();
|
->qt4Project()->rootProjectNode()->targetInformation();
|
||||||
@@ -232,7 +237,7 @@ QString MaemoPackageCreationStep::executable() const
|
|||||||
|
|
||||||
QString MaemoPackageCreationStep::executableFileName() const
|
QString MaemoPackageCreationStep::executableFileName() const
|
||||||
{
|
{
|
||||||
return QFileInfo(executable()).fileName();
|
return QFileInfo(localExecutableFilePath()).fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const
|
const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const
|
||||||
@@ -252,25 +257,28 @@ QString MaemoPackageCreationStep::targetRoot() const
|
|||||||
|
|
||||||
bool MaemoPackageCreationStep::packagingNeeded() const
|
bool MaemoPackageCreationStep::packagingNeeded() const
|
||||||
{
|
{
|
||||||
// TODO: When the package contents get user-modifiable, we need
|
|
||||||
// to check whether files have been added and/or removed and whether
|
|
||||||
// the newest one is newer than the package.
|
|
||||||
// For the first check, we should have a switch that the widget sets
|
|
||||||
// to true when the user has changed the package contents and which
|
|
||||||
// we set to false after a successful package creation.
|
|
||||||
QFileInfo packageInfo(packageFilePath());
|
QFileInfo packageInfo(packageFilePath());
|
||||||
return !packageInfo.exists()
|
if (!packageInfo.exists() || m_packageContents->isModified())
|
||||||
|| packageInfo.lastModified() <= QFileInfo(executable()).lastModified();
|
return true;
|
||||||
|
|
||||||
|
for (int i = 0; i < m_packageContents->rowCount(); ++i) {
|
||||||
|
if (packageInfo.lastModified()
|
||||||
|
<= QFileInfo(m_packageContents->deployableAt(i).localFilePath)
|
||||||
|
.lastModified())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoPackageCreationStep::packageFilePath() const
|
QString MaemoPackageCreationStep::packageFilePath() const
|
||||||
{
|
{
|
||||||
QFileInfo execInfo(executable());
|
QFileInfo execInfo(localExecutableFilePath());
|
||||||
return execInfo.path() % QDir::separator() % execInfo.fileName().toLower()
|
return execInfo.path() % QDir::separator() % execInfo.fileName().toLower()
|
||||||
% versionString() % QLatin1String("_armel.deb");
|
% versionString() % QLatin1String("_armel.deb");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoPackageCreationStep::executableFilePathOnTarget() const
|
QString MaemoPackageCreationStep::remoteExecutableFilePath() const
|
||||||
{
|
{
|
||||||
return QLatin1String("/usr/bin/") % executableFileName();
|
return QLatin1String("/usr/bin/") % executableFileName();
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,7 @@ QT_END_NAMESPACE
|
|||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class MaemoPackageContents;
|
||||||
class MaemoToolChain;
|
class MaemoToolChain;
|
||||||
class Qt4BuildConfiguration;
|
class Qt4BuildConfiguration;
|
||||||
|
|
||||||
@@ -63,7 +64,9 @@ public:
|
|||||||
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig);
|
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig);
|
||||||
|
|
||||||
QString packageFilePath() const;
|
QString packageFilePath() const;
|
||||||
QString executableFilePathOnTarget() const;
|
QString remoteExecutableFilePath() const;
|
||||||
|
QString localExecutableFilePath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
|
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
|
||||||
MaemoPackageCreationStep *other);
|
MaemoPackageCreationStep *other);
|
||||||
@@ -77,7 +80,6 @@ private:
|
|||||||
bool runCommand(QProcess &proc, const QString &command);
|
bool runCommand(QProcess &proc, const QString &command);
|
||||||
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
|
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
|
||||||
const MaemoToolChain *maemoToolChain() const;
|
const MaemoToolChain *maemoToolChain() const;
|
||||||
QString executable() const;
|
|
||||||
QString executableFileName() const;
|
QString executableFileName() const;
|
||||||
QString maddeRoot() const;
|
QString maddeRoot() const;
|
||||||
QString targetRoot() const;
|
QString targetRoot() const;
|
||||||
@@ -88,6 +90,8 @@ private:
|
|||||||
const QString &detailedMsg = QString());
|
const QString &detailedMsg = QString());
|
||||||
|
|
||||||
static const QLatin1String CreatePackageId;
|
static const QLatin1String CreatePackageId;
|
||||||
|
|
||||||
|
MaemoPackageContents *const m_packageContents;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -198,7 +198,7 @@ QString AbstractMaemoRunControl::packageFilePath() const
|
|||||||
|
|
||||||
QString AbstractMaemoRunControl::executableFilePathOnTarget() const
|
QString AbstractMaemoRunControl::executableFilePathOnTarget() const
|
||||||
{
|
{
|
||||||
return m_runConfig->packageStep()->executableFilePathOnTarget();
|
return m_runConfig->packageStep()->remoteExecutableFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractMaemoRunControl::isCleaning() const
|
bool AbstractMaemoRunControl::isCleaning() const
|
||||||
|
@@ -147,7 +147,7 @@ void MaemoInteractiveSshConnection::runCommand(const QString &command)
|
|||||||
|
|
||||||
int endMarkerCount = 0;
|
int endMarkerCount = 0;
|
||||||
do {
|
do {
|
||||||
ssh->waitFor(channel(), endMarker.toUtf8(), 1);
|
ssh->waitFor(channel(), endMarker.toUtf8(), 1); // TODO: Hack net7 to get rid of busy loop.
|
||||||
const char * const error = lastError();
|
const char * const error = lastError();
|
||||||
if (error)
|
if (error)
|
||||||
throw MaemoSshException(tr("SSH error: %1").arg(error));
|
throw MaemoSshException(tr("SSH error: %1").arg(error));
|
||||||
|
@@ -20,7 +20,8 @@ HEADERS += \
|
|||||||
$$PWD/maemopackagecreationstep.h \
|
$$PWD/maemopackagecreationstep.h \
|
||||||
$$PWD/maemopackagecreationfactory.h \
|
$$PWD/maemopackagecreationfactory.h \
|
||||||
$$PWD/ne7sshobject.h \
|
$$PWD/ne7sshobject.h \
|
||||||
$$PWD/maemopackagecreationwidget.h
|
$$PWD/maemopackagecreationwidget.h \
|
||||||
|
$$PWD/maemopackagecontents.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/maemoconfigtestdialog.cpp \
|
$$PWD/maemoconfigtestdialog.cpp \
|
||||||
@@ -39,7 +40,8 @@ SOURCES += \
|
|||||||
$$PWD/maemopackagecreationstep.cpp \
|
$$PWD/maemopackagecreationstep.cpp \
|
||||||
$$PWD/maemopackagecreationfactory.cpp \
|
$$PWD/maemopackagecreationfactory.cpp \
|
||||||
$$PWD/ne7sshobject.cpp \
|
$$PWD/ne7sshobject.cpp \
|
||||||
$$PWD/maemopackagecreationwidget.cpp
|
$$PWD/maemopackagecreationwidget.cpp \
|
||||||
|
$$PWD/maemopackagecontents.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/maemoconfigtestdialog.ui \
|
$$PWD/maemoconfigtestdialog.ui \
|
||||||
|
Reference in New Issue
Block a user