diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79f035e23c63886d5073ece982e6ac97d7c17f0c --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp @@ -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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h new file mode 100644 index 0000000000000000000000000000000000000000..0901129f53b0991146d8f8654b78fc28c5175405 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h @@ -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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index 5270f0b119b53adbaaf908897c3176aa07cc6f55..b873f66b7e6a279660b2e71eb98603a70f56579e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -43,6 +43,7 @@ #include "maemoconstants.h" #include "maemopackagecreationwidget.h" +#include "maemopackagecontents.h" #include "maemotoolchain.h" #include <projectexplorer/projectexplorerconstants.h> @@ -67,13 +68,16 @@ namespace Qt4ProjectManager { namespace Internal { MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig) - : ProjectExplorer::BuildStep(buildConfig, CreatePackageId) + : ProjectExplorer::BuildStep(buildConfig, CreatePackageId), + m_packageContents(new MaemoPackageContents(this)) { } MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig, 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(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5")); - const QString projectDir = QFileInfo(executable()).absolutePath(); + const QString projectDir = QFileInfo(localExecutableFilePath()).absolutePath(); env.insert(QLatin1String("PWD"), projectDir); const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*")); @@ -161,7 +165,7 @@ bool MaemoPackageCreationStep::createPackage() return false; const QString targetFile(projectDir % QLatin1String("/debian/") - % executableFileName().toLower() % executableFilePathOnTarget()); + % executableFileName().toLower() % remoteExecutableFilePath()); if (QFile::exists(targetFile)) { if (!QFile::remove(targetFile)) { raiseError(tr("Packaging Error: Could not replace file '%1'.") @@ -169,9 +173,9 @@ bool MaemoPackageCreationStep::createPackage() return false; } } - if (!QFile::copy(executable(), targetFile)) { + if (!QFile::copy(localExecutableFilePath(), targetFile)) { raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.") - .arg(QDir::toNativeSeparators(executable())) + .arg(QDir::toNativeSeparators(localExecutableFilePath())) .arg(QDir::toNativeSeparators(targetFile))); return false; } @@ -186,6 +190,7 @@ bool MaemoPackageCreationStep::createPackage() } emit addOutput(tr("Package created.")); + m_packageContents->setUnModified(); return true; } @@ -219,7 +224,7 @@ const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() c return static_cast<Qt4BuildConfiguration *>(buildConfiguration()); } -QString MaemoPackageCreationStep::executable() const +QString MaemoPackageCreationStep::localExecutableFilePath() const { const TargetInformation &ti = qt4BuildConfiguration()->qt4Target() ->qt4Project()->rootProjectNode()->targetInformation(); @@ -232,7 +237,7 @@ QString MaemoPackageCreationStep::executable() const QString MaemoPackageCreationStep::executableFileName() const { - return QFileInfo(executable()).fileName(); + return QFileInfo(localExecutableFilePath()).fileName(); } const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const @@ -252,25 +257,28 @@ QString MaemoPackageCreationStep::targetRoot() 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()); - return !packageInfo.exists() - || packageInfo.lastModified() <= QFileInfo(executable()).lastModified(); + if (!packageInfo.exists() || m_packageContents->isModified()) + 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 { - QFileInfo execInfo(executable()); + QFileInfo execInfo(localExecutableFilePath()); return execInfo.path() % QDir::separator() % execInfo.fileName().toLower() % versionString() % QLatin1String("_armel.deb"); } -QString MaemoPackageCreationStep::executableFilePathOnTarget() const +QString MaemoPackageCreationStep::remoteExecutableFilePath() const { return QLatin1String("/usr/bin/") % executableFileName(); } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h index 0e8f7ca740f7c129387a2fa3408dcd4894c41f5e..a38a5025c4c8fecac90b7a8babe6d75e0625fa9a 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h @@ -52,6 +52,7 @@ QT_END_NAMESPACE namespace Qt4ProjectManager { namespace Internal { +class MaemoPackageContents; class MaemoToolChain; class Qt4BuildConfiguration; @@ -63,7 +64,9 @@ public: MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig); QString packageFilePath() const; - QString executableFilePathOnTarget() const; + QString remoteExecutableFilePath() const; + QString localExecutableFilePath() const; + private: MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig, MaemoPackageCreationStep *other); @@ -77,7 +80,6 @@ private: bool runCommand(QProcess &proc, const QString &command); const Qt4BuildConfiguration *qt4BuildConfiguration() const; const MaemoToolChain *maemoToolChain() const; - QString executable() const; QString executableFileName() const; QString maddeRoot() const; QString targetRoot() const; @@ -88,6 +90,8 @@ private: const QString &detailedMsg = QString()); static const QLatin1String CreatePackageId; + + MaemoPackageContents *const m_packageContents; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index 4685fa180ceaa485870bb68556b7b0a9d359db62..6fe2e12dfce6e7ff309ef1491f3f1faff460d06f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -198,7 +198,7 @@ QString AbstractMaemoRunControl::packageFilePath() const QString AbstractMaemoRunControl::executableFilePathOnTarget() const { - return m_runConfig->packageStep()->executableFilePathOnTarget(); + return m_runConfig->packageStep()->remoteExecutableFilePath(); } bool AbstractMaemoRunControl::isCleaning() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp index 11aa4cb85f5204128b548c7795408844de22620d..50c117889fdfa266ec81c4d5123a969dcf290f26 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp @@ -147,7 +147,7 @@ void MaemoInteractiveSshConnection::runCommand(const QString &command) int endMarkerCount = 0; 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(); if (error) throw MaemoSshException(tr("SSH error: %1").arg(error)); diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 83ce4a5e378b77f8145f11d019dc1279ad63ba05..a970764cfc24435d9c4d7e00d7641abef6bb3bae 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -20,7 +20,8 @@ HEADERS += \ $$PWD/maemopackagecreationstep.h \ $$PWD/maemopackagecreationfactory.h \ $$PWD/ne7sshobject.h \ - $$PWD/maemopackagecreationwidget.h + $$PWD/maemopackagecreationwidget.h \ + $$PWD/maemopackagecontents.h SOURCES += \ $$PWD/maemoconfigtestdialog.cpp \ @@ -39,7 +40,8 @@ SOURCES += \ $$PWD/maemopackagecreationstep.cpp \ $$PWD/maemopackagecreationfactory.cpp \ $$PWD/ne7sshobject.cpp \ - $$PWD/maemopackagecreationwidget.cpp + $$PWD/maemopackagecreationwidget.cpp \ + $$PWD/maemopackagecontents.cpp FORMS += \ $$PWD/maemoconfigtestdialog.ui \