Maemo: Put mount specification class into its own set of source files.

This commit is contained in:
ck
2010-08-10 10:33:25 +02:00
parent 86bdf5af13
commit 823f0fd1b5
7 changed files with 120 additions and 40 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -34,19 +34,6 @@
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { 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) : MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) :
QAbstractTableModel(parent) QAbstractTableModel(parent)
{ {
@@ -66,7 +53,8 @@ void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir)
} }
beginInsertRows(QModelIndex(), rowCount(), rowCount()); beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_mountSpecs << MountSpecification(localDir, InvalidMountPoint, port); m_mountSpecs << MaemoMountSpecification(localDir,
MaemoMountSpecification::InvalidMountPoint, port);
endInsertRows(); endInsertRows();
} }
@@ -89,7 +77,7 @@ void MaemoRemoteMountsModel::setLocalDir(int pos, const QString &localDir)
int MaemoRemoteMountsModel::validMountSpecificationCount() const int MaemoRemoteMountsModel::validMountSpecificationCount() const
{ {
int count = 0; int count = 0;
foreach (const MountSpecification &m, m_mountSpecs) { foreach (const MaemoMountSpecification &m, m_mountSpecs) {
if (m.isValid()) if (m.isValid())
++count; ++count;
} }
@@ -98,7 +86,7 @@ int MaemoRemoteMountsModel::validMountSpecificationCount() const
bool MaemoRemoteMountsModel::hasValidMountSpecifications() const bool MaemoRemoteMountsModel::hasValidMountSpecifications() const
{ {
foreach (const MountSpecification &m, m_mountSpecs) { foreach (const MaemoMountSpecification &m, m_mountSpecs) {
if (m.isValid()) if (m.isValid())
return true; return true;
} }
@@ -111,7 +99,7 @@ QVariantMap MaemoRemoteMountsModel::toMap() const
QVariantList localDirsList; QVariantList localDirsList;
QVariantList remoteMountPointsList; QVariantList remoteMountPointsList;
QVariantList mountPortsList; QVariantList mountPortsList;
foreach (const MountSpecification &mountSpec, m_mountSpecs) { foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) {
localDirsList << mountSpec.localDir; localDirsList << mountSpec.localDir;
remoteMountPointsList << mountSpec.remoteMountPoint; remoteMountPointsList << mountSpec.remoteMountPoint;
mountPortsList << mountSpec.remotePort; mountPortsList << mountSpec.remotePort;
@@ -136,7 +124,7 @@ void MaemoRemoteMountsModel::fromMap(const QVariantMap &map)
const QString &remoteMountPoint const QString &remoteMountPoint
= remoteMountPointsList.at(i).toString(); = remoteMountPointsList.at(i).toString();
const int port = mountPortsList.at(i).toInt(); 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()) if (!index.isValid() || index.row() >= rowCount())
return QVariant(); return QVariant();
const MountSpecification &mountSpec = mountSpecificationAt(index.row()); const MaemoMountSpecification &mountSpec = mountSpecificationAt(index.row());
switch (index.column()) { switch (index.column()) {
case LocalDirRow: case LocalDirRow:
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
@@ -196,7 +184,7 @@ bool MaemoRemoteMountsModel::setData(const QModelIndex &index,
case RemoteMountPointRow: { case RemoteMountPointRow: {
const QString &newRemoteMountPoint = value.toString(); const QString &newRemoteMountPoint = value.toString();
for (int i = 0; i < m_mountSpecs.count(); ++i) { 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() if (i != index.row() && mountSpec.isValid()
&& mountSpec.remoteMountPoint == newRemoteMountPoint) && mountSpec.remoteMountPoint == newRemoteMountPoint)
return false; return false;

View File

@@ -30,6 +30,8 @@
#ifndef MAEMOREMOTEMOUNTSMODEL_H #ifndef MAEMOREMOTEMOUNTSMODEL_H
#define MAEMOREMOTEMOUNTSMODEL_H #define MAEMOREMOTEMOUNTSMODEL_H
#include "maemomountspecification.h"
#include <QtCore/QAbstractTableModel> #include <QtCore/QAbstractTableModel>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QString> #include <QtCore/QString>
@@ -42,19 +44,10 @@ class MaemoRemoteMountsModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: 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); explicit MaemoRemoteMountsModel(QObject *parent = 0);
int mountSpecificationCount() const { return m_mountSpecs.count(); } int mountSpecificationCount() const { return m_mountSpecs.count(); }
int validMountSpecificationCount() const; 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; bool hasValidMountSpecifications() const;
void addMountSpecification(const QString &localDir); void addMountSpecification(const QString &localDir);
@@ -79,7 +72,7 @@ private:
virtual bool setData(const QModelIndex &index, const QVariant &value, virtual bool setData(const QModelIndex &index, const QVariant &value,
int role); int role);
QList<MountSpecification> m_mountSpecs; QList<MaemoMountSpecification> m_mountSpecs;
}; };
inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const

View File

@@ -78,13 +78,13 @@ void MaemoSshRunner::start()
const MaemoRemoteMountsModel * const remoteMounts const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts(); = m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) { for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec const MaemoMountSpecification &mountSpec
= remoteMounts->mountSpecificationAt(i); = remoteMounts->mountSpecificationAt(i);
if (mountSpec.isValid()) if (mountSpec.isValid())
m_mountSpecs << mountSpec; m_mountSpecs << mountSpec;
} }
if (m_debugging && m_runConfig->useRemoteGdb()) { if (m_debugging && m_runConfig->useRemoteGdb()) {
m_mountSpecs << MaemoRemoteMountsModel::MountSpecification( m_mountSpecs << MaemoMountSpecification(
m_runConfig->localDirToMountForRemoteGdb(), m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(), MaemoGlobal::remoteProjectSourcesMountPoint(),
m_devConfig.debuggingPort); m_devConfig.debuggingPort);
@@ -264,8 +264,7 @@ void MaemoSshRunner::startUtfsClients()
const QLatin1String andOp(" && "); const QLatin1String andOp(" && ");
QString remoteCall = chmodFuse + andOp + chmodUtfsClient; QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
for (int i = 0; i < m_mountSpecs.count(); ++i) { for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i);
= m_mountSpecs.at(i);
const QString port = QString::number(mountSpec.remotePort); const QString port = QString::number(mountSpec.remotePort);
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint); .arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
@@ -319,8 +318,7 @@ void MaemoSshRunner::handleUtfsClientsFinished(int exitStatus)
void MaemoSshRunner::startUtfsServers() void MaemoSshRunner::startUtfsServers()
{ {
for (int i = 0; i < m_mountSpecs.count(); ++i) { for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i);
= m_mountSpecs.at(i);
QProcess * const utfsServerProc = new QProcess(this); QProcess * const utfsServerProc = new QProcess(this);
connect(utfsServerProc, SIGNAL(readyReadStandardError()), this, connect(utfsServerProc, SIGNAL(readyReadStandardError()), this,
SLOT(handleUtfsServerErrorOutput())); SLOT(handleUtfsServerErrorOutput()));

View File

@@ -112,7 +112,7 @@ private:
QSharedPointer<Core::SftpChannel> m_utfsClientUploader; QSharedPointer<Core::SftpChannel> m_utfsClientUploader;
QStringList m_procsToKill; QStringList m_procsToKill;
QList<QProcess *> m_utfsServers; QList<QProcess *> m_utfsServers;
QList<MaemoRemoteMountsModel::MountSpecification> m_mountSpecs; QList<MaemoMountSpecification> m_mountSpecs;
Core::SftpJobId m_uploadJobId; Core::SftpJobId m_uploadJobId;
bool m_stop; bool m_stop;

View File

@@ -29,7 +29,8 @@ HEADERS += \
$$PWD/maemodeviceconfiglistmodel.h \ $$PWD/maemodeviceconfiglistmodel.h \
$$PWD/maemoremotemountsmodel.h \ $$PWD/maemoremotemountsmodel.h \
$$PWD/maemodeviceenvreader.h \ $$PWD/maemodeviceenvreader.h \
$$PWD/maemotemplatesmanager.h $$PWD/maemotemplatesmanager.h \
$$PWD/maemomountspecification.h
SOURCES += \ SOURCES += \
$$PWD/maemoconfigtestdialog.cpp \ $$PWD/maemoconfigtestdialog.cpp \
@@ -60,7 +61,8 @@ SOURCES += \
$$PWD/maemodeviceconfiglistmodel.cpp \ $$PWD/maemodeviceconfiglistmodel.cpp \
$$PWD/maemoremotemountsmodel.cpp \ $$PWD/maemoremotemountsmodel.cpp \
$$PWD/maemodeviceenvreader.cpp \ $$PWD/maemodeviceenvreader.cpp \
$$PWD/maemotemplatesmanager.cpp $$PWD/maemotemplatesmanager.cpp \
$$PWD/maemomountspecification.cpp
FORMS += \ FORMS += \
$$PWD/maemoconfigtestdialog.ui \ $$PWD/maemoconfigtestdialog.ui \