forked from qt-creator/qt-creator
Device Support: Merge id and fingerprint.
It seems pointless to have two identity-related concepts in parallel. The new approach is as follows: The identifier is a Core::Id. If the client code supplies a fingerprint string (as needed for auto-detected devices), the id is derived from it, otherwise it gets created from a newly generated UUID. Change-Id: I680afa6cd2fdd43ec1c461616ba982b3ff55c73a Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include "idevicefactory.h"
|
#include "idevicefactory.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/persistentsettings.h>
|
#include <utils/persistentsettings.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -55,12 +56,11 @@ namespace Internal {
|
|||||||
static IDevice::Ptr findAutoDetectedDevice(const QList<IDevice::Ptr> &deviceList,
|
static IDevice::Ptr findAutoDetectedDevice(const QList<IDevice::Ptr> &deviceList,
|
||||||
const QString &type, const QString &fingerprint)
|
const QString &type, const QString &fingerprint)
|
||||||
{
|
{
|
||||||
|
const Core::Id id(fingerprint);
|
||||||
foreach (const IDevice::Ptr &device, deviceList) {
|
foreach (const IDevice::Ptr &device, deviceList) {
|
||||||
if (device->isAutoDetected() && device->type() == type
|
if (device->isAutoDetected() && device->type() == type && device->internalId() == id)
|
||||||
&& device->fingerprint() == fingerprint) {
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return IDevice::Ptr();
|
return IDevice::Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
static DeviceManager *clonedInstance;
|
static DeviceManager *clonedInstance;
|
||||||
QList<IDevice::Ptr> devices;
|
QList<IDevice::Ptr> devices;
|
||||||
QList<IDevice::Ptr> inactiveAutoDetectedDevices;
|
QList<IDevice::Ptr> inactiveAutoDetectedDevices;
|
||||||
QHash<QString, IDevice::Id> defaultDevices;
|
QHash<QString, Core::Id> defaultDevices;
|
||||||
};
|
};
|
||||||
DeviceManager *DeviceManagerPrivate::clonedInstance = 0;
|
DeviceManager *DeviceManagerPrivate::clonedInstance = 0;
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ void DeviceManager::loadPre2_6()
|
|||||||
const QVariantHash defaultDevsHash = settings->value(QLatin1String("DefaultConfigs")).toHash();
|
const QVariantHash defaultDevsHash = settings->value(QLatin1String("DefaultConfigs")).toHash();
|
||||||
for (QVariantHash::ConstIterator it = defaultDevsHash.constBegin();
|
for (QVariantHash::ConstIterator it = defaultDevsHash.constBegin();
|
||||||
it != defaultDevsHash.constEnd(); ++it) {
|
it != defaultDevsHash.constEnd(); ++it) {
|
||||||
d->defaultDevices.insert(it.key(), it.value().toULongLong());
|
d->defaultDevices.insert(it.key(), Core::Id(it.value().toString()));
|
||||||
}
|
}
|
||||||
int count = settings->beginReadArray(QLatin1String("ConfigList"));
|
int count = settings->beginReadArray(QLatin1String("ConfigList"));
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
@@ -166,8 +166,6 @@ void DeviceManager::loadPre2_6()
|
|||||||
continue;
|
continue;
|
||||||
IDevice::Ptr device = factory->loadDevice(map);
|
IDevice::Ptr device = factory->loadDevice(map);
|
||||||
QTC_ASSERT(device, continue);
|
QTC_ASSERT(device, continue);
|
||||||
if (device->internalId() == IDevice::invalidId())
|
|
||||||
device->setInternalId(unusedId());
|
|
||||||
d->devices << device;
|
d->devices << device;
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
@@ -179,7 +177,7 @@ void DeviceManager::fromMap(const QVariantMap &map)
|
|||||||
const QVariantMap defaultDevsMap = map.value(QLatin1String(DefaultDevicesKey)).toMap();
|
const QVariantMap defaultDevsMap = map.value(QLatin1String(DefaultDevicesKey)).toMap();
|
||||||
for (QVariantMap::ConstIterator it = defaultDevsMap.constBegin();
|
for (QVariantMap::ConstIterator it = defaultDevsMap.constBegin();
|
||||||
it != defaultDevsMap.constEnd(); ++it) {
|
it != defaultDevsMap.constEnd(); ++it) {
|
||||||
d->defaultDevices.insert(it.key(), it.value().toULongLong());
|
d->defaultDevices.insert(it.key(), Core::Id(it.value().toString()));
|
||||||
}
|
}
|
||||||
const QVariantList deviceList = map.value(QLatin1String(DeviceListKey)).toList();
|
const QVariantList deviceList = map.value(QLatin1String(DeviceListKey)).toList();
|
||||||
foreach (const QVariant &v, deviceList) {
|
foreach (const QVariant &v, deviceList) {
|
||||||
@@ -189,8 +187,6 @@ void DeviceManager::fromMap(const QVariantMap &map)
|
|||||||
continue;
|
continue;
|
||||||
IDevice::Ptr device = factory->loadDevice(map);
|
IDevice::Ptr device = factory->loadDevice(map);
|
||||||
QTC_ASSERT(device, continue);
|
QTC_ASSERT(device, continue);
|
||||||
if (device->internalId() == IDevice::invalidId())
|
|
||||||
device->setInternalId(unusedId());
|
|
||||||
if (device->isAutoDetected())
|
if (device->isAutoDetected())
|
||||||
d->inactiveAutoDetectedDevices << device;
|
d->inactiveAutoDetectedDevices << device;
|
||||||
else
|
else
|
||||||
@@ -202,10 +198,10 @@ QVariantMap DeviceManager::toMap() const
|
|||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
QVariantMap defaultDeviceMap;
|
QVariantMap defaultDeviceMap;
|
||||||
typedef QHash<QString, IDevice::Id> TypeIdHash;
|
typedef QHash<QString, Core::Id> TypeIdHash;
|
||||||
for (TypeIdHash::ConstIterator it = d->defaultDevices.constBegin();
|
for (TypeIdHash::ConstIterator it = d->defaultDevices.constBegin();
|
||||||
it != d->defaultDevices.constEnd(); ++it) {
|
it != d->defaultDevices.constEnd(); ++it) {
|
||||||
defaultDeviceMap.insert(it.key(), it.value());
|
defaultDeviceMap.insert(it.key(), it.value().toString());
|
||||||
}
|
}
|
||||||
map.insert(QLatin1String(DefaultDevicesKey), defaultDeviceMap);
|
map.insert(QLatin1String(DefaultDevicesKey), defaultDeviceMap);
|
||||||
QVariantList deviceList;
|
QVariantList deviceList;
|
||||||
@@ -241,8 +237,6 @@ void DeviceManager::addDevice(const IDevice::Ptr &device)
|
|||||||
while (hasDevice(name));
|
while (hasDevice(name));
|
||||||
}
|
}
|
||||||
device->setDisplayName(name);
|
device->setDisplayName(name);
|
||||||
if (pos < 0)
|
|
||||||
device->setInternalId(unusedId());
|
|
||||||
if (!defaultDevice(device->type()))
|
if (!defaultDevice(device->type()))
|
||||||
d->defaultDevices.insert(device->type(), device->internalId());
|
d->defaultDevices.insert(device->type(), device->internalId());
|
||||||
d->devices << device;
|
d->devices << device;
|
||||||
@@ -251,8 +245,7 @@ void DeviceManager::addDevice(const IDevice::Ptr &device)
|
|||||||
if (this == instance()) {
|
if (this == instance()) {
|
||||||
QList<IDevice::Ptr>::Iterator it = d->inactiveAutoDetectedDevices.begin();
|
QList<IDevice::Ptr>::Iterator it = d->inactiveAutoDetectedDevices.begin();
|
||||||
while (it != d->inactiveAutoDetectedDevices.end()) {
|
while (it != d->inactiveAutoDetectedDevices.end()) {
|
||||||
if (it->data()->type() == device->type()
|
if (it->data()->internalId() == device->internalId()) {
|
||||||
&& it->data()->fingerprint() == device->fingerprint()) {
|
|
||||||
d->inactiveAutoDetectedDevices.erase(it);
|
d->inactiveAutoDetectedDevices.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -370,7 +363,7 @@ bool DeviceManager::hasDevice(const QString &name) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::ConstPtr DeviceManager::find(IDevice::Id id) const
|
IDevice::ConstPtr DeviceManager::find(const Core::Id &id) const
|
||||||
{
|
{
|
||||||
const int index = indexForInternalId(id);
|
const int index = indexForInternalId(id);
|
||||||
return index == -1 ? IDevice::ConstPtr() : deviceAt(index);
|
return index == -1 ? IDevice::ConstPtr() : deviceAt(index);
|
||||||
@@ -384,13 +377,13 @@ IDevice::ConstPtr DeviceManager::findInactiveAutoDetectedDevice(const QString &t
|
|||||||
|
|
||||||
IDevice::ConstPtr DeviceManager::defaultDevice(const QString &deviceType) const
|
IDevice::ConstPtr DeviceManager::defaultDevice(const QString &deviceType) const
|
||||||
{
|
{
|
||||||
const IDevice::Id id = d->defaultDevices.value(deviceType, IDevice::invalidId());
|
const Core::Id id = d->defaultDevices.value(deviceType, IDevice::invalidId());
|
||||||
if (id == IDevice::invalidId())
|
if (id == IDevice::invalidId())
|
||||||
return IDevice::ConstPtr();
|
return IDevice::ConstPtr();
|
||||||
return find(id);
|
return find(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeviceManager::indexForInternalId(IDevice::Id internalId) const
|
int DeviceManager::indexForInternalId(const Core::Id &internalId) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d->devices.count(); ++i) {
|
for (int i = 0; i < d->devices.count(); ++i) {
|
||||||
if (deviceAt(i)->internalId() == internalId)
|
if (deviceAt(i)->internalId() == internalId)
|
||||||
@@ -399,7 +392,7 @@ int DeviceManager::indexForInternalId(IDevice::Id internalId) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::Id DeviceManager::internalId(const IDevice::ConstPtr &device) const
|
Core::Id DeviceManager::internalId(const IDevice::ConstPtr &device) const
|
||||||
{
|
{
|
||||||
return device ? device->internalId() : IDevice::invalidId();
|
return device ? device->internalId() : IDevice::invalidId();
|
||||||
}
|
}
|
||||||
@@ -417,16 +410,6 @@ void DeviceManager::ensureOneDefaultDevicePerType()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::Id DeviceManager::unusedId() const
|
|
||||||
{
|
|
||||||
for (IDevice::Id id = 0; id <= std::numeric_limits<IDevice::Id>::max(); ++id) {
|
|
||||||
if (id != IDevice::invalidId() && !find(id))
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
QTC_CHECK(false);
|
|
||||||
return IDevice::invalidId();
|
|
||||||
}
|
|
||||||
|
|
||||||
IDevice::Ptr DeviceManager::fromRawPointer(IDevice *device) const
|
IDevice::Ptr DeviceManager::fromRawPointer(IDevice *device) const
|
||||||
{
|
{
|
||||||
foreach (const IDevice::Ptr &devPtr, d->devices) {
|
foreach (const IDevice::Ptr &devPtr, d->devices) {
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ public:
|
|||||||
|
|
||||||
int deviceCount() const;
|
int deviceCount() const;
|
||||||
IDevice::ConstPtr deviceAt(int index) const;
|
IDevice::ConstPtr deviceAt(int index) const;
|
||||||
IDevice::ConstPtr find(IDevice::Id id) const;
|
IDevice::ConstPtr find(const Core::Id &id) const;
|
||||||
IDevice::ConstPtr findInactiveAutoDetectedDevice(const QString &type,
|
IDevice::ConstPtr findInactiveAutoDetectedDevice(const QString &type,
|
||||||
const QString &fingerprint);
|
const QString &fingerprint);
|
||||||
IDevice::ConstPtr defaultDevice(const QString &deviceType) const;
|
IDevice::ConstPtr defaultDevice(const QString &deviceType) const;
|
||||||
bool hasDevice(const QString &name) const;
|
bool hasDevice(const QString &name) const;
|
||||||
IDevice::Id internalId(const IDevice::ConstPtr &device) const;
|
Core::Id internalId(const IDevice::ConstPtr &device) const;
|
||||||
|
|
||||||
int indexOf(const IDevice::ConstPtr &device) const;
|
int indexOf(const IDevice::ConstPtr &device) const;
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
static const IDeviceFactory *factoryForDeviceType(const QString &type);
|
static const IDeviceFactory *factoryForDeviceType(const QString &type);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceUpdated(ProjectExplorer::IDevice::Id id);
|
void deviceUpdated(const Core::Id &id);
|
||||||
|
|
||||||
void deviceAdded(const QSharedPointer<const IDevice> &device);
|
void deviceAdded(const QSharedPointer<const IDevice> &device);
|
||||||
void deviceRemoved(int index);
|
void deviceRemoved(int index);
|
||||||
@@ -93,8 +93,7 @@ private:
|
|||||||
void fromMap(const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
QVariantMap toMap() const;
|
QVariantMap toMap() const;
|
||||||
void ensureOneDefaultDevicePerType();
|
void ensureOneDefaultDevicePerType();
|
||||||
IDevice::Id unusedId() const;
|
int indexForInternalId(const Core::Id &internalId) const;
|
||||||
int indexForInternalId(IDevice::Id internalId) const;
|
|
||||||
|
|
||||||
// For SettingsWidget.
|
// For SettingsWidget.
|
||||||
IDevice::Ptr mutableDeviceAt(int index) const;
|
IDevice::Ptr mutableDeviceAt(int index) const;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "idevicewidget.h"
|
#include "idevicewidget.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/portlist.h>
|
#include <utils/portlist.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -189,7 +190,7 @@ void DeviceSettingsWidget::displayCurrent()
|
|||||||
m_deviceManager->defaultDevice(current->type()) != current);
|
m_deviceManager->defaultDevice(current->type()) != current);
|
||||||
m_ui->osTypeValueLabel->setText(current->displayType());
|
m_ui->osTypeValueLabel->setText(current->displayType());
|
||||||
m_ui->autoDetectionValueLabel->setText(current->isAutoDetected()
|
m_ui->autoDetectionValueLabel->setText(current->isAutoDetected()
|
||||||
? tr("Yes (fingerprint is '%1')").arg(current->fingerprint()) : tr("No"));
|
? tr("Yes (fingerprint is '%1')").arg(current->internalId().toString()) : tr("No"));
|
||||||
m_nameValidator->setDisplayName(current->displayName());
|
m_nameValidator->setDisplayName(current->displayName());
|
||||||
m_ui->removeConfigButton->setEnabled(!current->isAutoDetected());
|
m_ui->removeConfigButton->setEnabled(!current->isAutoDetected());
|
||||||
fillInValues();
|
fillInValues();
|
||||||
|
|||||||
@@ -33,9 +33,11 @@
|
|||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class ProjectExplorer::IDevice
|
* \class ProjectExplorer::IDevice
|
||||||
@@ -74,21 +76,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \fn ProjectExplorer::IDevice::Id ProjectExplorer::IDevice::internalId() const
|
* \fn Core::Id ProjectExplorer::IDevice::internalId() const
|
||||||
* \brief Identify the device internally.
|
* \brief Identify the device internally.
|
||||||
*/
|
* If a fingerprint is given when constructing the device, the id will be derived from it, and
|
||||||
|
* the fingerprint can later be retrieved from the id.
|
||||||
/*!
|
|
||||||
* \fn QString ProjectExplorer::IDevice::fingerprint() const
|
|
||||||
* \brief Uniquely identifies an auto-detected device.
|
|
||||||
* The fingerprint can later be used to retrieve changes the user has done to the settings
|
|
||||||
* of an auto-detected device so they are not lost when the device goes away, e.g. because
|
|
||||||
* it has been disconnected.
|
|
||||||
* \sa ProjectExplorer::DeviceManager::findInactiveAutoDetectedDevice()
|
* \sa ProjectExplorer::DeviceManager::findInactiveAutoDetectedDevice()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \fn ProjectExplorer::IDevice::Id ProjectExplorer::IDevice::invalidId()
|
* \fn Core::Id ProjectExplorer::IDevice::invalidId()
|
||||||
* \brief A value that no device can ever have as its internal id.
|
* \brief A value that no device can ever have as its internal id.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -141,25 +137,26 @@
|
|||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static Core::Id newId()
|
||||||
|
{
|
||||||
|
return Core::Id(QUuid::createUuid().toString());
|
||||||
|
}
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
const char DisplayNameKey[] = "Name";
|
const char DisplayNameKey[] = "Name";
|
||||||
const char TypeKey[] = "OsType";
|
const char TypeKey[] = "OsType";
|
||||||
const char InternalIdKey[] = "InternalId";
|
const char InternalIdKey[] = "InternalId";
|
||||||
const char OriginKey[] = "Origin";
|
const char OriginKey[] = "Origin";
|
||||||
const char FingerprintKey[] = "FingerPrint";
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class IDevicePrivate
|
class IDevicePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IDevicePrivate() : internalId(IDevice::invalidId()) { }
|
|
||||||
|
|
||||||
QString displayName;
|
QString displayName;
|
||||||
QString type;
|
QString type;
|
||||||
IDevice::Origin origin;
|
IDevice::Origin origin;
|
||||||
IDevice::Id internalId;
|
Core::Id internalId;
|
||||||
QString fingerprint;
|
|
||||||
};
|
};
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
@@ -172,8 +169,8 @@ IDevice::IDevice(const QString &type, Origin origin, const QString &fingerprint)
|
|||||||
{
|
{
|
||||||
d->type = type;
|
d->type = type;
|
||||||
d->origin = origin;
|
d->origin = origin;
|
||||||
d->fingerprint = fingerprint;
|
QTC_CHECK(origin == ManuallyAdded || !fingerprint.isEmpty());
|
||||||
QTC_CHECK(d->origin == ManuallyAdded || !d->fingerprint.isEmpty());
|
d->internalId = fingerprint.isEmpty() ? newId() : Core::Id(fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::IDevice(const IDevice &other) : d(new Internal::IDevicePrivate)
|
IDevice::IDevice(const IDevice &other) : d(new Internal::IDevicePrivate)
|
||||||
@@ -208,24 +205,14 @@ bool IDevice::isAutoDetected() const
|
|||||||
return d->origin == AutoDetected;
|
return d->origin == AutoDetected;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IDevice::fingerprint() const
|
Core::Id IDevice::internalId() const
|
||||||
{
|
|
||||||
return d->fingerprint;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDevice::Id IDevice::internalId() const
|
|
||||||
{
|
{
|
||||||
return d->internalId;
|
return d->internalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDevice::setInternalId(IDevice::Id id)
|
Core::Id IDevice::invalidId()
|
||||||
{
|
{
|
||||||
d->internalId = id;
|
return Core::Id();
|
||||||
}
|
|
||||||
|
|
||||||
IDevice::Id IDevice::invalidId()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IDevice::typeFromMap(const QVariantMap &map)
|
QString IDevice::typeFromMap(const QVariantMap &map)
|
||||||
@@ -237,10 +224,8 @@ void IDevice::fromMap(const QVariantMap &map)
|
|||||||
{
|
{
|
||||||
d->type = typeFromMap(map);
|
d->type = typeFromMap(map);
|
||||||
d->displayName = map.value(QLatin1String(DisplayNameKey)).toString();
|
d->displayName = map.value(QLatin1String(DisplayNameKey)).toString();
|
||||||
d->internalId = map.value(QLatin1String(InternalIdKey), invalidId()).toULongLong();
|
d->internalId = Core::Id(map.value(QLatin1String(InternalIdKey), newId().toString()).toString());
|
||||||
d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt());
|
d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt());
|
||||||
d->fingerprint = map.value(QLatin1String(FingerprintKey)).toString();
|
|
||||||
QTC_CHECK(d->origin == ManuallyAdded || !d->fingerprint.isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap IDevice::toMap() const
|
QVariantMap IDevice::toMap() const
|
||||||
@@ -248,9 +233,8 @@ QVariantMap IDevice::toMap() const
|
|||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(QLatin1String(DisplayNameKey), d->displayName);
|
map.insert(QLatin1String(DisplayNameKey), d->displayName);
|
||||||
map.insert(QLatin1String(TypeKey), d->type);
|
map.insert(QLatin1String(TypeKey), d->type);
|
||||||
map.insert(QLatin1String(InternalIdKey), d->internalId);
|
map.insert(QLatin1String(InternalIdKey), d->internalId.toString());
|
||||||
map.insert(QLatin1String(OriginKey), d->origin);
|
map.insert(QLatin1String(OriginKey), d->origin);
|
||||||
map.insert(QLatin1String(FingerprintKey), d->fingerprint);
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class QDialog;
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core { class Id; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal { class IDevicePrivate; }
|
namespace Internal { class IDevicePrivate; }
|
||||||
class IDeviceWidget;
|
class IDeviceWidget;
|
||||||
@@ -50,13 +52,10 @@ class IDeviceWidget;
|
|||||||
// See cpp file for documentation.
|
// See cpp file for documentation.
|
||||||
class PROJECTEXPLORER_EXPORT IDevice
|
class PROJECTEXPLORER_EXPORT IDevice
|
||||||
{
|
{
|
||||||
friend class DeviceManager;
|
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<IDevice> Ptr;
|
typedef QSharedPointer<IDevice> Ptr;
|
||||||
typedef QSharedPointer<const IDevice> ConstPtr;
|
typedef QSharedPointer<const IDevice> ConstPtr;
|
||||||
|
|
||||||
typedef quint64 Id;
|
|
||||||
|
|
||||||
enum Origin { ManuallyAdded, AutoDetected };
|
enum Origin { ManuallyAdded, AutoDetected };
|
||||||
|
|
||||||
virtual ~IDevice();
|
virtual ~IDevice();
|
||||||
@@ -66,8 +65,7 @@ public:
|
|||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
bool isAutoDetected() const;
|
bool isAutoDetected() const;
|
||||||
QString fingerprint() const;
|
Core::Id internalId() const;
|
||||||
Id internalId() const;
|
|
||||||
|
|
||||||
virtual QString displayType() const = 0;
|
virtual QString displayType() const = 0;
|
||||||
virtual IDeviceWidget *createWidget() = 0;
|
virtual IDeviceWidget *createWidget() = 0;
|
||||||
@@ -76,9 +74,10 @@ public:
|
|||||||
virtual QDialog *createAction(const QString &actionId, QWidget *parent = 0) const = 0;
|
virtual QDialog *createAction(const QString &actionId, QWidget *parent = 0) const = 0;
|
||||||
|
|
||||||
virtual void fromMap(const QVariantMap &map);
|
virtual void fromMap(const QVariantMap &map);
|
||||||
|
virtual QVariantMap toMap() const;
|
||||||
virtual Ptr clone() const = 0;
|
virtual Ptr clone() const = 0;
|
||||||
|
|
||||||
static Id invalidId();
|
static Core::Id invalidId();
|
||||||
|
|
||||||
static QString typeFromMap(const QVariantMap &map);
|
static QString typeFromMap(const QVariantMap &map);
|
||||||
|
|
||||||
@@ -90,11 +89,7 @@ protected:
|
|||||||
Ptr sharedFromThis();
|
Ptr sharedFromThis();
|
||||||
ConstPtr sharedFromThis() const;
|
ConstPtr sharedFromThis() const;
|
||||||
|
|
||||||
virtual QVariantMap toMap() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setInternalId(Id id);
|
|
||||||
|
|
||||||
IDevice &operator=(const IDevice &);
|
IDevice &operator=(const IDevice &);
|
||||||
|
|
||||||
Internal::IDevicePrivate *d;
|
Internal::IDevicePrivate *d;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "remotelinuxdeployconfigurationwidget.h"
|
#include "remotelinuxdeployconfigurationwidget.h"
|
||||||
#include "typespecificdeviceconfigurationlistmodel.h"
|
#include "typespecificdeviceconfigurationlistmodel.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
#include <qt4projectmanager/qt4target.h>
|
#include <qt4projectmanager/qt4target.h>
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ void RemoteLinuxDeployConfiguration::handleDeviceConfigurationListUpdated()
|
|||||||
setDeviceConfig(DeviceManager::instance()->internalId(d->deviceConfiguration));
|
setDeviceConfig(DeviceManager::instance()->internalId(d->deviceConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteLinuxDeployConfiguration::setDeviceConfig(LinuxDeviceConfiguration::Id internalId)
|
void RemoteLinuxDeployConfiguration::setDeviceConfig(const Core::Id &internalId)
|
||||||
{
|
{
|
||||||
d->deviceConfiguration = target()->deviceConfigModel()->find(internalId);
|
d->deviceConfiguration = target()->deviceConfigModel()->find(internalId);
|
||||||
emit deviceConfigurationListChanged();
|
emit deviceConfigurationListChanged();
|
||||||
@@ -102,7 +103,8 @@ bool RemoteLinuxDeployConfiguration::fromMap(const QVariantMap &map)
|
|||||||
{
|
{
|
||||||
if (!DeployConfiguration::fromMap(map))
|
if (!DeployConfiguration::fromMap(map))
|
||||||
return false;
|
return false;
|
||||||
setDeviceConfig(map.value(QLatin1String(DeviceIdKey), IDevice::invalidId()).toULongLong());
|
setDeviceConfig(Core::Id(map.value(QLatin1String(DeviceIdKey),
|
||||||
|
IDevice::invalidId().toString()).toString()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ QVariantMap RemoteLinuxDeployConfiguration::toMap() const
|
|||||||
{
|
{
|
||||||
QVariantMap map = DeployConfiguration::toMap();
|
QVariantMap map = DeployConfiguration::toMap();
|
||||||
map.insert(QLatin1String(DeviceIdKey),
|
map.insert(QLatin1String(DeviceIdKey),
|
||||||
DeviceManager::instance()->internalId(d->deviceConfiguration));
|
DeviceManager::instance()->internalId(d->deviceConfiguration).toString());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void setDeviceConfig(LinuxDeviceConfiguration::Id internalId);
|
void setDeviceConfig(const Core::Id &internalId);
|
||||||
Q_SLOT void handleDeviceConfigurationListUpdated();
|
Q_SLOT void handleDeviceConfigurationListUpdated();
|
||||||
|
|
||||||
Internal::RemoteLinuxDeployConfigurationPrivate * const d;
|
Internal::RemoteLinuxDeployConfigurationPrivate * const d;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -182,7 +183,7 @@ void RemoteLinuxDeployConfigurationWidget::handleDeviceConfigurationListChanged(
|
|||||||
{
|
{
|
||||||
const LinuxDeviceConfiguration::ConstPtr &devConf
|
const LinuxDeviceConfiguration::ConstPtr &devConf
|
||||||
= d->deployConfiguration->deviceConfiguration();
|
= d->deployConfiguration->deviceConfiguration();
|
||||||
const IDevice::Id internalId = DeviceManager::instance()->internalId(devConf);
|
const Core::Id &internalId = DeviceManager::instance()->internalId(devConf);
|
||||||
const int newIndex
|
const int newIndex
|
||||||
= d->deployConfiguration->target()->deviceConfigModel()->indexForInternalId(internalId);
|
= d->deployConfiguration->target()->deviceConfigModel()->indexForInternalId(internalId);
|
||||||
d->ui.deviceConfigsComboBox->setCurrentIndex(newIndex);
|
d->ui.deviceConfigsComboBox->setCurrentIndex(newIndex);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::def
|
|||||||
return LinuxDeviceConfiguration::ConstPtr();
|
return LinuxDeviceConfiguration::ConstPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::find(LinuxDeviceConfiguration::Id id) const
|
LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::find(const Core::Id &id) const
|
||||||
{
|
{
|
||||||
const IDevice::ConstPtr &devConf = DeviceManager::instance()->find(id);
|
const IDevice::ConstPtr &devConf = DeviceManager::instance()->find(id);
|
||||||
if (devConf && target()->supportsDevice(devConf))
|
if (devConf && target()->supportsDevice(devConf))
|
||||||
@@ -117,7 +117,7 @@ LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::fin
|
|||||||
return defaultDeviceConfig();
|
return defaultDeviceConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TypeSpecificDeviceConfigurationListModel::indexForInternalId(LinuxDeviceConfiguration::Id id) const
|
int TypeSpecificDeviceConfigurationListModel::indexForInternalId(const Core::Id &id) const
|
||||||
{
|
{
|
||||||
const int count = rowCount();
|
const int count = rowCount();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
|
|
||||||
QSharedPointer<const LinuxDeviceConfiguration> deviceAt(int idx) const;
|
QSharedPointer<const LinuxDeviceConfiguration> deviceAt(int idx) const;
|
||||||
QSharedPointer<const LinuxDeviceConfiguration> defaultDeviceConfig() const;
|
QSharedPointer<const LinuxDeviceConfiguration> defaultDeviceConfig() const;
|
||||||
QSharedPointer<const LinuxDeviceConfiguration> find(LinuxDeviceConfiguration::Id id) const;
|
QSharedPointer<const LinuxDeviceConfiguration> find(const Core::Id &id) const;
|
||||||
int indexForInternalId(LinuxDeviceConfiguration::Id id) const;
|
int indexForInternalId(const Core::Id &id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractEmbeddedLinuxTarget * target() const;
|
AbstractEmbeddedLinuxTarget * target() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user