DeviceFactory: Allow for querying supported device types

Allow to query the DeviceFactory for device types it can create as
well as the display names to use for those types. Also allow to
create any of the supported device types.

The MaddeDeviceFactory makes use of the information to set the correct
type in the wizard.

Change-Id: I8c05ecd467e5bb1b151a84a8d62ef98a57849605
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Tobias Hunger
2012-05-29 17:00:24 +02:00
parent efb1b7fc3b
commit 468d7c32b6
24 changed files with 177 additions and 98 deletions

View File

@@ -48,19 +48,19 @@ MaddeDeviceConfigurationFactory::MaddeDeviceConfigurationFactory(QObject *parent
{ {
} }
QString MaddeDeviceConfigurationFactory::displayName() const QString MaddeDeviceConfigurationFactory::displayNameForId(Core::Id type) const
{ {
return tr("Device with MADDE support (Fremantle, Harmattan, MeeGo)"); return MaddeDevice::maddeDisplayType(type);
} }
bool MaddeDeviceConfigurationFactory::canCreate() const QList<Core::Id> MaddeDeviceConfigurationFactory::availableCreationIds() const
{ {
return true; return QList<Core::Id>() << Core::Id(Maemo5OsType) << Core::Id(HarmattanOsType) << Core::Id(MeeGoOsType);
} }
IDevice::Ptr MaddeDeviceConfigurationFactory::create() const IDevice::Ptr MaddeDeviceConfigurationFactory::create(Core::Id id) const
{ {
MaemoDeviceConfigWizard wizard; MaemoDeviceConfigWizard wizard(id);
if (wizard.exec() != QDialog::Accepted) if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr(); return IDevice::Ptr();
return wizard.device(); return wizard.device();

View File

@@ -43,9 +43,10 @@ class MaddeDeviceConfigurationFactory : public ProjectExplorer::IDeviceFactory
public: public:
MaddeDeviceConfigurationFactory(QObject *parent = 0); MaddeDeviceConfigurationFactory(QObject *parent = 0);
QString displayName() const; QString displayNameForId(Core::Id type) const;
bool canCreate() const; QList<Core::Id> availableCreationIds() const;
ProjectExplorer::IDevice::Ptr create() const;
ProjectExplorer::IDevice::Ptr create(Core::Id id) const;
bool canRestore(const QVariantMap &map) const; bool canRestore(const QVariantMap &map) const;
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;
}; };

View File

@@ -99,21 +99,13 @@ class MaemoDeviceConfigWizardStartPage : public QWizardPage
Q_OBJECT Q_OBJECT
public: public:
MaemoDeviceConfigWizardStartPage(QWidget *parent = 0) explicit MaemoDeviceConfigWizardStartPage(QWidget *parent = 0)
: QWizardPage(parent), m_ui(new Ui::MaemoDeviceConfigWizardStartPage) : QWizardPage(parent), m_ui(new Ui::MaemoDeviceConfigWizardStartPage)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setTitle(tr("General Information")); setTitle(tr("General Information"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color) setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
m_ui->osTypeComboBox->addItem(MaddeDevice::maddeDisplayType(Core::Id(Maemo5OsType)),
QVariant::fromValue(Core::Id(Maemo5OsType)));
const QVariant harmattanIdVariant = QVariant::fromValue(Core::Id(HarmattanOsType));
m_ui->osTypeComboBox->addItem(MaddeDevice::maddeDisplayType(Core::Id(HarmattanOsType)),
harmattanIdVariant);
m_ui->osTypeComboBox->addItem(MaddeDevice::maddeDisplayType(Core::Id(MeeGoOsType)),
QVariant::fromValue(Core::Id(MeeGoOsType)));
QButtonGroup *buttonGroup = new QButtonGroup(this); QButtonGroup *buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(true); buttonGroup->setExclusive(true);
buttonGroup->addButton(m_ui->hwButton); buttonGroup->addButton(m_ui->hwButton);
@@ -121,7 +113,6 @@ public:
connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleMachineTypeChanged())); connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleMachineTypeChanged()));
m_ui->nameLineEdit->setText(tr("MeeGo Device")); m_ui->nameLineEdit->setText(tr("MeeGo Device"));
m_ui->osTypeComboBox->setCurrentIndex(m_ui->osTypeComboBox->findData(harmattanIdVariant));
m_ui->hwButton->setChecked(true); m_ui->hwButton->setChecked(true);
handleMachineTypeChanged(); handleMachineTypeChanged();
m_ui->hostNameLineEdit->setText(defaultHost(machineType())); m_ui->hostNameLineEdit->setText(defaultHost(machineType()));
@@ -134,6 +125,12 @@ public:
SIGNAL(completeChanged())); SIGNAL(completeChanged()));
} }
void setDeviceType(Core::Id type)
{
m_deviceType = type;
m_ui->nameLineEdit->setText(tr("%1 Device").arg(MaddeDevice::maddeDisplayType(m_deviceType)));
}
virtual bool isComplete() const virtual bool isComplete() const
{ {
return !configName().isEmpty() && !hostName().isEmpty(); return !configName().isEmpty() && !hostName().isEmpty();
@@ -150,7 +147,7 @@ public:
Core::Id deviceType() const Core::Id deviceType() const
{ {
return m_ui->osTypeComboBox->itemData(m_ui->osTypeComboBox->currentIndex()).value<Core::Id>(); return m_deviceType;
} }
LinuxDeviceConfiguration::MachineType machineType() const LinuxDeviceConfiguration::MachineType machineType() const
@@ -177,6 +174,7 @@ private slots:
private: private:
const QScopedPointer<Ui::MaemoDeviceConfigWizardStartPage> m_ui; const QScopedPointer<Ui::MaemoDeviceConfigWizardStartPage> m_ui;
Core::Id m_deviceType;
}; };
class MaemoDeviceConfigWizardPreviousKeySetupCheckPage : public QWizardPage class MaemoDeviceConfigWizardPreviousKeySetupCheckPage : public QWizardPage
@@ -540,11 +538,12 @@ struct MaemoDeviceConfigWizardPrivate
}; };
MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent) MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(Core::Id id, QWidget *parent)
: QWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this)) : QWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this))
{ {
setWindowTitle(tr("New Device Configuration Setup")); setWindowTitle(tr("New Device Configuration Setup"));
setPage(StartPageId, &d->startPage); setPage(StartPageId, &d->startPage);
d->startPage.setDeviceType(id);
setPage(PreviousKeySetupCheckPageId, &d->previousKeySetupPage); setPage(PreviousKeySetupCheckPageId, &d->previousKeySetupPage);
setPage(ReuseKeysCheckPageId, &d->reuseKeysCheckPage); setPage(ReuseKeysCheckPageId, &d->reuseKeysCheckPage);
setPage(KeyCreationPageId, &d->keyCreationPage); setPage(KeyCreationPageId, &d->keyCreationPage);

View File

@@ -46,7 +46,7 @@ class MaemoDeviceConfigWizard : public QWizard
Q_OBJECT Q_OBJECT
public: public:
explicit MaemoDeviceConfigWizard(QWidget *parent = 0); explicit MaemoDeviceConfigWizard(Core::Id id, QWidget *parent = 0);
~MaemoDeviceConfigWizard(); ~MaemoDeviceConfigWizard();
ProjectExplorer::IDevice::Ptr device(); ProjectExplorer::IDevice::Ptr device();

View File

@@ -7,13 +7,16 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>721</width> <width>721</width>
<height>176</height> <height>136</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>WizardPage</string> <string>WizardPage</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="nameLabel"> <widget class="QLabel" name="nameLabel">
<property name="text"> <property name="text">
@@ -25,40 +28,13 @@
<widget class="QLineEdit" name="nameLineEdit"/> <widget class="QLineEdit" name="nameLineEdit"/>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="maemoVersionLabel">
<property name="text">
<string>The system running on the device:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="osTypeComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="typeLabel"> <widget class="QLabel" name="typeLabel">
<property name="text"> <property name="text">
<string>The kind of device:</string> <string>The kind of device:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QRadioButton" name="emulatorButton"> <widget class="QRadioButton" name="emulatorButton">
@@ -89,24 +65,24 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0"> <item row="2" column="0">
<widget class="QLabel" name="hostNameLabel"> <widget class="QLabel" name="hostNameLabel">
<property name="text"> <property name="text">
<string>The device's host name or IP address:</string> <string>The device's host name or IP address:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="hostNameLineEdit"/> <widget class="QLineEdit" name="hostNameLineEdit"/>
</item> </item>
<item row="4" column="0"> <item row="3" column="0">
<widget class="QLabel" name="sshPortLabel"> <widget class="QLabel" name="sshPortLabel">
<property name="text"> <property name="text">
<string>The SSH server port:</string> <string>The SSH server port:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QSpinBox" name="sshPortSpinBox"/> <widget class="QSpinBox" name="sshPortSpinBox"/>

View File

@@ -31,13 +31,12 @@
**************************************************************************/ **************************************************************************/
#include "desktopdevice.h" #include "desktopdevice.h"
#include "projectexplorerconstants.h"
#include <QCoreApplication> #include <QCoreApplication>
namespace ProjectExplorer { namespace ProjectExplorer {
const Core::Id DesktopDevice::Id = Core::Id("Desktop Device");
IDevice::DeviceInfo DesktopDevice::deviceInformation() const IDevice::DeviceInfo DesktopDevice::deviceInformation() const
{ {
return DeviceInfo(); return DeviceInfo();
@@ -74,7 +73,8 @@ IDevice::Ptr DesktopDevice::clone() const
return Ptr(new DesktopDevice(*this)); return Ptr(new DesktopDevice(*this));
} }
DesktopDevice::DesktopDevice() : IDevice(Core::Id("Desktop"), IDevice::AutoDetected, Id) DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE), IDevice::AutoDetected,
Core::Id(Constants::DESKTOP_DEVICE_ID))
{ {
setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Run locally")); setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Run locally"));
} }

