From f43095ceafa77087fb467cdc534692eef301f6fb Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 6 Jul 2010 12:04:53 +0200 Subject: [PATCH] Maemo: Prepare infrastructure for proper subdirs support. No difference in functionality yet. Reviewed-by: kh1 --- .../qt-maemo/maemodeployable.h | 62 +++++++ ...tents.cpp => maemodeployablelistmodel.cpp} | 74 ++++++--- ...econtents.h => maemodeployablelistmodel.h} | 35 ++-- .../qt-maemo/maemodeployablelistwidget.cpp | 129 +++++++++++++++ .../qt-maemo/maemodeployablelistwidget.h | 78 +++++++++ .../qt-maemo/maemodeployablelistwidget.ui | 139 ++++++++++++++++ .../qt-maemo/maemodeployables.cpp | 104 ++++++++++++ .../qt-maemo/maemodeployables.h | 75 +++++++++ .../qt-maemo/maemopackagecreationstep.cpp | 35 ++-- .../qt-maemo/maemopackagecreationstep.h | 8 +- .../qt-maemo/maemopackagecreationwidget.cpp | 77 ++------- .../qt-maemo/maemopackagecreationwidget.h | 3 - .../qt-maemo/maemopackagecreationwidget.ui | 152 ++---------------- .../qt-maemo/maemorunconfiguration.h | 2 +- .../qt-maemo/maemoruncontrol.cpp | 16 +- .../qt-maemo/maemoruncontrol.h | 2 +- .../qt-maemo/profilewrapper.h | 1 + .../qt4projectmanager/qt-maemo/qt-maemo.pri | 16 +- 18 files changed, 708 insertions(+), 300 deletions(-) create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployable.h rename src/plugins/qt4projectmanager/qt-maemo/{maemopackagecontents.cpp => maemodeployablelistmodel.cpp} (67%) rename src/plugins/qt4projectmanager/qt-maemo/{maemopackagecontents.h => maemodeployablelistmodel.h} (80%) create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.h create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.ui create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployable.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployable.h new file mode 100644 index 00000000000..b9324a5aea0 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployable.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** 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 MAEMODEPLOYABLE_H +#define MAEMODEPLOYABLE_H + +#include +#include + +namespace Qt4ProjectManager { +namespace Internal { + +struct MaemoDeployable +{ + MaemoDeployable(const QString &localFilePath, const QString &remoteDir) + : localFilePath(localFilePath), remoteDir(remoteDir) {} + + bool operator==(const MaemoDeployable &other) const + { + return localFilePath == other.localFilePath + && remoteDir == other.remoteDir; + } + + QString localFilePath; + QString remoteDir; +}; + +inline uint qHash(const MaemoDeployable &d) +{ + return qHash(qMakePair(d.localFilePath, d.remoteDir)); +} + +} // namespace Qt4ProjectManager +} // namespace Internal + +#endif // MAEMODEPLOYABLE_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp similarity index 67% rename from src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp rename to src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp index 920a3408e9d..a8a26ae248b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp @@ -27,7 +27,7 @@ ** **************************************************************************/ -#include "maemopackagecontents.h" +#include "maemodeployablelistmodel.h" #include "maemopackagecreationstep.h" #include "maemotoolchain.h" @@ -44,7 +44,7 @@ namespace Qt4ProjectManager { namespace Internal { -MaemoPackageContents::MaemoPackageContents(MaemoPackageCreationStep *packageStep) +MaemoDeployableListModel::MaemoDeployableListModel(MaemoPackageCreationStep *packageStep) : QAbstractTableModel(packageStep), m_packageStep(packageStep), m_modified(false), @@ -52,17 +52,23 @@ MaemoPackageContents::MaemoPackageContents(MaemoPackageCreationStep *packageStep { } -MaemoPackageContents::~MaemoPackageContents() {} +MaemoDeployableListModel::~MaemoDeployableListModel() {} -bool MaemoPackageContents::buildModel() const +bool MaemoDeployableListModel::buildModel() const { if (m_initialized) return true; m_deployables.clear(); - QSharedPointer proFileWrapper - = m_packageStep->proFileWrapper(); - const ProFileWrapper::InstallsList &installs = proFileWrapper->installs(); + + // TODO: The pro file path comes from the outside. + if (!m_proFileWrapper) { + const Qt4ProFileNode * const proFileNode = m_packageStep + ->qt4BuildConfiguration()->qt4Target()->qt4Project() + ->rootProjectNode(); + m_proFileWrapper.reset(new ProFileWrapper(proFileNode->path())); + } + const ProFileWrapper::InstallsList &installs = m_proFileWrapper->installs(); if (installs.targetPath.isEmpty()) { const Qt4ProFileNode * const proFileNode = m_packageStep->qt4BuildConfiguration()->qt4Target() @@ -70,19 +76,19 @@ bool MaemoPackageContents::buildModel() const const QString remoteDir = proFileNode->projectType() == LibraryTemplate ? QLatin1String("/usr/local/lib") : QLatin1String("/usr/local/bin"); - m_deployables.prepend(MaemoDeployable(m_packageStep->localExecutableFilePath(), + m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), remoteDir)); - if (!proFileWrapper->addInstallsTarget(remoteDir)) { + if (!m_proFileWrapper->addInstallsTarget(remoteDir)) { qWarning("Error updating .pro file."); return false; } } else { - m_deployables.prepend(MaemoDeployable(m_packageStep->localExecutableFilePath(), + m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), installs.targetPath)); } foreach (const ProFileWrapper::InstallsElem &elem, installs.normalElems) { foreach (const QString &file, elem.files) { - m_deployables << MaemoDeployable(proFileWrapper->absFilePath(file), + m_deployables << MaemoDeployable(m_proFileWrapper->absFilePath(file), elem.path); } } @@ -92,13 +98,13 @@ bool MaemoPackageContents::buildModel() const return true; } -MaemoDeployable MaemoPackageContents::deployableAt(int row) const +MaemoDeployable MaemoDeployableListModel::deployableAt(int row) const { Q_ASSERT(row >= 0 && row < rowCount()); return m_deployables.at(row); } -bool MaemoPackageContents::addDeployable(const MaemoDeployable &deployable, +bool MaemoDeployableListModel::addDeployable(const MaemoDeployable &deployable, QString *error) { if (m_deployables.contains(deployable)) { @@ -106,7 +112,7 @@ bool MaemoPackageContents::addDeployable(const MaemoDeployable &deployable, return false; } - if (!m_packageStep->proFileWrapper()->addInstallsElem(deployable.remoteDir, + if (!m_proFileWrapper->addInstallsElem(deployable.remoteDir, deployable.localFilePath)) { *error = tr("Failed to update .pro file."); return false; @@ -118,13 +124,13 @@ bool MaemoPackageContents::addDeployable(const MaemoDeployable &deployable, return true; } -bool MaemoPackageContents::removeDeployableAt(int row, QString *error) +bool MaemoDeployableListModel::removeDeployableAt(int row, QString *error) { Q_ASSERT(row > 0 && row < rowCount()); const MaemoDeployable &deployable = deployableAt(row); - if (!m_packageStep->proFileWrapper() - ->removeInstallsElem(deployable.remoteDir, deployable.localFilePath)) { + if (!m_proFileWrapper->removeInstallsElem(deployable.remoteDir, + deployable.localFilePath)) { *error = tr("Could not update .pro file."); return false; } @@ -135,18 +141,18 @@ bool MaemoPackageContents::removeDeployableAt(int row, QString *error) return true; } -int MaemoPackageContents::rowCount(const QModelIndex &parent) const +int MaemoDeployableListModel::rowCount(const QModelIndex &parent) const { buildModel(); return parent.isValid() ? 0 : m_deployables.count(); } -int MaemoPackageContents::columnCount(const QModelIndex &parent) const +int MaemoDeployableListModel::columnCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 2; } -QVariant MaemoPackageContents::data(const QModelIndex &index, int role) const +QVariant MaemoDeployableListModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= rowCount()) return QVariant(); @@ -159,7 +165,7 @@ QVariant MaemoPackageContents::data(const QModelIndex &index, int role) const return QVariant(); } -Qt::ItemFlags MaemoPackageContents::flags(const QModelIndex &index) const +Qt::ItemFlags MaemoDeployableListModel::flags(const QModelIndex &index) const { Qt::ItemFlags parentFlags = QAbstractTableModel::flags(index); if (index.column() == 1) @@ -167,7 +173,7 @@ Qt::ItemFlags MaemoPackageContents::flags(const QModelIndex &index) const return parentFlags; } -bool MaemoPackageContents::setData(const QModelIndex &index, +bool MaemoDeployableListModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid() || index.row() >= rowCount() || index.column() != 1 @@ -176,7 +182,7 @@ bool MaemoPackageContents::setData(const QModelIndex &index, MaemoDeployable &deployable = m_deployables[index.row()]; const QString &newRemoteDir = value.toString(); - if (!m_packageStep->proFileWrapper()->replaceInstallPath(deployable.remoteDir, + if (!m_proFileWrapper->replaceInstallPath(deployable.remoteDir, deployable.localFilePath, newRemoteDir)) { qWarning("Error: Could not update .pro file"); return false; @@ -187,7 +193,7 @@ bool MaemoPackageContents::setData(const QModelIndex &index, return true; } -QVariant MaemoPackageContents::headerData(int section, +QVariant MaemoDeployableListModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Vertical || role != Qt::DisplayRole) @@ -195,11 +201,29 @@ QVariant MaemoPackageContents::headerData(int section, return section == 0 ? tr("Local File Path") : tr("Remote Directory"); } -QString MaemoPackageContents::remoteExecutableFilePath() const +QString MaemoDeployableListModel::localExecutableFilePath() const +{ + // TODO: This information belongs to this class. + return m_packageStep->localExecutableFilePath(); +} + +QString MaemoDeployableListModel::remoteExecutableFilePath() const { return buildModel() ? deployableAt(0).remoteDir + '/' + m_packageStep->executableFileName() : QString(); } +QString MaemoDeployableListModel::projectName() const +{ + // TODO: This must return our own sub project name. + return m_packageStep->qt4BuildConfiguration()->qt4Target()->qt4Project() + ->rootProjectNode()->displayName(); +} + +QString MaemoDeployableListModel::projectDir() const +{ + return m_proFileWrapper->projectDir(); +} + } // namespace Qt4ProjectManager } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h similarity index 80% rename from src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h rename to src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h index c74f4c1fd84..c441e92a4f2 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h @@ -30,42 +30,25 @@ #ifndef MAEMOPACKAGECONTENTS_H #define MAEMOPACKAGECONTENTS_H +#include "maemodeployable.h" + #include #include #include +#include #include namespace Qt4ProjectManager { namespace Internal { - -struct MaemoDeployable -{ - MaemoDeployable(const QString &localFilePath, const QString &remoteDir) - : localFilePath(localFilePath), remoteDir(remoteDir) {} - - bool operator==(const MaemoDeployable &other) const - { - return localFilePath == other.localFilePath - && remoteDir == other.remoteDir; - } - - QString localFilePath; - QString remoteDir; -}; -inline uint qHash(const MaemoDeployable &d) -{ - return qHash(qMakePair(d.localFilePath, d.remoteDir)); -} - class MaemoPackageCreationStep; -class ProFileReader; +class ProFileWrapper; -class MaemoPackageContents : public QAbstractTableModel +class MaemoDeployableListModel : public QAbstractTableModel { Q_OBJECT public: - MaemoPackageContents(MaemoPackageCreationStep *packageStep); - ~MaemoPackageContents(); + MaemoDeployableListModel(MaemoPackageCreationStep *packageStep); + ~MaemoDeployableListModel(); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; @@ -74,7 +57,10 @@ public: bool removeDeployableAt(int row, QString *error); bool isModified() const { return m_modified; } void setUnModified() { m_modified = false; } + QString localExecutableFilePath() const; QString remoteExecutableFilePath() const; + QString projectName() const; + QString projectDir() const; private: virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; @@ -92,6 +78,7 @@ private: mutable QList m_deployables; mutable bool m_modified; mutable bool m_initialized; + mutable QScopedPointer m_proFileWrapper; }; } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp new file mode 100644 index 00000000000..77232277441 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "maemodeployablelistwidget.h" +#include "ui_maemodeployablelistwidget.h" + +#include "maemodeployablelistmodel.h" + +#include + +#include +#include +#include +#include +#include + +namespace Qt4ProjectManager { +namespace Internal { + +MaemoDeployableListWidget::MaemoDeployableListWidget(QWidget *parent, + MaemoDeployableListModel *model) + : QWidget(parent), m_ui(new Ui::MaemoDeployableListWidget), m_model(model) +{ + m_ui->setupUi(this); + m_ui->deployablesView->setWordWrap(false); + m_ui->deployablesView->setModel(m_model); + connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + m_ui->deployablesView, SLOT(resizeColumnsToContents())); + connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), + m_ui->deployablesView, SLOT(resizeColumnsToContents())); + connect(m_ui->deployablesView->selectionModel(), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, + SLOT(enableOrDisableRemoveButton())); + m_ui->deployablesView->resizeColumnsToContents(); + m_ui->deployablesView->horizontalHeader()->setStretchLastSection(true); + enableOrDisableRemoveButton(); +} + +MaemoDeployableListWidget::~MaemoDeployableListWidget() +{ + delete m_ui; +} + +void MaemoDeployableListWidget::addFile() +{ + // TODO: Make all this stuff subproject-specific. + const QString title = tr("Choose a local file"); + const QString localFile = QFileDialog::getOpenFileName(this, title, m_model->projectDir()); // TODO: Support directories. + if (localFile.isEmpty()) + return; + const MaemoDeployable + deployable(QDir::toNativeSeparators(QFileInfo(localFile).absoluteFilePath()), + "/"); + QString errorString; + if (!m_model->addDeployable(deployable, &errorString)) { + QMessageBox::information(this, tr("Error adding file"), errorString); + } else { + const QModelIndex newIndex + = m_model->index(m_model->rowCount() - 1, 1); + m_ui->deployablesView->selectionModel()->clear(); + m_ui->deployablesView->scrollTo(newIndex); + m_ui->deployablesView->edit(newIndex); + } +} + +void MaemoDeployableListWidget::removeFile() +{ + const QModelIndexList selectedRows + = m_ui->deployablesView->selectionModel()->selectedRows(); + if (selectedRows.isEmpty()) + return; + const int row = selectedRows.first().row(); + if (row != 0) { + QString errorString; + if (!m_model->removeDeployableAt(row, &errorString)) { + QMessageBox::information(this, tr("Error removing file"), + errorString); + } + } +} + +void MaemoDeployableListWidget::enableOrDisableRemoveButton() +{ + const QModelIndexList selectedRows + = m_ui->deployablesView->selectionModel()->selectedRows(); + m_ui->removeFileButton->setEnabled(!selectedRows.isEmpty() + && selectedRows.first().row() != 0); +} + +} // namespace Internal +} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.h new file mode 100644 index 00000000000..fcbf75249e5 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAEMODEPLOYABLELISTWIDGET_H +#define MAEMODEPLOYABLELISTWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { + class MaemoDeployableListWidget; +} +QT_END_NAMESPACE + +namespace Qt4ProjectManager { +namespace Internal { +class MaemoDeployableListModel; + +class MaemoDeployableListWidget : public QWidget +{ + Q_OBJECT + +public: + MaemoDeployableListWidget(QWidget *parent, MaemoDeployableListModel *model); + ~MaemoDeployableListWidget(); + +private slots: + void addFile(); + void removeFile(); + void enableOrDisableRemoveButton(); + +private: + Ui::MaemoDeployableListWidget *m_ui; + MaemoDeployableListModel * const m_model; +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // MAEMODEPLOYABLELISTWIDGET_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.ui b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.ui new file mode 100644 index 00000000000..412b53bd8a5 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistwidget.ui @@ -0,0 +1,139 @@ + + + MaemoDeployableListWidget + + + + 0 + 0 + 491 + 289 + + + + Form + + + + + + + 1 + 1 + + + + + 400 + 200 + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + false + + + false + + + + + + + + + Add File to Package + + + + + + + :/core/images/plus.png:/core/images/plus.png + + + + + + + Remove File from Package + + + + + + + :/core/images/minus.png:/core/images/minus.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + addFileButton + clicked() + MaemoDeployableListWidget + addFile() + + + 475 + 32 + + + 488 + 242 + + + + + removeFileButton + clicked() + MaemoDeployableListWidget + removeFile() + + + 456 + 66 + + + 490 + 182 + + + + + + addFile() + removeFile() + + diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp new file mode 100644 index 00000000000..c670c1bb131 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "maemodeployables.h" + +#include "maemodeployablelistmodel.h" + +namespace Qt4ProjectManager { +namespace Internal { + +MaemoDeployables::MaemoDeployables(MaemoPackageCreationStep *packagingStep) +{ + // TODO: Enumerate sub projects and create one list model for each app or lib template. + // Their constructurs will then take this object as parent and the + // project node + m_listModels << new MaemoDeployableListModel(packagingStep); +} + +void MaemoDeployables::setUnmodified() +{ + foreach (MaemoDeployableListModel *model, m_listModels) + model->setUnModified(); +} + +bool MaemoDeployables::isModified() const +{ + foreach (const MaemoDeployableListModel *model, m_listModels) { + if (model->isModified()) + return true; + } + return false; +} + +int MaemoDeployables::deployableCount() const +{ + int count = 0; + foreach (const MaemoDeployableListModel *model, m_listModels) + count += model->rowCount(); + return count; +} + +MaemoDeployable MaemoDeployables::deployableAt(int i) const +{ + foreach (const MaemoDeployableListModel *model, m_listModels) { + Q_ASSERT(i >= 0); + if (i < model->rowCount()) + return model->deployableAt(i); + i -= model->rowCount(); + } + + Q_ASSERT(!"Invalid deployable number"); + return MaemoDeployable(QString(), QString()); +} + +QString MaemoDeployables::remoteExecutableFilePath(const QString &localExecutableFilePath) const +{ + foreach (const MaemoDeployableListModel *model, m_listModels) { + if (model->localExecutableFilePath() == localExecutableFilePath) + return model->remoteExecutableFilePath(); + } + Q_ASSERT(!"Invalid local executable!"); + return QString(); +} + +} // namespace Qt4ProjectManager +} // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h new file mode 100644 index 00000000000..bc0dc2fe63c --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployables.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAEMODEPLOYABLES_H +#define MAEMODEPLOYABLES_H + +#include "maemodeployable.h" + +#include +#include + +namespace Qt4ProjectManager { +namespace Internal { +class MaemoDeployableListModel; +class MaemoPackageCreationStep; + +class MaemoDeployables : public QObject +{ + Q_OBJECT +public: + MaemoDeployables(MaemoPackageCreationStep *packagingStep); + void setUnmodified(); + bool isModified() const; + int deployableCount() const; + MaemoDeployable deployableAt(int i) const; + QString remoteExecutableFilePath(const QString &localExecutableFilePath) const; + int modelCount() const { return m_listModels.count(); } + MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); } + +private: + QList m_listModels; +}; + +} // namespace Qt4ProjectManager +} // namespace Internal + +#endif // MAEMODEPLOYABLES_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index 69f73c877eb..afb4ecf4a48 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -43,7 +43,7 @@ #include "maemoconstants.h" #include "maemopackagecreationwidget.h" -#include "maemopackagecontents.h" +#include "maemodeployables.h" #include "maemotoolchain.h" #include "profilewrapper.h" @@ -52,9 +52,6 @@ #include #include -#include -#include -#include #include #include #include @@ -76,7 +73,7 @@ namespace Internal { MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig) : ProjectExplorer::BuildStep(buildConfig, CreatePackageId), - m_packageContents(new MaemoPackageContents(this)), + m_deployables(new MaemoDeployables(this)), m_packagingEnabled(true), m_versionString(DefaultVersionNumber) { @@ -85,13 +82,16 @@ MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConf MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig, MaemoPackageCreationStep *other) : BuildStep(buildConfig, other), - m_packageContents(new MaemoPackageContents(this)), + m_deployables(new MaemoDeployables(this)), m_packagingEnabled(other->m_packagingEnabled), m_versionString(other->m_versionString) { } -MaemoPackageCreationStep::~MaemoPackageCreationStep() {} +MaemoPackageCreationStep::~MaemoPackageCreationStep() +{ + delete m_deployables; +} bool MaemoPackageCreationStep::init() { @@ -245,7 +245,7 @@ bool MaemoPackageCreationStep::createPackage() } emit addOutput(tr("Package created."), textCharFormat); - m_packageContents->setUnModified(); + m_deployables->setUnmodified(); return true; } @@ -346,12 +346,13 @@ QString MaemoPackageCreationStep::targetRoot() const bool MaemoPackageCreationStep::packagingNeeded() const { QFileInfo packageInfo(packageFilePath()); - if (!packageInfo.exists() || m_packageContents->isModified()) + if (!packageInfo.exists() || m_deployables->isModified()) return true; - for (int i = 0; i < m_packageContents->rowCount(); ++i) { + const int deployableCount = m_deployables->deployableCount(); + for (int i = 0; i < deployableCount; ++i) { if (packageInfo.lastModified() - <= QFileInfo(m_packageContents->deployableAt(i).localFilePath) + <= QFileInfo(m_deployables->deployableAt(i).localFilePath) .lastModified()) return true; } @@ -389,18 +390,6 @@ void MaemoPackageCreationStep::raiseError(const QString &shortMsg, TASK_CATEGORY_BUILDSYSTEM)); } -QSharedPointer MaemoPackageCreationStep::proFileWrapper() const -{ - if (!m_proFileWrapper) { - const Qt4ProFileNode * const proFileNode = qt4BuildConfiguration() - ->qt4Target()->qt4Project()->rootProjectNode(); - m_proFileWrapper = QSharedPointer( - new ProFileWrapper(proFileNode->path())); - } - - return m_proFileWrapper; -} - const QLatin1String MaemoPackageCreationStep::CreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep"); } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h index ca588843119..37b32355ef6 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h @@ -55,7 +55,7 @@ QT_END_NAMESPACE namespace Qt4ProjectManager { namespace Internal { -class MaemoPackageContents; +class MaemoDeployables; class MaemoToolChain; class ProFileWrapper; class Qt4BuildConfiguration; @@ -71,9 +71,8 @@ public: QString packageFilePath() const; QString localExecutableFilePath() const; QString executableFileName() const; - MaemoPackageContents *packageContents() const { return m_packageContents; } + MaemoDeployables *deployables() const { return m_deployables; } const Qt4BuildConfiguration *qt4BuildConfiguration() const; - QSharedPointer proFileWrapper() const; bool isPackagingEnabled() const { return m_packagingEnabled; } void setPackagingEnabled(bool enabled) { m_packagingEnabled = enabled; } @@ -108,10 +107,9 @@ private: static const QLatin1String CreatePackageId; - MaemoPackageContents *const m_packageContents; + MaemoDeployables * const m_deployables; bool m_packagingEnabled; QString m_versionString; - mutable QSharedPointer m_proFileWrapper; QScopedPointer m_buildProc; }; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp index 91fc14a3fc2..0e6697ef001 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp @@ -42,7 +42,9 @@ #include "maemopackagecreationwidget.h" #include "ui_maemopackagecreationwidget.h" -#include "maemopackagecontents.h" +#include "maemodeployablelistmodel.h" +#include "maemodeployablelistwidget.h" +#include "maemodeployables.h" #include "maemopackagecreationstep.h" #include "maemotoolchain.h" @@ -51,10 +53,6 @@ #include #include -#include -#include -#include - namespace Qt4ProjectManager { namespace Internal { @@ -64,27 +62,20 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep m_ui(new Ui::MaemoPackageCreationWidget) { m_ui->setupUi(this); - m_ui->packageContentsView->setWordWrap(false); m_ui->skipCheckBox->setChecked(!m_step->isPackagingEnabled()); - m_ui->packageContentsView->setModel(step->packageContents()); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - connect(step->packageContents(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), - m_ui->packageContentsView, SLOT(resizeColumnsToContents())); - connect(step->packageContents(), SIGNAL(rowsInserted(QModelIndex, int, int)), - m_ui->packageContentsView, SLOT(resizeColumnsToContents())); - connect(m_ui->packageContentsView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, - SLOT(enableOrDisableRemoveButton())); - m_ui->packageContentsView->resizeColumnsToContents(); - m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true); - enableOrDisableRemoveButton(); - const QStringList list = m_step->versionString().split(QLatin1Char('.'), QString::SkipEmptyParts); m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt()); m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt()); m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt()); versionInfoChanged(); // workaround for missing minor and patch update notifications + for (int i = 0; i < step->deployables()->modelCount(); ++i) { + MaemoDeployableListModel * const model + = step->deployables()->modelAt(i); + m_ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model), + model->projectName()); + } } void MaemoPackageCreationWidget::init() @@ -101,56 +92,6 @@ QString MaemoPackageCreationWidget::displayName() const return m_step->displayName(); } -void MaemoPackageCreationWidget::addFile() -{ - const Qt4BuildConfiguration * const bc - = static_cast(m_step->buildConfiguration()); - QTC_ASSERT(bc, return); - const QString title = tr("Choose a local file"); - const QString baseDir = bc->target()->project()->projectDirectory(); - const QString localFile = QFileDialog::getOpenFileName(this, title, baseDir); // TODO: Support directories? - if (localFile.isEmpty()) - return; - const MaemoDeployable - deployable(QDir::toNativeSeparators(QFileInfo(localFile).absoluteFilePath()), - "/"); - MaemoPackageContents * const contents = m_step->packageContents(); - QString errorString; - if (!contents->addDeployable(deployable, &errorString)) { - QMessageBox::information(this, tr("Error adding file"), errorString); - } else { - const QModelIndex newIndex - = contents->index(contents->rowCount() - 1, 1); - m_ui->packageContentsView->selectionModel()->clear(); - m_ui->packageContentsView->scrollTo(newIndex); - m_ui->packageContentsView->edit(newIndex); - } -} - -void MaemoPackageCreationWidget::removeFile() -{ - const QModelIndexList selectedRows - = m_ui->packageContentsView->selectionModel()->selectedRows(); - if (selectedRows.isEmpty()) - return; - const int row = selectedRows.first().row(); - if (row != 0) { - QString errorString; - if (!m_step->packageContents()->removeDeployableAt(row, &errorString)) { - QMessageBox::information(this, tr("Error removing file"), - errorString); - } - } -} - -void MaemoPackageCreationWidget::enableOrDisableRemoveButton() -{ - const QModelIndexList selectedRows - = m_ui->packageContentsView->selectionModel()->selectedRows(); - m_ui->removeFileButton->setEnabled(!selectedRows.isEmpty() - && selectedRows.first().row() != 0); -} - void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked) { m_step->setPackagingEnabled(!checked); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h index a341880517e..6f01bdeaa76 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h @@ -64,9 +64,6 @@ public: virtual QString displayName() const; private slots: - void addFile(); - void removeFile(); - void enableOrDisableRemoveButton(); void handleSkipButtonToggled(bool checked); void versionInfoChanged(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.ui b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.ui index 5ac787f6cde..8e3b923136e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.ui +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.ui @@ -6,8 +6,8 @@ 0 0 - 470 - 325 + 478 + 335 @@ -191,142 +191,16 @@ - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 13 - 13 - - - - - - - - - 1 - 1 - - - - - 400 - 200 - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - false - - - false - - - - - - - - - Add File to Package - - - - - - - :/core/images/plus.png:/core/images/plus.png - - - - - - - Remove File from Package - - - - - - - :/core/images/minus.png:/core/images/minus.png - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + -1 + + - - - + - - addFileButton - clicked() - MaemoPackageCreationWidget - addFile() - - - 458 - 134 - - - 732 - 525 - - - - - removeFileButton - clicked() - MaemoPackageCreationWidget - removeFile() - - - 458 - 162 - - - 735 - 145 - - - skipCheckBox clicked(bool) @@ -366,8 +240,8 @@ versionInfoChanged() - 154 - 68 + 233 + 94 5 @@ -382,12 +256,12 @@ versionInfoChanged() - 249 - 68 + 339 + 94 466 - -7 + 0 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h index 0a42d526506..04b9f1cc3c3 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h @@ -32,7 +32,7 @@ #include "maemoconstants.h" #include "maemodeviceconfigurations.h" -#include "maemopackagecontents.h" +#include "maemodeployable.h" #include diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index 5541eccd7c7..7b622f50963 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -34,9 +34,9 @@ #include "maemoruncontrol.h" +#include "maemodeployables.h" #include "maemopackagecreationstep.h" #include "maemorunconfiguration.h" -#include "maemopackagecontents.h" #include #include @@ -139,10 +139,11 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging) const MaemoDeployable d(packageFilePath(), uploadDir()); m_needsInstall = addDeployableIfNeeded(d); } else { - const MaemoPackageContents * const packageContents - = packageStep->packageContents(); - for (int i = 0; i < packageContents->rowCount(); ++i) { - const MaemoDeployable &d = packageContents->deployableAt(i); + const MaemoDeployables * const deployables + = packageStep->deployables(); + const int deployableCount = deployables->deployableCount(); + for (int i = 0; i < deployableCount; ++i) { + const MaemoDeployable &d = deployables->deployableAt(i); if (addDeployableIfNeeded(d)) m_needsInstall = true; } @@ -237,7 +238,10 @@ QString AbstractMaemoRunControl::packageFilePath() const QString AbstractMaemoRunControl::executableFilePathOnTarget() const { - return m_runConfig->packageStep()->packageContents()->remoteExecutableFilePath(); + // TODO: The local executable is known directly by us (from RunConfiguration::target(), + // so we must not rely on the packaging step for this information (which will + // no longer provide it, anyway)/ + return m_runConfig->packageStep()->deployables()->remoteExecutableFilePath(m_runConfig->packageStep()->localExecutableFilePath()); } bool AbstractMaemoRunControl::isCleaning() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h index 2cf68b105c8..5965b0e8a17 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h @@ -36,7 +36,7 @@ #define MAEMORUNCONTROL_H #include "maemodeviceconfigurations.h" -#include "maemopackagecontents.h" +#include "maemodeployable.h" #include "maemosshthread.h" #include diff --git a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h index e82c03c2231..7f2d4512143 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h +++ b/src/plugins/qt4projectmanager/qt-maemo/profilewrapper.h @@ -53,6 +53,7 @@ public: const QString &newValue); QString absFilePath(const QString &relFilePath) const; + QString projectDir() const { return m_proDir.path(); } private: enum ParseType { ParseFromFile, ParseFromLines }; diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 2a0d8e02f17..346c1b8a062 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -15,9 +15,12 @@ HEADERS += \ $$PWD/maemopackagecreationstep.h \ $$PWD/maemopackagecreationfactory.h \ $$PWD/maemopackagecreationwidget.h \ - $$PWD/maemopackagecontents.h \ + $$PWD/maemodeployablelistmodel.h \ $$PWD/qemuruntimemanager.h \ - $$PWD/profilewrapper.h + $$PWD/profilewrapper.h \ + $$PWD/maemodeployables.h \ + $$PWD/maemodeployable.h \ + $$PWD/maemodeployablelistwidget.h SOURCES += \ $$PWD/maemoconfigtestdialog.cpp \ @@ -35,14 +38,17 @@ SOURCES += \ $$PWD/maemopackagecreationstep.cpp \ $$PWD/maemopackagecreationfactory.cpp \ $$PWD/maemopackagecreationwidget.cpp \ - $$PWD/maemopackagecontents.cpp \ + $$PWD/maemodeployablelistmodel.cpp \ $$PWD/qemuruntimemanager.cpp \ - $$PWD/profilewrapper.cpp + $$PWD/profilewrapper.cpp \ + $$PWD/maemodeployables.cpp \ + $$PWD/maemodeployablelistwidget.cpp FORMS += \ $$PWD/maemoconfigtestdialog.ui \ $$PWD/maemosettingswidget.ui \ $$PWD/maemosshconfigdialog.ui \ - $$PWD/maemopackagecreationwidget.ui + $$PWD/maemopackagecreationwidget.ui \ + $$PWD/maemodeployablelistwidget.ui RESOURCES += $$PWD/qt-maemo.qrc