forked from qt-creator/qt-creator
IDevice: Make id creation (a bit) less magic
Change-Id: Icf5743a5b5a6305d18860cf6f87d70079c3effbc Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -54,9 +54,9 @@ MaddeDevice::Ptr MaddeDevice::create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaddeDevice::Ptr MaddeDevice::create(const QString &name, const QString &type,
|
MaddeDevice::Ptr MaddeDevice::create(const QString &name, const QString &type,
|
||||||
MachineType machineType, Origin origin, const QString &fingerprint)
|
MachineType machineType, Origin origin, const Core::Id &id)
|
||||||
{
|
{
|
||||||
return Ptr(new MaddeDevice(name, type, machineType, origin, fingerprint));
|
return Ptr(new MaddeDevice(name, type, machineType, origin, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaddeDevice::MaddeDevice()
|
MaddeDevice::MaddeDevice()
|
||||||
@@ -64,8 +64,8 @@ MaddeDevice::MaddeDevice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaddeDevice::MaddeDevice(const QString &name, const QString &type, MachineType machineType,
|
MaddeDevice::MaddeDevice(const QString &name, const QString &type, MachineType machineType,
|
||||||
Origin origin, const QString &fingerprint)
|
Origin origin, const Core::Id &id)
|
||||||
: LinuxDeviceConfiguration(name, type, machineType, origin, fingerprint)
|
: LinuxDeviceConfiguration(name, type, machineType, origin, id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
static Ptr create();
|
static Ptr create();
|
||||||
static Ptr create(const QString &name, const QString &type, MachineType machineType,
|
static Ptr create(const QString &name, const QString &type, MachineType machineType,
|
||||||
Origin origin = ManuallyAdded, const QString &fingerprint = QString());
|
Origin origin = ManuallyAdded, const Core::Id &id = Core::Id());
|
||||||
|
|
||||||
QString displayType() const;
|
QString displayType() const;
|
||||||
QStringList actionIds() const;
|
QStringList actionIds() const;
|
||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
MaddeDevice();
|
MaddeDevice();
|
||||||
MaddeDevice(const QString &name, const QString &type, MachineType machineType,
|
MaddeDevice(const QString &name, const QString &type, MachineType machineType,
|
||||||
Origin origin, const QString &fingerprint);
|
Origin origin, const Core::Id &id);
|
||||||
|
|
||||||
MaddeDevice(const MaddeDevice &other);
|
MaddeDevice(const MaddeDevice &other);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,9 +54,8 @@ namespace ProjectExplorer {
|
|||||||
namespace Internal {
|
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 Core::Id id)
|
||||||
{
|
{
|
||||||
const Core::Id id(fingerprint);
|
|
||||||
foreach (const IDevice::Ptr &device, deviceList) {
|
foreach (const IDevice::Ptr &device, deviceList) {
|
||||||
if (device->isAutoDetected() && device->type() == type && device->id() == id)
|
if (device->isAutoDetected() && device->type() == type && device->id() == id)
|
||||||
return device;
|
return device;
|
||||||
@@ -372,9 +371,9 @@ IDevice::ConstPtr DeviceManager::find(const Core::Id &id) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
IDevice::ConstPtr DeviceManager::findInactiveAutoDetectedDevice(const QString &type,
|
IDevice::ConstPtr DeviceManager::findInactiveAutoDetectedDevice(const QString &type,
|
||||||
const QString &fingerprint)
|
const Core::Id id)
|
||||||
{
|
{
|
||||||
return findAutoDetectedDevice(d->inactiveAutoDetectedDevices, type, fingerprint);
|
return findAutoDetectedDevice(d->inactiveAutoDetectedDevices, type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::ConstPtr DeviceManager::defaultDevice(const QString &deviceType) const
|
IDevice::ConstPtr DeviceManager::defaultDevice(const QString &deviceType) const
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ public:
|
|||||||
int deviceCount() const;
|
int deviceCount() const;
|
||||||
IDevice::ConstPtr deviceAt(int index) const;
|
IDevice::ConstPtr deviceAt(int index) const;
|
||||||
IDevice::ConstPtr find(const Core::Id &id) const;
|
IDevice::ConstPtr find(const Core::Id &id) const;
|
||||||
IDevice::ConstPtr findInactiveAutoDetectedDevice(const QString &type,
|
IDevice::ConstPtr findInactiveAutoDetectedDevice(const QString &type, const Core::Id id);
|
||||||
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;
|
||||||
Core::Id deviceId(const IDevice::ConstPtr &device) const;
|
Core::Id deviceId(const IDevice::ConstPtr &device) const;
|
||||||
|
|||||||
@@ -78,10 +78,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \fn Core::Id ProjectExplorer::IDevice::internalId() const
|
* \fn Core::Id ProjectExplorer::IDevice::id() const
|
||||||
* \brief Identify the device internally.
|
* \brief Identify the device.
|
||||||
* If a fingerprint is given when constructing the device, the id will be derived from it, and
|
* If an id is given when constructing a device then this id is used. Otherwise a UUID is
|
||||||
* the fingerprint can later be retrieved from the id.
|
* generated and used to identity the device.
|
||||||
* \sa ProjectExplorer::DeviceManager::findInactiveAutoDetectedDevice()
|
* \sa ProjectExplorer::DeviceManager::findInactiveAutoDetectedDevice()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
const char DisplayNameKey[] = "Name";
|
const char DisplayNameKey[] = "Name";
|
||||||
const char TypeKey[] = "OsType";
|
const char TypeKey[] = "OsType";
|
||||||
const char InternalIdKey[] = "InternalId";
|
const char IdKey[] = "InternalId";
|
||||||
const char OriginKey[] = "Origin";
|
const char OriginKey[] = "Origin";
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
QString displayName;
|
QString displayName;
|
||||||
QString type;
|
QString type;
|
||||||
IDevice::Origin origin;
|
IDevice::Origin origin;
|
||||||
Core::Id internalId;
|
Core::Id id;
|
||||||
IDevice::AvailabilityState availability;
|
IDevice::AvailabilityState availability;
|
||||||
};
|
};
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -167,13 +167,13 @@ IDevice::IDevice() : d(new Internal::IDevicePrivate)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::IDevice(const QString &type, Origin origin, const QString &fingerprint)
|
IDevice::IDevice(const QString &type, Origin origin, const Core::Id &id)
|
||||||
: d(new Internal::IDevicePrivate)
|
: d(new Internal::IDevicePrivate)
|
||||||
{
|
{
|
||||||
d->type = type;
|
d->type = type;
|
||||||
d->origin = origin;
|
d->origin = origin;
|
||||||
QTC_CHECK(origin == ManuallyAdded || !fingerprint.isEmpty());
|
QTC_CHECK(origin == ManuallyAdded || id.isValid());
|
||||||
d->internalId = fingerprint.isEmpty() ? newId() : Core::Id(fingerprint);
|
d->id = id.isValid() ? id : newId();
|
||||||
d->availability = DeviceAvailabilityUnknown;
|
d->availability = DeviceAvailabilityUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ bool IDevice::isAutoDetected() const
|
|||||||
|
|
||||||
Core::Id IDevice::id() const
|
Core::Id IDevice::id() const
|
||||||
{
|
{
|
||||||
return d->internalId;
|
return d->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::AvailabilityState IDevice::availability() const
|
IDevice::AvailabilityState IDevice::availability() const
|
||||||
@@ -256,7 +256,7 @@ 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 = Core::Id(map.value(QLatin1String(InternalIdKey), newId().toString()).toString());
|
d->id = Core::Id(map.value(QLatin1String(IdKey), newId().name()).toByteArray().constData());
|
||||||
d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt());
|
d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ 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.toString());
|
map.insert(QLatin1String(IdKey), d->id.name());
|
||||||
map.insert(QLatin1String(OriginKey), d->origin);
|
map.insert(QLatin1String(OriginKey), d->origin);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
#ifndef IDEVICE_H
|
#ifndef IDEVICE_H
|
||||||
#define IDEVICE_H
|
#define IDEVICE_H
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorer_export.h>
|
#include "../projectexplorer_export.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
IDevice();
|
IDevice();
|
||||||
IDevice(const QString &type, Origin origin, const QString &fingerprint = QString());
|
IDevice(const QString &type, Origin origin, const Core::Id &id = Core::Id());
|
||||||
IDevice(const IDevice &other);
|
IDevice(const IDevice &other);
|
||||||
|
|
||||||
Ptr sharedFromThis();
|
Ptr sharedFromThis();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Qt4ProjectManager {
|
|||||||
SymbianIDevice::SymbianIDevice() :
|
SymbianIDevice::SymbianIDevice() :
|
||||||
ProjectExplorer::IDevice(Internal::SymbianIDeviceFactory::deviceType(),
|
ProjectExplorer::IDevice(Internal::SymbianIDeviceFactory::deviceType(),
|
||||||
ProjectExplorer::IDevice::AutoDetected,
|
ProjectExplorer::IDevice::AutoDetected,
|
||||||
QLatin1String("Symbian Device")),
|
Core::Id("Symbian Device")),
|
||||||
m_port(QLatin1String(DEFAULT_CODA_TCP_PORT)),
|
m_port(QLatin1String(DEFAULT_CODA_TCP_PORT)),
|
||||||
m_communicationChannel(CommunicationCodaSerialConnection)
|
m_communicationChannel(CommunicationCodaSerialConnection)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ LinuxDeviceConfiguration::~LinuxDeviceConfiguration()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name,
|
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name,
|
||||||
const QString &type, MachineType machineType, Origin origin, const QString &fingerprint)
|
const QString &type, MachineType machineType, Origin origin, const Core::Id &id)
|
||||||
{
|
{
|
||||||
return Ptr(new LinuxDeviceConfiguration(name, type, machineType, origin, fingerprint));
|
return Ptr(new LinuxDeviceConfiguration(name, type, machineType, origin, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LinuxDeviceConfiguration::displayType() const
|
QString LinuxDeviceConfiguration::displayType() const
|
||||||
@@ -140,8 +140,8 @@ LinuxDeviceConfiguration::LinuxDeviceConfiguration() : d(new LinuxDeviceConfigur
|
|||||||
}
|
}
|
||||||
|
|
||||||
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, const QString &type,
|
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, const QString &type,
|
||||||
MachineType machineType, Origin origin, const QString &fingerprint)
|
MachineType machineType, Origin origin, const Core::Id &id)
|
||||||
: IDevice(type, origin, fingerprint), d(new LinuxDeviceConfigurationPrivate)
|
: IDevice(type, origin, id), d(new LinuxDeviceConfigurationPrivate)
|
||||||
{
|
{
|
||||||
setDisplayName(name);
|
setDisplayName(name);
|
||||||
d->machineType = machineType;
|
d->machineType = machineType;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
|
|
||||||
static Ptr create();
|
static Ptr create();
|
||||||
static Ptr create(const QString &name, const QString &type, MachineType machineType,
|
static Ptr create(const QString &name, const QString &type, MachineType machineType,
|
||||||
Origin origin = ManuallyAdded, const QString &fingerprint = QString());
|
Origin origin = ManuallyAdded, const Core::Id &id = Core::Id());
|
||||||
|
|
||||||
QString displayType() const;
|
QString displayType() const;
|
||||||
ProjectExplorer::IDeviceWidget *createWidget();
|
ProjectExplorer::IDeviceWidget *createWidget();
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
LinuxDeviceConfiguration();
|
LinuxDeviceConfiguration();
|
||||||
LinuxDeviceConfiguration(const QString &name, const QString &type, MachineType machineType,
|
LinuxDeviceConfiguration(const QString &name, const QString &type, MachineType machineType,
|
||||||
Origin origin, const QString &fingerprint);
|
Origin origin, const Core::Id &id);
|
||||||
LinuxDeviceConfiguration(const LinuxDeviceConfiguration &other);
|
LinuxDeviceConfiguration(const LinuxDeviceConfiguration &other);
|
||||||
|
|
||||||
QVariantMap toMap() const;
|
QVariantMap toMap() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user