View File

@@ -56,8 +56,6 @@ public:
IDevice::Ptr clone() const; IDevice::Ptr clone() const;
static const Core::Id Id;
protected: protected:
DesktopDevice(); DesktopDevice();
DesktopDevice(const DesktopDevice &other); DesktopDevice(const DesktopDevice &other);

View File

@@ -32,13 +32,24 @@
#include "desktopdevicefactory.h" #include "desktopdevicefactory.h"
#include "desktopdevice.h" #include "desktopdevice.h"
#include "projectexplorerconstants.h"
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
QString DesktopDeviceFactory::displayName() const DesktopDeviceFactory::DesktopDeviceFactory(QObject *parent) : IDeviceFactory(parent)
{ }
QString DesktopDeviceFactory::displayNameForId(Core::Id type) const
{ {
if (type == Core::Id(Constants::DESKTOP_DEVICE_TYPE))
return tr("Desktop"); return tr("Desktop");
return QString();
}
QList<Core::Id> DesktopDeviceFactory::availableCreationIds() const
{
return QList<Core::Id>() << Core::Id(Constants::DESKTOP_DEVICE_TYPE);
} }
bool DesktopDeviceFactory::canCreate() const bool DesktopDeviceFactory::canCreate() const
@@ -46,14 +57,15 @@ bool DesktopDeviceFactory::canCreate() const
return false; return false;
} }
IDevice::Ptr DesktopDeviceFactory::create() const IDevice::Ptr DesktopDeviceFactory::create(Core::Id id) const
{ {
Q_UNUSED(id);
return IDevice::Ptr(); return IDevice::Ptr();
} }
bool DesktopDeviceFactory::canRestore(const QVariantMap &map) const bool DesktopDeviceFactory::canRestore(const QVariantMap &map) const
{ {
return IDevice::idFromMap(map) == DesktopDevice::Id; return IDevice::idFromMap(map) == Core::Id(Constants::DESKTOP_DEVICE_ID);
} }
IDevice::Ptr DesktopDeviceFactory::restore(const QVariantMap &map) const IDevice::Ptr DesktopDeviceFactory::restore(const QVariantMap &map) const
@@ -62,8 +74,5 @@ IDevice::Ptr DesktopDeviceFactory::restore(const QVariantMap &map) const
return IDevice::Ptr(new DesktopDevice); return IDevice::Ptr(new DesktopDevice);
} }
DesktopDeviceFactory::DesktopDeviceFactory(QObject *parent) : IDeviceFactory(parent)
{ }
} // namespace Internal } // namespace Internal
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -45,10 +45,11 @@ class DesktopDeviceFactory : public IDeviceFactory
public: public:
explicit DesktopDeviceFactory(QObject *parent = 0); explicit DesktopDeviceFactory(QObject *parent = 0);
QString displayName() const; QString displayNameForId(Core::Id type) const;
QList<Core::Id> availableCreationIds() const;
bool canCreate() const; bool canCreate() const;
IDevice::Ptr create() const; IDevice::Ptr create(Core::Id id) const;
bool canRestore(const QVariantMap &map) const; bool canRestore(const QVariantMap &map) const;
IDevice::Ptr restore(const QVariantMap &map) const; IDevice::Ptr restore(const QVariantMap &map) const;
}; };

