Commit aefb7d06 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Device support: Use Core::Id for device actions.



Change-Id: Ic313e73e9fa83596e18bf2884bc310a1a7d8a744
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent c41a332f
......@@ -83,37 +83,37 @@ QString MaddeDevice::displayType() const
return maddeDisplayType(type());
}
QStringList MaddeDevice::actionIds() const
QList<Core::Id> MaddeDevice::actionIds() const
{
return QStringList() << QLatin1String(MaddeDeviceTestActionId)
<< QLatin1String(Constants::GenericDeployKeyToDeviceActionId)
<< QLatin1String(MaddeRemoteProcessesActionId);
return QList<Core::Id>() << Core::Id(MaddeDeviceTestActionId)
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId)
<< Core::Id(MaddeRemoteProcessesActionId);
}
QString MaddeDevice::displayNameForActionId(const QString &actionId) const
QString MaddeDevice::displayNameForActionId(Core::Id actionId) const
{
QTC_ASSERT(actionIds().contains(actionId), return QString());
if (actionId == QLatin1String(MaddeDeviceTestActionId))
if (actionId == Core::Id(MaddeDeviceTestActionId))
return tr("Test");
if (actionId == QLatin1String(MaddeRemoteProcessesActionId))
if (actionId == Core::Id(MaddeRemoteProcessesActionId))
return tr("Remote Processes...");
if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId))
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
return tr("Deploy Public Key...");
return QString(); // Can't happen.
}
QDialog *MaddeDevice::createAction(const QString &actionId, QWidget *parent) const
QDialog *MaddeDevice::createAction(Core::Id actionId, QWidget *parent) const
{
QTC_ASSERT(actionIds().contains(actionId), return 0);
const LinuxDeviceConfiguration::ConstPtr device
= sharedFromThis().staticCast<const LinuxDeviceConfiguration>();
if (actionId == QLatin1String(MaddeDeviceTestActionId))
if (actionId == Core::Id(MaddeDeviceTestActionId))
return new LinuxDeviceTestDialog(device, new MaddeDeviceTester, parent);
if (actionId == QLatin1String(MaddeRemoteProcessesActionId))
if (actionId == Core::Id(MaddeRemoteProcessesActionId))
return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(device), parent);
if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId))
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
return PublicKeyDeploymentDialog::createDialog(device, parent);
return 0; // Can't happen.
}
......
......@@ -51,9 +51,9 @@ public:
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
QString displayType() const;
QStringList actionIds() const;
QString displayNameForActionId(const QString &actionId) const;
QDialog *createAction(const QString &actionId, QWidget *parent) const;
QList<Core::Id> actionIds() const;
QString displayNameForActionId(Core::Id actionId) const;
QDialog *createAction(Core::Id actionId, QWidget *parent) const;
ProjectExplorer::IDevice::Ptr clone() const;
static QString maddeDisplayType(const QString &type);
......
......@@ -105,8 +105,8 @@ DeviceSettingsWidget::DeviceSettingsWidget(QWidget *parent)
m_configWidget(0)
{
initGui();
connect(m_additionalActionsMapper, SIGNAL(mapped(QString)),
SLOT(handleAdditionalActionRequest(QString)));
connect(m_additionalActionsMapper, SIGNAL(mapped(int)),
SLOT(handleAdditionalActionRequest(int)));
connect(m_deviceManager, SIGNAL(deviceUpdated(Core::Id)), SLOT(handleDeviceUpdated(Core::Id)));
}
......@@ -258,11 +258,11 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
} else {
m_ui->removeConfigButton->setEnabled(true);
const IDevice::ConstPtr device = m_deviceManager->deviceAt(index);
foreach (const QString &actionId, device->actionIds()) {
foreach (const Core::Id actionId, device->actionIds()) {
QPushButton * const button = new QPushButton(device->displayNameForActionId(actionId));
m_additionalActionButtons << button;
connect(button, SIGNAL(clicked()), m_additionalActionsMapper, SLOT(map()));
m_additionalActionsMapper->setMapping(button, actionId);
m_additionalActionsMapper->setMapping(button, actionId.uniqueIdentifier());
m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button);
}
if (!m_ui->osSpecificGroupBox->layout())
......@@ -281,11 +281,11 @@ void DeviceSettingsWidget::clearDetails()
m_ui->autoDetectionValueLabel->clear();
}
void DeviceSettingsWidget::handleAdditionalActionRequest(const QString &actionId)
void DeviceSettingsWidget::handleAdditionalActionRequest(int actionId)
{
const IDevice::ConstPtr &device = currentDevice();
QTC_ASSERT(device, return);
QDialog * const action = device->createAction(actionId, this);
QDialog * const action = device->createAction(Core::Id::fromUniqueIdentifier(actionId), this);
if (action)
action->exec();
delete action;
......
......@@ -70,7 +70,7 @@ private slots:
void removeDevice();
void deviceNameEditingFinished();
void setDefaultDevice();
void handleAdditionalActionRequest(const QString &actionId);
void handleAdditionalActionRequest(int actionId);
private:
void initGui();
......
......@@ -36,10 +36,8 @@
#include <coreplugin/id.h>
#include <coreplugin/id.h>
#include <QList>
#include <QSharedPointer>
#include <QStringList>
#include <QVariantMap>
QT_BEGIN_NAMESPACE
......@@ -83,9 +81,9 @@ public:
virtual QString displayType() const = 0;
virtual IDeviceWidget *createWidget() = 0;
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 QList<Core::Id> actionIds() const = 0;
virtual QString displayNameForActionId(Core::Id actionId) const = 0;
virtual QDialog *createAction(Core::Id actionId, QWidget *parent = 0) const = 0;
enum AvailabilityState { DeviceAvailable, DeviceUnavailable, DeviceAvailabilityUnknown };
AvailabilityState availability() const;
......
......@@ -196,18 +196,18 @@ ProjectExplorer::IDeviceWidget *SymbianIDevice::createWidget()
return new Internal::SymbianIDeviceConfigurationWidget(sharedFromThis());
}
QStringList SymbianIDevice::actionIds() const
QList<Core::Id> SymbianIDevice::actionIds() const
{
return QStringList();
return QList<Core::Id>();
}
QString SymbianIDevice::displayNameForActionId(const QString &actionId) const
QString SymbianIDevice::displayNameForActionId(Core::Id actionId) const
{
Q_UNUSED(actionId);
return QString();
}
QDialog *SymbianIDevice::createAction(const QString &actionId, QWidget *parent) const
QDialog *SymbianIDevice::createAction(Core::Id actionId, QWidget *parent) const
{
Q_UNUSED(actionId);
Q_UNUSED(parent);
......
......@@ -76,9 +76,9 @@ public:
QString displayType() const;
ProjectExplorer::IDeviceWidget* createWidget();
QStringList actionIds() const;
QString displayNameForActionId(const QString&actionId) const;
QDialog* createAction(const QString&, QWidget*parent) const;
QList<Core::Id> actionIds() const;
QString displayNameForActionId(Core::Id actionId) const;
QDialog* createAction(Core::Id actionId, QWidget*parent) const;
protected:
SymbianIDevice(const SymbianIDevice &other);
......
......@@ -100,37 +100,37 @@ ProjectExplorer::IDeviceWidget *LinuxDeviceConfiguration::createWidget()
.staticCast<LinuxDeviceConfiguration>());
}
QStringList LinuxDeviceConfiguration::actionIds() const
QList<Core::Id> LinuxDeviceConfiguration::actionIds() const
{
return QStringList() << QLatin1String(Constants::GenericTestDeviceActionId)
<< QLatin1String(Constants::GenericDeployKeyToDeviceActionId)
<< QLatin1String(Constants::GenericRemoteProcessesActionId);
return QList<Core::Id>() << Core::Id(Constants::GenericTestDeviceActionId)
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId)
<< Core::Id(Constants::GenericRemoteProcessesActionId);
}
QString LinuxDeviceConfiguration::displayNameForActionId(const QString &actionId) const
QString LinuxDeviceConfiguration::displayNameForActionId(Core::Id actionId) const
{
QTC_ASSERT(actionIds().contains(actionId), return QString());
if (actionId == QLatin1String(Constants::GenericTestDeviceActionId))
if (actionId == Core::Id(Constants::GenericTestDeviceActionId))
return tr("Test");
if (actionId == QLatin1String(Constants::GenericRemoteProcessesActionId))
if (actionId == Core::Id(Constants::GenericRemoteProcessesActionId))
return tr("Remote Processes...");
if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId))
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
return tr("Deploy Public Key...");
return QString(); // Can't happen.
}
QDialog *LinuxDeviceConfiguration::createAction(const QString &actionId, QWidget *parent) const
QDialog *LinuxDeviceConfiguration::createAction(Core::Id actionId, QWidget *parent) const
{
QTC_ASSERT(actionIds().contains(actionId), return 0);
const LinuxDeviceConfiguration::ConstPtr device
= sharedFromThis().staticCast<const LinuxDeviceConfiguration>();
if (actionId == QLatin1String(Constants::GenericTestDeviceActionId))
if (actionId == Core::Id(Constants::GenericTestDeviceActionId))
return new LinuxDeviceTestDialog(device, new GenericLinuxDeviceTester, parent);
if (actionId == QLatin1String(Constants::GenericRemoteProcessesActionId))
if (actionId == Core::Id(Constants::GenericRemoteProcessesActionId))
return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(device, parent));
if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId))
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
return PublicKeyDeploymentDialog::createDialog(device, parent);
return 0; // Can't happen.
}
......
......@@ -75,9 +75,9 @@ public:
QString displayType() const;
ProjectExplorer::IDeviceWidget *createWidget();
QStringList actionIds() const;
QString displayNameForActionId(const QString &actionId) const;
QDialog *createAction(const QString &actionId, QWidget *parent) const;
QList<Core::Id> actionIds() const;
QString displayNameForActionId(Core::Id actionId) const;
QDialog *createAction(Core::Id actionId, QWidget *parent) const;
void fromMap(const QVariantMap &map);
ProjectExplorer::IDevice::Ptr clone() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment