summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2012-03-26 14:01:58 +0200
committerTobias Hunger <tobias.hunger@nokia.com>2012-04-12 15:35:23 +0200
commit1f4caf53994fa57c8756d809a0b8468139a7b5b0 (patch)
treea5fb4a429af24cf5677ef028e457c03d5032ec16 /src/plugins/projectexplorer
parent866cc421542e4ea746526e7a04f3795784db8b43 (diff)
downloadqt-creator-1f4caf53994fa57c8756d809a0b8468139a7b5b0.tar.gz
Device: Add create method to IDeviceFactory
Add a create method to the IDeviceFactory and make it replace the createWizard method. The create method may or may not pop up a wizard. Remove IDeviceWizard as suggested by Christian. This patch also adds a canCreate() method to check whether a factory should be asked to create something or not. Change-Id: Iaf16aa407530022e8f3804093b58dc3f120f7599 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp2
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicemanager.h2
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp24
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.cpp4
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.h3
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevicefactory.h14
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevicewizard.h64
-rw-r--r--src/plugins/projectexplorer/projectexplorer.pro1
-rw-r--r--src/plugins/projectexplorer/projectexplorer.qbs1
9 files changed, 33 insertions, 82 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp b/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp
index 7ce9e57c7a..c8093c70ee 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<IDeviceFactory *> &factories
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
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 accd04b520..7a7b5a9d8c 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.h
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.h
@@ -39,6 +39,7 @@
#include <QObject>
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 e2f33491cb..a69408f0d9 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 <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
@@ -137,6 +136,17 @@ void DeviceSettingsWidget::initGui()
m_ui->configurationComboBox->setModel(model);
m_ui->nameLineEdit->setValidator(m_nameValidator);
+ bool hasDeviceFactories = false;
+ const QList<IDeviceFactory *> &factories
+ = ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
+ 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<IDeviceFactory *> &factories
- = ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
-
- if (factories.isEmpty()) // Can't happen, because this plugin provides the generic one.
- return;
-
DeviceFactorySelectionDialog d;
if (d.exec() != QDialog::Accepted)
return;
- const QScopedPointer<IDeviceWizard> 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 9c44012d6b..7f0ae1a56b 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 83b934fb20..75a0d942c6 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 1950155697..c9af9c7123 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 5e109f0b47..0000000000
--- 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 <projectexplorer/projectexplorer_export.h>
-
-#include <QWizard>
-
-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 1727a93388..08441706e7 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 1e5816e5af..7e613018f7 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"
]