View File

@@ -54,8 +54,11 @@ DeviceFactorySelectionDialog::DeviceFactorySelectionDialog(QWidget *parent) :
foreach (const IDeviceFactory * const factory, factories) { foreach (const IDeviceFactory * const factory, factories) {
if (!factory->canCreate()) if (!factory->canCreate())
continue; continue;
m_factories << factory; foreach (Core::Id id, factory->availableCreationIds()) {
ui->listWidget->addItem(factory->displayName()); QListWidgetItem *item = new QListWidgetItem(factory->displayNameForId(id));
item->setData(Qt::UserRole, QVariant::fromValue(id));
ui->listWidget->addItem(item);
}
} }
connect(ui->listWidget, SIGNAL(itemSelectionChanged()), SLOT(handleItemSelectionChanged())); connect(ui->listWidget, SIGNAL(itemSelectionChanged()), SLOT(handleItemSelectionChanged()));
@@ -73,9 +76,12 @@ void DeviceFactorySelectionDialog::handleItemSelectionChanged()
->setEnabled(!ui->listWidget->selectedItems().isEmpty()); ->setEnabled(!ui->listWidget->selectedItems().isEmpty());
} }
const IDeviceFactory *DeviceFactorySelectionDialog::selectedFactory() const Core::Id DeviceFactorySelectionDialog::selectedId() const
{ {
return m_factories.at(ui->listWidget->row(ui->listWidget->selectedItems().first())); QList<QListWidgetItem *> selected = ui->listWidget->selectedItems();
if (selected.isEmpty())
return Core::Id();
return selected.at(0)->data(Qt::UserRole).value<Core::Id>();
} }
} // namespace Internal } // namespace Internal

