Commit 164cc4ff authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Refactor device configurations list.

parent 56bbd4ad
......@@ -49,7 +49,8 @@ using namespace Core;
namespace Qt4ProjectManager {
namespace Internal {
MaemoConfigTestDialog::MaemoConfigTestDialog(const MaemoDeviceConfig &config, QWidget *parent)
MaemoConfigTestDialog::MaemoConfigTestDialog(const MaemoDeviceConfig::ConstPtr &config,
QWidget *parent)
: QDialog(parent)
, m_ui(new Ui_MaemoConfigTestDialog)
, m_config(config)
......@@ -82,7 +83,7 @@ void MaemoConfigTestDialog::startConfigTest()
m_currentTest = GeneralTest;
m_ui->testResultEdit->setPlainText(tr("Testing configuration..."));
m_closeButton->setText(tr("Stop Test"));
m_testProcessRunner = SshRemoteProcessRunner::create(m_config.server);
m_testProcessRunner = SshRemoteProcessRunner::create(m_config->sshParameters());
connect(m_testProcessRunner.data(), SIGNAL(connectionError(Core::SshError)),
this, SLOT(handleConnectionError()));
connect(m_testProcessRunner.data(), SIGNAL(processClosed(int)), this,
......@@ -103,7 +104,7 @@ void MaemoConfigTestDialog::handleConnectionError()
return;
QString output = tr("Could not connect to host: %1")
.arg(m_testProcessRunner->connection()->errorString());
if (m_config.type == MaemoDeviceConfig::Simulator)
if (m_config->type() == MaemoDeviceConfig::Simulator)
output += tr("\nDid you start Qemu?");
m_ui->testResultEdit->setPlainText(output);
stopConfigTest();
......@@ -157,9 +158,9 @@ void MaemoConfigTestDialog::handleMadDeveloperTestResult(int exitStatus)
+ QLatin1String("<br>") + tr("Mad Developer is not installed.<br>"
"You will not be able to deploy to this device."));
}
if (m_config.freePorts().hasMore())
if (m_config->freePorts().hasMore())
m_portsGatherer->start(m_testProcessRunner->connection(),
m_config.freePorts());
m_config->freePorts());
else
finish();
}
......
......@@ -60,7 +60,8 @@ class MaemoConfigTestDialog : public QDialog
{
Q_OBJECT
public:
explicit MaemoConfigTestDialog(const MaemoDeviceConfig &config, QWidget *parent = 0);
explicit MaemoConfigTestDialog(const QSharedPointer<const MaemoDeviceConfig> &config,
QWidget *parent = 0);
~MaemoConfigTestDialog();
private slots:
......@@ -81,7 +82,7 @@ private:
Ui_MaemoConfigTestDialog *m_ui;
QPushButton *m_closeButton;
const MaemoDeviceConfig &m_config;
const QSharedPointer<const MaemoDeviceConfig> m_config;
QSharedPointer<Core::SshRemoteProcessRunner> m_testProcessRunner;
QString m_deviceTestOutput;
bool m_qtVersionOk;
......
......@@ -63,12 +63,12 @@ namespace Internal {
RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runConfig)
{
DebuggerStartParameters params;
const MaemoDeviceConfig &devConf = runConfig->deviceConfig();
const MaemoDeviceConfig::ConstPtr &devConf = runConfig->deviceConfig();
const MaemoRunConfiguration::DebuggingType debuggingType
= runConfig->debuggingType();
if (debuggingType != MaemoRunConfiguration::DebugCppOnly) {
params.qmlServerAddress = runConfig->deviceConfig().server.host;
params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
params.qmlServerPort = -1;
}
if (debuggingType != MaemoRunConfiguration::DebugQmlOnly) {
......@@ -85,7 +85,7 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
= MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
+ MaemoGlobal::remoteEnvironment(runConfig->userEnvironmentChanges())
+ QLatin1String(" /usr/bin/gdb");
params.connParams = devConf.server;
params.connParams = devConf->sshParameters();
params.localMountDir = runConfig->localDirToMountForRemoteGdb();
params.remoteMountPoint
= runConfig->remoteProjectSourcesMountPoint();
......@@ -99,7 +99,8 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
params.startMode = AttachToRemote;
params.executable = runConfig->localExecutableFilePath();
params.debuggerCommand = runConfig->gdbCmd();
params.remoteChannel = devConf.server.host + QLatin1String(":-1");
params.remoteChannel
= devConf->sshParameters().host + QLatin1String(":-1");
params.useServerStartScript = true;
params.remoteArchitecture = QLatin1String("arm");
params.gnuTarget = QLatin1String("arm-none-linux-gnueabi");
......@@ -122,6 +123,7 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig,
DebuggerEngine *engine, bool useGdb)
: QObject(engine), m_engine(engine), m_runConfig(runConfig),
m_deviceConfig(m_runConfig->deviceConfig()),
m_runner(new MaemoSshRunner(this, runConfig, true)),
m_debuggingType(runConfig->debuggingType()),
m_dumperLib(runConfig->dumperLib()),
......@@ -189,8 +191,8 @@ void MaemoDebugSupport::startExecution()
if (m_debuggingType != MaemoRunConfiguration::DebugQmlOnly
&& !m_dumperLib.isEmpty()
&& m_runConfig
&& m_runConfig->deployStep()->currentlyNeedsDeployment(m_runner->deviceConfig().server.host,
MaemoDeployable(m_dumperLib, uploadDir(m_runner->deviceConfig())))) {
&& m_runConfig->deployStep()->currentlyNeedsDeployment(m_deviceConfig->sshParameters().host,
MaemoDeployable(m_dumperLib, uploadDir(m_deviceConfig)))) {
setState(InitializingUploader);
m_uploader = m_runner->connection()->createSftpChannel();
connect(m_uploader.data(), SIGNAL(initialized()), this,
......@@ -214,8 +216,8 @@ void MaemoDebugSupport::handleSftpChannelInitialized()
ASSERT_STATE(InitializingUploader);
const QString fileName = QFileInfo(m_dumperLib).fileName();
const QString remoteFilePath
= uploadDir(m_runner->deviceConfig()) + '/' + fileName;
const QString remoteFilePath = uploadDir(m_deviceConfig)
+ QLatin1Char('/') + fileName;
m_uploadJob = m_uploader->uploadFile(m_dumperLib, remoteFilePath,
SftpOverwriteExisting);
if (m_uploadJob == SftpInvalidJob) {
......@@ -255,8 +257,8 @@ void MaemoDebugSupport::handleSftpJobFinished(Core::SftpJobId job,
} else {
setState(DumpersUploaded);
if (m_runConfig) {
m_runConfig->deployStep()->setDeployed(m_runner->deviceConfig().server.host,
MaemoDeployable(m_dumperLib, uploadDir(m_runner->deviceConfig())));
m_runConfig->deployStep()->setDeployed(m_deviceConfig->sshParameters().host,
MaemoDeployable(m_dumperLib, uploadDir(m_deviceConfig)));
}
showMessage(tr("Finished uploading debugging helpers."), AppStuff);
startDebugging();
......@@ -356,9 +358,9 @@ void MaemoDebugSupport::setState(State newState)
}
}
QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)
QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig::ConstPtr &devConf)
{
return MaemoGlobal::homeDirOnDevice(devConf.server.uname);
return MaemoGlobal::homeDirOnDevice(devConf->sshParameters().uname);
}
bool MaemoDebugSupport::useGdb() const
......
......@@ -55,6 +55,7 @@ namespace ProjectExplorer { class RunControl; }
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeviceConfig;
class MaemoRunConfiguration;
class MaemoSshRunner;
......@@ -68,7 +69,7 @@ public:
Debugger::DebuggerEngine *engine, bool useGdb);
~MaemoDebugSupport();
static QString uploadDir(const MaemoDeviceConfig &devConf);
static QString uploadDir(const QSharedPointer<const MaemoDeviceConfig> &devConf);
private slots:
void handleAdapterSetupRequested();
......@@ -98,6 +99,7 @@ private:
void showMessage(const QString &msg, int channel);
const QPointer<Debugger::DebuggerEngine> m_engine;
const QPointer<MaemoRunConfiguration> m_runConfig;
const QSharedPointer<const MaemoDeviceConfig> m_deviceConfig;
MaemoSshRunner * const m_runner;
const MaemoRunConfiguration::DebuggingType m_debuggingType;
const QString m_dumperLib;
......
......@@ -35,7 +35,6 @@
#include "maemoconstants.h"
#include "maemodeploystepwidget.h"
#include "maemodeviceconfiglistmodel.h"
#include "maemoglobal.h"
#include "maemopackagecreationstep.h"
#include "maemoremotemounter.h"
......@@ -108,7 +107,6 @@ void MaemoDeployStep::ctor()
m_state = Inactive;
m_needsInstall = false;
m_deviceConfigModel = new MaemoDeviceConfigListModel(this);
m_sysrootInstaller = new QProcess(this);
connect(m_sysrootInstaller, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(handleSysrootInstallerFinished()));
......@@ -130,6 +128,8 @@ void MaemoDeployStep::ctor()
SLOT(handlePortsGathererError(QString)));
connect(m_portsGatherer, SIGNAL(portListReady()), this,
SLOT(handlePortListReady()));
connect(MaemoDeviceConfigurations::instance(), SIGNAL(updated()),
SLOT(handleDeviceConfigurationsUpdated()));
}
bool MaemoDeployStep::init()
......@@ -155,7 +155,8 @@ QVariantMap MaemoDeployStep::toMap() const
QVariantMap map(BuildStep::toMap());
addDeployTimesToMap(map);
map.insert(DeployToSysrootKey, m_deployToSysroot);
map.unite(m_deviceConfigModel->toMap());
map.insert(DeviceIdKey,
MaemoDeviceConfigurations::instance()->internalId(m_deviceConfig));
return map;
}
......@@ -183,7 +184,7 @@ bool MaemoDeployStep::fromMap(const QVariantMap &map)
if (!BuildStep::fromMap(map))
return false;
getDeployTimesFromMap(map);
m_deviceConfigModel->fromMap(map);
setDeviceConfig(map.value(DeviceIdKey, MaemoDeviceConfig::InvalidId).toULongLong());
m_deployToSysroot = map.value(DeployToSysrootKey, true).toBool();
return true;
}
......@@ -292,9 +293,23 @@ void MaemoDeployStep::setDeployed(const QString &host,
QDateTime::currentDateTime());
}
MaemoDeviceConfig MaemoDeployStep::deviceConfig() const
void MaemoDeployStep::handleDeviceConfigurationsUpdated()
{
return deviceConfigModel()->current();
setDeviceConfig(MaemoDeviceConfigurations::instance()->internalId(m_deviceConfig));
}
void MaemoDeployStep::setDeviceConfig(MaemoDeviceConfig::Id internalId)
{
m_deviceConfig = MaemoDeviceConfigurations::instance()->find(internalId);
if (!m_deviceConfig && MaemoDeviceConfigurations::instance()->rowCount() > 0)
m_deviceConfig = MaemoDeviceConfigurations::instance()->deviceAt(0);
emit deviceConfigChanged();
}
void MaemoDeployStep::setDeviceConfig(int i)
{
m_deviceConfig = MaemoDeviceConfigurations::instance()->deviceAt(i);
emit deviceConfigChanged();
}
void MaemoDeployStep::start()
......@@ -305,7 +320,8 @@ void MaemoDeployStep::start()
return;
}
if (!deviceConfig().isValid()) {
m_cachedDeviceConfig = m_deviceConfig;
if (!m_cachedDeviceConfig) {
raiseError(tr("Deployment failed: No valid device set."));
emit done();
return;
......@@ -315,7 +331,7 @@ void MaemoDeployStep::start()
Q_ASSERT(!m_needsInstall);
Q_ASSERT(m_filesToCopy.isEmpty());
const MaemoPackageCreationStep * const pStep = packagingStep();
const QString hostName = deviceConfig().server.host;
const QString hostName = m_cachedDeviceConfig->sshParameters().host;
if (pStep->isPackagingEnabled()) {
const MaemoDeployable d(pStep->packageFilePath(), QString());
if (currentlyNeedsDeployment(hostName, d))
......@@ -346,7 +362,7 @@ void MaemoDeployStep::handleConnectionFailure()
return;
const QString errorMsg = m_state == Connecting
? MaemoGlobal::failedToConnectToServerMessage(m_connection, deviceConfig())
? MaemoGlobal::failedToConnectToServerMessage(m_connection, m_cachedDeviceConfig)
: tr("Connection error: %1").arg(m_connection->errorString());
raiseError(errorMsg);
setState(Inactive);
......@@ -469,7 +485,7 @@ void MaemoDeployStep::handleUnmounted()
}
case UnmountingCurrentDirs:
setState(GatheringPorts);
m_portsGatherer->start(m_connection, deviceConfig().freePorts());
m_portsGatherer->start(m_connection, m_cachedDeviceConfig->freePorts());
break;
case UnmountingCurrentMounts:
writeOutput(tr("Deployment finished."));
......@@ -648,7 +664,7 @@ void MaemoDeployStep::connectToDevice()
const bool canReUse = m_connection
&& m_connection->state() == SshConnection::Connected
&& m_connection->connectionParameters() == deviceConfig().server;
&& m_connection->connectionParameters() == m_cachedDeviceConfig->sshParameters();
if (!canReUse)
m_connection = SshConnection::create();
connect(m_connection.data(), SIGNAL(connected()), this,
......@@ -659,7 +675,7 @@ void MaemoDeployStep::connectToDevice()
handleConnected();
} else {
writeOutput(tr("Connecting to device..."));
m_connection->connectToHost(deviceConfig().server);
m_connection->connectToHost(m_cachedDeviceConfig->sshParameters());
}
}
......@@ -789,7 +805,7 @@ void MaemoDeployStep::handleCopyProcessFinished(int exitStatus)
QString MaemoDeployStep::deployMountPoint() const
{
return MaemoGlobal::homeDirOnDevice(deviceConfig().server.uname)
return MaemoGlobal::homeDirOnDevice(m_cachedDeviceConfig->sshParameters().uname)
+ QLatin1String("/deployMountPoint_") + packagingStep()->projectName();
}
......@@ -874,7 +890,7 @@ void MaemoDeployStep::handlePortListReady()
if (m_state == GatheringPorts) {
setState(Mounting);
m_freePorts = deviceConfig().freePorts();
m_freePorts = m_cachedDeviceConfig->freePorts();
m_mounter->mount(&m_freePorts, m_portsGatherer);
} else {
setState(Inactive);
......
......@@ -63,7 +63,7 @@ class SshRemoteProcess;
namespace Qt4ProjectManager {
namespace Internal {
class MaemoRemoteMounter;
class MaemoDeviceConfigListModel;
class MaemoDeviceConfig;
class MaemoPackageCreationStep;
class MaemoToolChain;
class MaemoUsedPortsGatherer;
......@@ -76,8 +76,8 @@ public:
MaemoDeployStep(ProjectExplorer::BuildStepList *bc);
virtual ~MaemoDeployStep();
MaemoDeviceConfig deviceConfig() const;
MaemoDeviceConfigListModel *deviceConfigModel() const { return m_deviceConfigModel; }
QSharedPointer<const MaemoDeviceConfig> deviceConfig() const { return m_deviceConfig; }
void setDeviceConfig(int i);
bool currentlyNeedsDeployment(const QString &host,
const MaemoDeployable &deployable) const;
void setDeployed(const QString &host, const MaemoDeployable &deployable);
......@@ -92,6 +92,7 @@ public:
signals:
void done();
void error();
void deviceConfigChanged();
private slots:
void start();
......@@ -115,6 +116,7 @@ private slots:
void handleDeviceInstallerErrorOutput(const QByteArray &output);
void handlePortsGathererError(const QString &errorMsg);
void handlePortListReady();
void handleDeviceConfigurationsUpdated();
private:
enum State {
......@@ -151,6 +153,7 @@ private:
void runDpkg(const QString &packageFilePath);
void setState(State newState);
void unmount();
void setDeviceConfig(MaemoDeviceConfig::Id internalId);
static const QLatin1String Id;
......@@ -168,7 +171,8 @@ private:
bool m_needsInstall;
typedef QPair<MaemoDeployable, QString> DeployablePerHost;
QHash<DeployablePerHost, QDateTime> m_lastDeployed;
MaemoDeviceConfigListModel *m_deviceConfigModel;
QSharedPointer<const MaemoDeviceConfig> m_deviceConfig;
QSharedPointer<const MaemoDeviceConfig> m_cachedDeviceConfig;
MaemoUsedPortsGatherer *m_portsGatherer;
MaemoPortList m_freePorts;
State m_state;
......
......@@ -4,7 +4,7 @@
#include "maemodeploystep.h"
#include "maemodeployablelistmodel.h"
#include "maemodeployables.h"
#include "maemodeviceconfiglistmodel.h"
#include "maemoglobal.h"
#include "maemorunconfiguration.h"
#include <projectexplorer/buildconfiguration.h>
......@@ -39,6 +39,7 @@ MaemoDeployStepWidget::MaemoDeployStepWidget(MaemoDeployStep *step) :
SLOT(addDesktopFile()));
connect(ui->addIconButton, SIGNAL(clicked()), SLOT(addIcon()));
handleModelListReset();
}
MaemoDeployStepWidget::~MaemoDeployStepWidget()
......@@ -48,43 +49,30 @@ MaemoDeployStepWidget::~MaemoDeployStepWidget()
void MaemoDeployStepWidget::init()
{
handleDeviceConfigModelChanged();
connect(m_step->buildConfiguration()->target(),
SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
this, SLOT(handleDeviceConfigModelChanged()));
ui->deviceConfigComboBox->setModel(MaemoDeviceConfigurations::instance());
connect(m_step, SIGNAL(deviceConfigChanged()), SLOT(handleDeviceUpdate()));
handleDeviceUpdate();
connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
ui->deployToSysrootCheckBox->setChecked(m_step->isDeployToSysrootEnabled());
connect(ui->deployToSysrootCheckBox, SIGNAL(toggled(bool)), this,
SLOT(setDeployToSysroot(bool)));
handleDeviceConfigModelChanged();
}
void MaemoDeployStepWidget::handleDeviceConfigModelChanged()
{
const MaemoDeviceConfigListModel * const oldModel
= qobject_cast<MaemoDeviceConfigListModel *>(ui->deviceConfigComboBox->model());
if (oldModel)
disconnect(oldModel, 0, this, 0);
MaemoDeviceConfigListModel * const devModel = m_step->deviceConfigModel();
ui->deviceConfigComboBox->setModel(devModel);
connect(devModel, SIGNAL(currentChanged()), this,
SLOT(handleDeviceUpdate()));
connect(devModel, SIGNAL(modelReset()), this,
SLOT(handleDeviceUpdate()));
handleDeviceUpdate();
}
void MaemoDeployStepWidget::handleDeviceUpdate()
{
ui->deviceConfigComboBox->setCurrentIndex(m_step->deviceConfigModel()
->currentIndex());
const MaemoDeviceConfig::ConstPtr &devConf = m_step->deviceConfig();
const MaemoDeviceConfigurations * const devConfigs
= MaemoDeviceConfigurations::instance();
ui->deviceConfigComboBox->setCurrentIndex(
devConfigs->indexForInternalId(devConfigs->internalId(devConf)));
emit updateSummary();
}
QString MaemoDeployStepWidget::summaryText() const
{
return tr("<b>Deploy to device</b>: %1").arg(m_step->deviceConfig().name);
return tr("<b>Deploy to device</b>: %1")
.arg(MaemoGlobal::deviceConfigurationName(m_step->deviceConfig()));
}
QString MaemoDeployStepWidget::displayName() const
......@@ -94,7 +82,10 @@ QString MaemoDeployStepWidget::displayName() const
void MaemoDeployStepWidget::setCurrentDeviceConfig(int index)
{
m_step->deviceConfigModel()->setCurrentIndex(index);
disconnect(m_step, SIGNAL(deviceConfigChanged()), this,
SLOT(handleDeviceUpdate()));
m_step->setDeviceConfig(index);
connect(m_step, SIGNAL(deviceConfigChanged()), SLOT(handleDeviceUpdate()));
}
void MaemoDeployStepWidget::setDeployToSysroot(bool doDeploy)
......
......@@ -23,7 +23,6 @@ public:
private:
Q_SLOT void handleDeviceUpdate();
Q_SLOT void handleDeviceConfigModelChanged();
Q_SLOT void setCurrentDeviceConfig(int index);
Q_SLOT void setDeployToSysroot(bool doDeloy);
Q_SLOT void setModel(int row);
......
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the 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 "maemodeviceconfiglistmodel.h"
#include "maemoconstants.h"
namespace Qt4ProjectManager {
namespace Internal {
MaemoDeviceConfigListModel::MaemoDeviceConfigListModel(QObject *parent)
: QAbstractListModel(parent), m_currentIndex(-1)
{
setupList();
const MaemoDeviceConfigurations &devConfs
= MaemoDeviceConfigurations::instance();
if (m_devConfigs.isEmpty())
setInvalid();
else
setCurrentIndex(0);
connect(&devConfs, SIGNAL(updated()), this,
SLOT(handleDeviceConfigListChange()));
}
void MaemoDeviceConfigListModel::setupList()
{
m_devConfigs.clear();
const MaemoDeviceConfigurations &devConfs
= MaemoDeviceConfigurations::instance();
foreach (const MaemoDeviceConfig &devConfig, devConfs.devConfigs()) {
if (devConfig.freePorts().hasMore())
m_devConfigs << devConfig;
}
}
void MaemoDeviceConfigListModel::setCurrentIndex(int index)
{
m_currentIndex = index;
m_currentId = m_devConfigs.at(m_currentIndex).internalId;
emit currentChanged();
}
void MaemoDeviceConfigListModel::resetCurrentIndex()
{
if (m_devConfigs.isEmpty()) {
setInvalid();
return;
}
for (int i = 0; i < m_devConfigs.count(); ++i) {
if (m_devConfigs.at(i).internalId == m_currentId) {
setCurrentIndex(i);
return;
}
}
setCurrentIndex(0);
}
void MaemoDeviceConfigListModel::setInvalid()
{
m_currentIndex = -1;
m_currentId = MaemoDeviceConfig::InvalidId;
emit currentChanged();
}
MaemoDeviceConfig MaemoDeviceConfigListModel::current() const
{
return MaemoDeviceConfigurations::instance().find(m_currentId);
}
QVariantMap MaemoDeviceConfigListModel::toMap() const
{
QVariantMap map;
map.insert(DeviceIdKey, current().internalId);
return map;
}
void MaemoDeviceConfigListModel::fromMap(const QVariantMap &map)
{
const quint64 oldId = m_currentId;
m_currentId = map.value(DeviceIdKey, 0).toULongLong();
resetCurrentIndex();
if (oldId != m_currentId)
emit currentChanged();
}
void MaemoDeviceConfigListModel::handleDeviceConfigListChange()
{
setupList();
resetCurrentIndex();
reset();
emit currentChanged();
}
int MaemoDeviceConfigListModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_devConfigs.count();
}
QVariant MaemoDeviceConfigListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() >= rowCount()
|| role != Qt::DisplayRole)
return QVariant();
return m_devConfigs.at(index.row()).name;
}