diff --git a/src/plugins/madde/maddedeviceconfigurationfactory.cpp b/src/plugins/madde/maddedeviceconfigurationfactory.cpp index c32b8edfdef..663a33c89b0 100644 --- a/src/plugins/madde/maddedeviceconfigurationfactory.cpp +++ b/src/plugins/madde/maddedeviceconfigurationfactory.cpp @@ -53,9 +53,17 @@ QString MaddeDeviceConfigurationFactory::displayName() const return tr("Device with MADDE support (Fremantle, Harmattan, MeeGo)"); } -IDeviceWizard *MaddeDeviceConfigurationFactory::createWizard(QWidget *parent) const +bool MaddeDeviceConfigurationFactory::canCreate() const { - return new MaemoDeviceConfigWizard(parent); + return true; +} + +IDevice::Ptr MaddeDeviceConfigurationFactory::create() const +{ + MaemoDeviceConfigWizard *wizard = new MaemoDeviceConfigWizard; + if (wizard->exec() != QDialog::Accepted) + return IDevice::Ptr(); + return wizard->device(); } IDevice::Ptr MaddeDeviceConfigurationFactory::loadDevice(const QVariantMap &map) const diff --git a/src/plugins/madde/maddedeviceconfigurationfactory.h b/src/plugins/madde/maddedeviceconfigurationfactory.h index e64b9a71e20..aa15a1b4792 100644 --- a/src/plugins/madde/maddedeviceconfigurationfactory.h +++ b/src/plugins/madde/maddedeviceconfigurationfactory.h @@ -44,7 +44,8 @@ public: MaddeDeviceConfigurationFactory(QObject *parent = 0); QString displayName() const; - ProjectExplorer::IDeviceWizard *createWizard(QWidget *parent) const; + bool canCreate() const; + ProjectExplorer::IDevice::Ptr create() const; ProjectExplorer::IDevice::Ptr loadDevice(const QVariantMap &map) const; bool supportsDeviceType(const QString &type) const; }; diff --git a/src/plugins/madde/maemodeviceconfigwizard.cpp b/src/plugins/madde/maemodeviceconfigwizard.cpp index b476deb00bf..f16fd901fdb 100644 --- a/src/plugins/madde/maemodeviceconfigwizard.cpp +++ b/src/plugins/madde/maemodeviceconfigwizard.cpp @@ -539,7 +539,7 @@ struct MaemoDeviceConfigWizardPrivate MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent) - : IDeviceWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this)) + : QWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this)) { setWindowTitle(tr("New Device Configuration Setup")); setPage(StartPageId, &d->startPage); diff --git a/src/plugins/madde/maemodeviceconfigwizard.h b/src/plugins/madde/maemodeviceconfigwizard.h index 9ea0f11eabf..04ffd6893bb 100644 --- a/src/plugins/madde/maemodeviceconfigwizard.h +++ b/src/plugins/madde/maemodeviceconfigwizard.h @@ -33,14 +33,15 @@ #define MAEMODEVICECONFIGWIZARD_H #include -#include + +#include namespace Madde { namespace Internal { struct MaemoDeviceConfigWizardPrivate; -class MaemoDeviceConfigWizard : public ProjectExplorer::IDeviceWizard +class MaemoDeviceConfigWizard : public QWizard { Q_OBJECT diff --git a/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp b/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp index 7ce9e57c7a5..c8093c70eef 100644 --- a/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp @@ -52,6 +52,8 @@ DeviceFactorySelectionDialog::DeviceFactorySelectionDialog(QWidget *parent) : const QList &factories = ExtensionSystem::PluginManager::instance()->getObjects(); foreach (const IDeviceFactory * const factory, factories) { + if (!factory->canCreate()) + continue; m_factories << factory; ui->listWidget->addItem(factory->displayName()); } diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.h b/src/plugins/projectexplorer/devicesupport/devicemanager.h index accd04b5202..7a7b5a9d8ce 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.h +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.h @@ -39,6 +39,7 @@ #include namespace ProjectExplorer { +class IDevice; class IDeviceFactory; namespace Internal { @@ -51,6 +52,7 @@ class PROJECTEXPLORER_EXPORT DeviceManager : public QObject Q_OBJECT friend class Internal::DeviceSettingsWidget; friend class IDevice; + public: ~DeviceManager(); diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp index e2f33491cbc..a69408f0d93 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp @@ -37,7 +37,6 @@ #include "idevice.h" #include "idevicefactory.h" #include "idevicewidget.h" -#include "idevicewizard.h" #include #include @@ -137,6 +136,17 @@ void DeviceSettingsWidget::initGui() m_ui->configurationComboBox->setModel(model); m_ui->nameLineEdit->setValidator(m_nameValidator); + bool hasDeviceFactories = false; + const QList &factories + = ExtensionSystem::PluginManager::instance()->getObjects(); + foreach (const IDeviceFactory *f, factories) { + if (f->canCreate()) { + hasDeviceFactories = true; + break; + } + } + m_ui->addConfigButton->setEnabled(hasDeviceFactories); + int lastIndex = Core::ICore::settings() ->value(QLatin1String(LastDeviceIndexKey), 0).toInt(); if (lastIndex == -1) @@ -152,21 +162,15 @@ void DeviceSettingsWidget::initGui() void DeviceSettingsWidget::addDevice() { - const QList &factories - = ExtensionSystem::PluginManager::instance()->getObjects(); - - if (factories.isEmpty()) // Can't happen, because this plugin provides the generic one. - return; - DeviceFactorySelectionDialog d; if (d.exec() != QDialog::Accepted) return; - const QScopedPointer wizard(d.selectedFactory()->createWizard(this)); - if (wizard->exec() != QDialog::Accepted) + IDevice::Ptr device = d.selectedFactory()->create(); + if (device.isNull()) return; - m_deviceManager->addDevice(wizard->device()); + m_deviceManager->addDevice(device); m_ui->removeConfigButton->setEnabled(true); m_ui->configurationComboBox->setCurrentIndex(m_ui->configurationComboBox->count()-1); } diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 9c44012d6b6..7f0ae1a56bf 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -167,7 +167,7 @@ IDevice::IDevice() : d(new Internal::IDevicePrivate) { } -IDevice::IDevice(const QString &type, Origin origin, const QString fingerprint) +IDevice::IDevice(const QString &type, Origin origin, const QString &fingerprint) : d(new Internal::IDevicePrivate) { d->type = type; @@ -193,6 +193,8 @@ QString IDevice::displayName() const void IDevice::setDisplayName(const QString &name) { + if (d->displayName == name) + return; d->displayName = name; } diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 83b934fb200..75a0d942c64 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -74,6 +74,7 @@ public: virtual QStringList actionIds() const = 0; virtual QString displayNameForActionId(const QString &actionId) const = 0; virtual QDialog *createAction(const QString &actionId, QWidget *parent = 0) const = 0; + virtual void fromMap(const QVariantMap &map); virtual Ptr clone() const = 0; @@ -83,7 +84,7 @@ public: protected: IDevice(); - IDevice(const QString &type, Origin origin, const QString fingerprint = QString()); + IDevice(const QString &type, Origin origin, const QString &fingerprint = QString()); IDevice(const IDevice &other); Ptr sharedFromThis(); diff --git a/src/plugins/projectexplorer/devicesupport/idevicefactory.h b/src/plugins/projectexplorer/devicesupport/idevicefactory.h index 1950155697d..c9af9c71231 100644 --- a/src/plugins/projectexplorer/devicesupport/idevicefactory.h +++ b/src/plugins/projectexplorer/devicesupport/idevicefactory.h @@ -43,7 +43,7 @@ class QWidget; QT_END_NAMESPACE namespace ProjectExplorer { -class IDeviceWizard; +class IDeviceWidget; /*! \class ProjectExplorer::IDeviceFactory @@ -65,9 +65,15 @@ public: virtual QString displayName() const = 0; /*! - A wizard that can create the types of device this factory supports. - */ - virtual IDeviceWizard *createWizard(QWidget *parent = 0) const = 0; + 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. + */ + virtual bool canCreate() const = 0; + + /*! + Create a new device. This may or may not open a wizard. + */ + virtual IDevice::Ptr create() const = 0; /*! Loads a device from a serialized state. The device must be of a matching type. diff --git a/src/plugins/projectexplorer/devicesupport/idevicewizard.h b/src/plugins/projectexplorer/devicesupport/idevicewizard.h deleted file mode 100644 index 5e109f0b479..00000000000 --- a/src/plugins/projectexplorer/devicesupport/idevicewizard.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** 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. -** -**************************************************************************/ -#ifndef IDEVICEWIZARD_H -#define IDEVICEWIZARD_H - -#include "idevice.h" -#include - -#include - -namespace ProjectExplorer { - -/*! - \class ProjectExplorer::IDeviceWizard - - \brief Provides an interface for wizards creating an IDevice subclass. - - A class implementing this interface is a wizard whose final result is - an \c IDevice object. The wizard will be started when the user chooses the - "Add..." action from the "Devices" options page. -*/ -class PROJECTEXPLORER_EXPORT IDeviceWizard : public QWizard -{ - Q_OBJECT - -public: - virtual IDevice::Ptr device() = 0; - -protected: - IDeviceWizard(QWidget *parent) : QWizard(parent) { } -}; - -} // namespace ProjectExplorer - -#endif // IDEVICEWIZARD_H diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 1727a93388d..08441706e7e 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -108,7 +108,6 @@ HEADERS += projectexplorer.h \ settingsaccessor.h \ environmentitemswidget.h \ devicesupport/idevice.h \ - devicesupport/idevicewizard.h \ devicesupport/idevicewidget.h \ devicesupport/idevicefactory.h \ devicesupport/devicemanager.h \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 1e5816e5afe..7e613018f72 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -286,7 +286,6 @@ QtcPlugin { "devicesupport/devicesettingswidget.cpp", "devicesupport/devicesettingswidget.h", "devicesupport/devicesettingswidget.ui", - "devicesupport/idevicewizard.h", "devicesupport/idevicewidget.h", "devicesupport/idevicefactory.h" ] diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp index 4bba38569a3..a33a237fb01 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp @@ -51,9 +51,17 @@ QString GenericLinuxDeviceConfigurationFactory::displayName() const return tr("Generic Linux Device"); } -IDeviceWizard *GenericLinuxDeviceConfigurationFactory::createWizard(QWidget *parent) const +bool GenericLinuxDeviceConfigurationFactory::canCreate() const { - return new GenericLinuxDeviceConfigurationWizard(parent); + return true; +} + +IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create() const +{ + GenericLinuxDeviceConfigurationWizard *wizard = new GenericLinuxDeviceConfigurationWizard; + if (wizard->exec() != QDialog::Accepted) + return IDevice::Ptr(); + return wizard->device(); } IDevice::Ptr GenericLinuxDeviceConfigurationFactory::loadDevice(const QVariantMap &map) const diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h index c5c57c9cdff..884461c5a54 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h @@ -47,7 +47,8 @@ public: GenericLinuxDeviceConfigurationFactory(QObject *parent = 0); QString displayName() const; - ProjectExplorer::IDeviceWizard *createWizard(QWidget *parent) const; + bool canCreate() const; + ProjectExplorer::IDevice::Ptr create() const; ProjectExplorer::IDevice::Ptr loadDevice(const QVariantMap &map) const; bool supportsDeviceType(const QString &deviceType) const; }; diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp index 0a5e290bc03..4590ee29a3f 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp @@ -60,7 +60,7 @@ public: } // namespace Internal GenericLinuxDeviceConfigurationWizard::GenericLinuxDeviceConfigurationWizard(QWidget *parent) - : IDeviceWizard(parent), + : QWizard(parent), d(new Internal::GenericLinuxDeviceConfigurationWizardPrivate(this)) { setWindowTitle(tr("New Generic Linux Device Configuration Setup")); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.h index a599f5edb27..7a9772c8a80 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.h @@ -33,15 +33,16 @@ #include "remotelinux_export.h" -#include +#include + +#include namespace RemoteLinux { namespace Internal { class GenericLinuxDeviceConfigurationWizardPrivate; } // namespace Internal -class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationWizard - : public ProjectExplorer::IDeviceWizard +class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationWizard : public QWizard { Q_OBJECT