forked from qt-creator/qt-creator
Maemo: Put mount specification class into its own set of source files.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user