From 823f0fd1b50ffcca241eb94a8e08b70a57ba2b2d Mon Sep 17 00:00:00 2001 From: ck <qt-info@nokia.com> Date: Tue, 10 Aug 2010 10:33:25 +0200 Subject: [PATCH] Maemo: Put mount specification class into its own set of source files. --- .../qt-maemo/maemomountspecification.cpp | 45 ++++++++++++++++ .../qt-maemo/maemomountspecification.h | 54 +++++++++++++++++++ .../qt-maemo/maemoremotemountsmodel.cpp | 28 +++------- .../qt-maemo/maemoremotemountsmodel.h | 15 ++---- .../qt-maemo/maemosshrunner.cpp | 10 ++-- .../qt-maemo/maemosshrunner.h | 2 +- .../qt4projectmanager/qt-maemo/qt-maemo.pri | 6 ++- 7 files changed, 120 insertions(+), 40 deletions(-) create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.cpp create mode 100644 src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.h diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.cpp new file mode 100644 index 00000000000..6ed38689e62 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.cpp @@ -0,0 +1,45 @@ +/************************************************************************** +** +** 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 "maemomountspecification.h" + +namespace Qt4ProjectManager { +namespace Internal { + +const QLatin1String MaemoMountSpecification::InvalidMountPoint("/"); + +MaemoMountSpecification::MaemoMountSpecification(const QString &localDir, + const QString &remoteDir, int remotePort) + : localDir(localDir), remoteMountPoint(remoteDir), remotePort(remotePort) +{ +} + +} // namespace Internal +} // namespace Qt4ProjectManager + diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.h b/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.h new file mode 100644 index 00000000000..d1700eb9b77 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomountspecification.h @@ -0,0 +1,54 @@ +/************************************************************************** +** +** 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 MAEMOMOUNTSPECIFICATION_H +#define MAEMOMOUNTSPECIFICATION_H + +#include <QtCore/QLatin1String> + +namespace Qt4ProjectManager { +namespace Internal { + +struct MaemoMountSpecification { + MaemoMountSpecification(const QString &localDir, const QString &remoteDir, + int remotePort); + + bool isValid() const { return remoteMountPoint != InvalidMountPoint; } + + static const QLatin1String InvalidMountPoint; + + QString localDir; + QString remoteMountPoint; + int remotePort; +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // MAEMOMOUNTSPECIFICATION_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.cpp index 4016ed0abdd..d755b44c138 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.cpp @@ -34,19 +34,6 @@ namespace Qt4ProjectManager { namespace Internal { -namespace { -const QLatin1String InvalidMountPoint("/"); -} // anonymous namespace - -MaemoRemoteMountsModel::MountSpecification::MountSpecification(const QString &l, - const QString &r, int p) : localDir(l), remoteMountPoint(r), remotePort(p) {} - -bool MaemoRemoteMountsModel::MountSpecification::isValid() const -{ - return remoteMountPoint != InvalidMountPoint; -} - - MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) : QAbstractTableModel(parent) { @@ -66,7 +53,8 @@ void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir) } beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_mountSpecs << MountSpecification(localDir, InvalidMountPoint, port); + m_mountSpecs << MaemoMountSpecification(localDir, + MaemoMountSpecification::InvalidMountPoint, port); endInsertRows(); } @@ -89,7 +77,7 @@ void MaemoRemoteMountsModel::setLocalDir(int pos, const QString &localDir) int MaemoRemoteMountsModel::validMountSpecificationCount() const { int count = 0; - foreach (const MountSpecification &m, m_mountSpecs) { + foreach (const MaemoMountSpecification &m, m_mountSpecs) { if (m.isValid()) ++count; } @@ -98,7 +86,7 @@ int MaemoRemoteMountsModel::validMountSpecificationCount() const bool MaemoRemoteMountsModel::hasValidMountSpecifications() const { - foreach (const MountSpecification &m, m_mountSpecs) { + foreach (const MaemoMountSpecification &m, m_mountSpecs) { if (m.isValid()) return true; } @@ -111,7 +99,7 @@ QVariantMap MaemoRemoteMountsModel::toMap() const QVariantList localDirsList; QVariantList remoteMountPointsList; QVariantList mountPortsList; - foreach (const MountSpecification &mountSpec, m_mountSpecs) { + foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) { localDirsList << mountSpec.localDir; remoteMountPointsList << mountSpec.remoteMountPoint; mountPortsList << mountSpec.remotePort; @@ -136,7 +124,7 @@ void MaemoRemoteMountsModel::fromMap(const QVariantMap &map) const QString &remoteMountPoint = remoteMountPointsList.at(i).toString(); const int port = mountPortsList.at(i).toInt(); - m_mountSpecs << MountSpecification(localDir, remoteMountPoint, port); + m_mountSpecs << MaemoMountSpecification(localDir, remoteMountPoint, port); } } @@ -167,7 +155,7 @@ QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const if (!index.isValid() || index.row() >= rowCount()) return QVariant(); - const MountSpecification &mountSpec = mountSpecificationAt(index.row()); + const MaemoMountSpecification &mountSpec = mountSpecificationAt(index.row()); switch (index.column()) { case LocalDirRow: if (role == Qt::DisplayRole) @@ -196,7 +184,7 @@ bool MaemoRemoteMountsModel::setData(const QModelIndex &index, case RemoteMountPointRow: { const QString &newRemoteMountPoint = value.toString(); for (int i = 0; i < m_mountSpecs.count(); ++i) { - const MountSpecification &mountSpec = m_mountSpecs.at(i); + const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i); if (i != index.row() && mountSpec.isValid() && mountSpec.remoteMountPoint == newRemoteMountPoint) return false; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.h b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.h index eb64227e152..04b4d7b1f3f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemountsmodel.h @@ -30,6 +30,8 @@ #ifndef MAEMOREMOTEMOUNTSMODEL_H #define MAEMOREMOTEMOUNTSMODEL_H +#include "maemomountspecification.h" + #include <QtCore/QAbstractTableModel> #include <QtCore/QList> #include <QtCore/QString> @@ -42,19 +44,10 @@ class MaemoRemoteMountsModel : public QAbstractTableModel { Q_OBJECT public: - struct MountSpecification { - MountSpecification(const QString &l, const QString &r, int p); - bool isValid() const; - - QString localDir; - QString remoteMountPoint; - int remotePort; - }; - explicit MaemoRemoteMountsModel(QObject *parent = 0); int mountSpecificationCount() const { return m_mountSpecs.count(); } int validMountSpecificationCount() const; - MountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); } + MaemoMountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); } bool hasValidMountSpecifications() const; void addMountSpecification(const QString &localDir); @@ -79,7 +72,7 @@ private: virtual bool setData(const QModelIndex &index, const QVariant &value, int role); - QList<MountSpecification> m_mountSpecs; + QList<MaemoMountSpecification> m_mountSpecs; }; inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 935ff4595c0..7f4870a25af 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -78,13 +78,13 @@ void MaemoSshRunner::start() const MaemoRemoteMountsModel * const remoteMounts = m_runConfig->remoteMounts(); for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) { - const MaemoRemoteMountsModel::MountSpecification &mountSpec + const MaemoMountSpecification &mountSpec = remoteMounts->mountSpecificationAt(i); if (mountSpec.isValid()) m_mountSpecs << mountSpec; } if (m_debugging && m_runConfig->useRemoteGdb()) { - m_mountSpecs << MaemoRemoteMountsModel::MountSpecification( + m_mountSpecs << MaemoMountSpecification( m_runConfig->localDirToMountForRemoteGdb(), MaemoGlobal::remoteProjectSourcesMountPoint(), m_devConfig.debuggingPort); @@ -264,8 +264,7 @@ void MaemoSshRunner::startUtfsClients() const QLatin1String andOp(" && "); QString remoteCall = chmodFuse + andOp + chmodUtfsClient; for (int i = 0; i < m_mountSpecs.count(); ++i) { - const MaemoRemoteMountsModel::MountSpecification &mountSpec - = m_mountSpecs.at(i); + const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i); const QString port = QString::number(mountSpec.remotePort); const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") .arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint); @@ -319,8 +318,7 @@ void MaemoSshRunner::handleUtfsClientsFinished(int exitStatus) void MaemoSshRunner::startUtfsServers() { for (int i = 0; i < m_mountSpecs.count(); ++i) { - const MaemoRemoteMountsModel::MountSpecification &mountSpec - = m_mountSpecs.at(i); + const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i); QProcess * const utfsServerProc = new QProcess(this); connect(utfsServerProc, SIGNAL(readyReadStandardError()), this, SLOT(handleUtfsServerErrorOutput())); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h index 29c520979d7..ff045b27866 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h @@ -112,7 +112,7 @@ private: QSharedPointer<Core::SftpChannel> m_utfsClientUploader; QStringList m_procsToKill; QList<QProcess *> m_utfsServers; - QList<MaemoRemoteMountsModel::MountSpecification> m_mountSpecs; + QList<MaemoMountSpecification> m_mountSpecs; Core::SftpJobId m_uploadJobId; bool m_stop; diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 53b7fc4c835..dc5c331ba7f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -29,7 +29,8 @@ HEADERS += \ $$PWD/maemodeviceconfiglistmodel.h \ $$PWD/maemoremotemountsmodel.h \ $$PWD/maemodeviceenvreader.h \ - $$PWD/maemotemplatesmanager.h + $$PWD/maemotemplatesmanager.h \ + $$PWD/maemomountspecification.h SOURCES += \ $$PWD/maemoconfigtestdialog.cpp \ @@ -60,7 +61,8 @@ SOURCES += \ $$PWD/maemodeviceconfiglistmodel.cpp \ $$PWD/maemoremotemountsmodel.cpp \ $$PWD/maemodeviceenvreader.cpp \ - $$PWD/maemotemplatesmanager.cpp + $$PWD/maemotemplatesmanager.cpp \ + $$PWD/maemomountspecification.cpp FORMS += \ $$PWD/maemoconfigtestdialog.ui \ -- GitLab