View File

@@ -33,6 +33,8 @@
#ifndef DEVICEFACTORYSELECTIONDIALOG_H #ifndef DEVICEFACTORYSELECTIONDIALOG_H
#define DEVICEFACTORYSELECTIONDIALOG_H #define DEVICEFACTORYSELECTIONDIALOG_H
#include <coreplugin/id.h>
#include <QList> #include <QList>
#include <QDialog> #include <QDialog>
@@ -49,13 +51,12 @@ class DeviceFactorySelectionDialog : public QDialog
public: public:
explicit DeviceFactorySelectionDialog(QWidget *parent = 0); explicit DeviceFactorySelectionDialog(QWidget *parent = 0);
~DeviceFactorySelectionDialog(); ~DeviceFactorySelectionDialog();
const IDeviceFactory *selectedFactory() const; Core::Id selectedId() const;
private: private:
Q_SLOT void handleItemSelectionChanged(); Q_SLOT void handleItemSelectionChanged();
Ui::DeviceFactorySelectionDialog *ui; Ui::DeviceFactorySelectionDialog *ui;
QList<const IDeviceFactory *> m_factories;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -31,7 +31,7 @@
**************************************************************************/ **************************************************************************/
#include "devicemanagermodel.h" #include "devicemanagermodel.h"
#include "desktopdevice.h" #include "../projectexplorerconstants.h"
#include "devicemanager.h" #include "devicemanager.h"
#include <coreplugin/id.h> #include <coreplugin/id.h>
@@ -127,7 +127,7 @@ void DeviceManagerModel::handleDeviceListChanged()
for (int i = 0; i < d->deviceManager->deviceCount(); ++i) { for (int i = 0; i < d->deviceManager->deviceCount(); ++i) {
IDevice::ConstPtr dev = d->deviceManager->deviceAt(i); IDevice::ConstPtr dev = d->deviceManager->deviceAt(i);
if (dev->id() == DesktopDevice::Id) if (dev->id() == Core::Id(Constants::DESKTOP_DEVICE_ID))
continue; continue;
d->devices << dev; d->devices << dev;
} }

View File

@@ -169,7 +169,13 @@ void DeviceSettingsWidget::addDevice()
if (d.exec() != QDialog::Accepted) if (d.exec() != QDialog::Accepted)
return; return;
IDevice::Ptr device = d.selectedFactory()->create(); Core::Id toCreate = d.selectedId();
if (!toCreate.isValid())
return;
IDeviceFactory *factory = IDeviceFactory::find(toCreate);
if (!factory)
return;
IDevice::Ptr device = factory->create(toCreate);
if (device.isNull()) if (device.isNull())
return; return;

View File

@@ -0,0 +1,58 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "idevicefactory.h"
#include <extensionsystem/pluginmanager.h>
namespace ProjectExplorer {
bool IDeviceFactory::canCreate() const
{
return !availableCreationIds().isEmpty();
}
IDeviceFactory *IDeviceFactory::find(Core::Id type)
{
QList<IDeviceFactory *> factories
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
foreach (IDeviceFactory *factory, factories) {
if (factory->availableCreationIds().contains(type))
return factory;
}
return 0;
}
IDeviceFactory::IDeviceFactory(QObject *parent) : QObject(parent)
{ }
} // namespace ProjectExplorer

View File

@@ -60,20 +60,24 @@ class PROJECTEXPLORER_EXPORT IDeviceFactory : public QObject
public: public:
/*! /*!
A short, one-line description of what kind of device this factory supports. A short, one-line description of what the device type.
*/ */
virtual QString displayName() const = 0; virtual QString displayNameForId(Core::Id type) const = 0;
/*!
A list of device types this factory can create.
*/
virtual QList<Core::Id> availableCreationIds() const = 0;
/*! /*!
Check whether this factory can create new devices. This is used to hide Check whether this factory can create new devices. This is used to hide
auto-detect-only factories from the listing of possible devices to create. auto-detect-only factories from the listing of possible devices to create.
*/ */
virtual bool canCreate() const = 0; virtual bool canCreate() const;
/*! /*!
Create a new device. This may or may not open a wizard. Create a new device. This may or may not open a wizard.
*/ */
virtual IDevice::Ptr create() const = 0; virtual IDevice::Ptr create(Core::Id id) const = 0;
/*! /*!
Check whether this factory can restore a device from the given serialized state. Check whether this factory can restore a device from the given serialized state.
@@ -86,8 +90,10 @@ public:
*/ */
virtual IDevice::Ptr restore(const QVariantMap &map) const = 0; virtual IDevice::Ptr restore(const QVariantMap &map) const = 0;
static IDeviceFactory *find(Core::Id type);
protected: protected:
IDeviceFactory(QObject *parent) : QObject(parent) { } IDeviceFactory(QObject *parent = 0);
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -1131,7 +1131,7 @@ void ProjectExplorerPlugin::extensionsInitialized()
bool ProjectExplorerPlugin::delayedInitialize() bool ProjectExplorerPlugin::delayedInitialize()
{ {
DeviceManager *dm = DeviceManager::instance(); DeviceManager *dm = DeviceManager::instance();
if (dm->find(DesktopDevice::Id).isNull()) if (dm->find(Core::Id(Constants::DESKTOP_DEVICE_ID)).isNull())
DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice)); DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
return true; return true;

View File

@@ -200,6 +200,7 @@ SOURCES += projectexplorer.cpp \
devicesupport/idevice.cpp \ devicesupport/idevice.cpp \
devicesupport/desktopdevice.cpp \ devicesupport/desktopdevice.cpp \
devicesupport/desktopdevicefactory.cpp \ devicesupport/desktopdevicefactory.cpp \
devicesupport/idevicefactory.cpp \
devicesupport/devicemanager.cpp \ devicesupport/devicemanager.cpp \
devicesupport/devicemanagermodel.cpp \ devicesupport/devicemanagermodel.cpp \
devicesupport/devicefactoryselectiondialog.cpp \ devicesupport/devicefactoryselectiondialog.cpp \

View File

@@ -285,6 +285,7 @@ QtcPlugin {
"devicesupport/devicesettingswidget.h", "devicesupport/devicesettingswidget.h",
"devicesupport/devicesettingswidget.ui", "devicesupport/devicesettingswidget.ui",
"devicesupport/idevicewidget.h", "devicesupport/idevicewidget.h",
"devicesupport/idevicefactory.cpp",
"devicesupport/idevicefactory.h" "devicesupport/idevicefactory.h"
] ]

View File

@@ -232,6 +232,10 @@ const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768;
// Default directory to run custom (build) commands in. // Default directory to run custom (build) commands in.
const char DEFAULT_WORKING_DIR[] = "%{buildDir}"; const char DEFAULT_WORKING_DIR[] = "%{buildDir}";
// Desktop Device related ids:
const char DESKTOP_DEVICE_ID[] = "Desktop Device";
const char DESKTOP_DEVICE_TYPE[] = "Desktop";
} // namespace Constants } // namespace Constants
// Run modes // Run modes

View File

@@ -43,7 +43,6 @@
#include <limits> #include <limits>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <projectexplorer/buildmanager.h> #include <projectexplorer/buildmanager.h>
#include <projectexplorer/devicesupport/desktopdevice.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
@@ -545,7 +544,7 @@ void Target::updateDeviceState()
ProjectExplorer::IDevice::ConstPtr Target::currentDevice() const ProjectExplorer::IDevice::ConstPtr Target::currentDevice() const
{ {
return DeviceManager::instance()->find(ProjectExplorer::DesktopDevice::Id); return DeviceManager::instance()->find(ProjectExplorer::Constants::DESKTOP_DEVICE_ID);
} }
void Target::setEnabled(bool enabled) void Target::setEnabled(bool enabled)

View File

@@ -42,9 +42,16 @@ namespace Internal {
SymbianIDeviceFactory::SymbianIDeviceFactory(QObject *parent) : IDeviceFactory(parent) SymbianIDeviceFactory::SymbianIDeviceFactory(QObject *parent) : IDeviceFactory(parent)
{ } { }
QString SymbianIDeviceFactory::displayName() const QString SymbianIDeviceFactory::displayNameForId(Core::Id type) const
{ {
if (type == deviceType())
return tr("Symbian Device"); return tr("Symbian Device");
return QString();
}
QList<Core::Id> SymbianIDeviceFactory::availableCreationIds() const
{
return QList<Core::Id>() << deviceType();
} }
bool SymbianIDeviceFactory::canCreate() const bool SymbianIDeviceFactory::canCreate() const
@@ -52,8 +59,9 @@ bool SymbianIDeviceFactory::canCreate() const
return false; return false;
} }
ProjectExplorer::IDevice::Ptr SymbianIDeviceFactory::create() const ProjectExplorer::IDevice::Ptr SymbianIDeviceFactory::create(Core::Id id) const
{ {
Q_UNUSED(id);
return ProjectExplorer::IDevice::Ptr(); return ProjectExplorer::IDevice::Ptr();
} }

View File

@@ -45,9 +45,11 @@ class SymbianIDeviceFactory : public ProjectExplorer::IDeviceFactory
public: public:
SymbianIDeviceFactory(QObject *parent = 0); SymbianIDeviceFactory(QObject *parent = 0);
QString displayName() const; QString displayNameForId(Core::Id type) const;
QList<Core::Id> availableCreationIds() const;
bool canCreate() const; bool canCreate() const;
ProjectExplorer::IDevice::Ptr create() const; ProjectExplorer::IDevice::Ptr create(Core::Id id) const;
bool canRestore(const QVariantMap &map) const; bool canRestore(const QVariantMap &map) const;
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;

View File

@@ -46,18 +46,20 @@ GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory(Q
{ {
} }
QString GenericLinuxDeviceConfigurationFactory::displayName() const QString GenericLinuxDeviceConfigurationFactory::displayNameForId(Core::Id type) const
{ {
QTC_ASSERT(type == Core::Id(Constants::GenericLinuxOsType), return QString());
return tr("Generic Linux Device"); return tr("Generic Linux Device");
} }
bool GenericLinuxDeviceConfigurationFactory::canCreate() const QList<Core::Id> GenericLinuxDeviceConfigurationFactory::availableCreationIds() const
{ {
return true; return QList<Core::Id>() << Core::Id(Constants::GenericLinuxOsType);
} }
IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create() const IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create(Core::Id id) const
{ {
QTC_ASSERT(id == Core::Id(Constants::GenericLinuxOsType), return IDevice::Ptr());
GenericLinuxDeviceConfigurationWizard wizard; GenericLinuxDeviceConfigurationWizard wizard;
if (wizard.exec() != QDialog::Accepted) if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr(); return IDevice::Ptr();

View File

@@ -46,9 +46,10 @@ class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationFactory
public: public:
GenericLinuxDeviceConfigurationFactory(QObject *parent = 0); GenericLinuxDeviceConfigurationFactory(QObject *parent = 0);
QString displayName() const; QString displayNameForId(Core::Id type) const;
bool canCreate() const; QList<Core::Id> availableCreationIds() const;
ProjectExplorer::IDevice::Ptr create() const;
ProjectExplorer::IDevice::Ptr create(Core::Id id) const;
bool canRestore(const QVariantMap &map) const; bool canRestore(const QVariantMap &map) const;
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;
}; };