forked from qt-creator/qt-creator
DeviceSupport: use new Core::Id interface
Change-Id: I83fb5933e7feca7d402a288122839d34c9d0f709 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
@@ -382,15 +382,13 @@ IDevice::ConstPtr DeviceManager::findInactiveAutoDetectedDevice(Core::Id type, C
|
||||
|
||||
IDevice::ConstPtr DeviceManager::defaultDevice(Core::Id deviceType) const
|
||||
{
|
||||
const Core::Id id = d->defaultDevices.value(deviceType, IDevice::invalidId());
|
||||
if (id == IDevice::invalidId())
|
||||
return IDevice::ConstPtr();
|
||||
return find(id);
|
||||
const Core::Id id = d->defaultDevices.value(deviceType);
|
||||
return id.isValid() ? find(id) : IDevice::ConstPtr();
|
||||
}
|
||||
|
||||
Core::Id DeviceManager::deviceId(const IDevice::ConstPtr &device) const
|
||||
{
|
||||
return device ? device->id() : IDevice::invalidId();
|
||||
return device ? device->id() : Core::Id();
|
||||
}
|
||||
|
||||
void DeviceManager::ensureOneDefaultDevicePerType()
|
||||
|
@@ -93,9 +93,7 @@ IDevice::ConstPtr DeviceManagerModel::device(int pos) const
|
||||
Core::Id DeviceManagerModel::deviceId(int pos) const
|
||||
{
|
||||
IDevice::ConstPtr dev = device(pos);
|
||||
if (dev.isNull())
|
||||
return IDevice::invalidId();
|
||||
return dev->id();
|
||||
return dev ? dev->id() : Core::Id();
|
||||
}
|
||||
|
||||
int DeviceManagerModel::indexOf(IDevice::ConstPtr dev) const
|
||||
|
@@ -141,7 +141,7 @@
|
||||
|
||||
static Core::Id newId()
|
||||
{
|
||||
return Core::Id(QUuid::createUuid().toString());
|
||||
return Core::Id::fromString(QUuid::createUuid().toString());
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -278,22 +278,14 @@ void IDevice::setDeviceState(const IDevice::DeviceState state)
|
||||
d->deviceState = state;
|
||||
}
|
||||
|
||||
Core::Id IDevice::invalidId()
|
||||
{
|
||||
return Core::Id();
|
||||
}
|
||||
|
||||
Core::Id IDevice::typeFromMap(const QVariantMap &map)
|
||||
{
|
||||
const QString idStr = map.value(QLatin1String(TypeKey)).toString();
|
||||
if (idStr.isEmpty())
|
||||
return Core::Id();
|
||||
return Core::Id(idStr);
|
||||
return Core::Id::fromSetting(map.value(QLatin1String(TypeKey)));
|
||||
}
|
||||
|
||||
Core::Id IDevice::idFromMap(const QVariantMap &map)
|
||||
{
|
||||
return Core::Id(map.value(QLatin1String(IdKey)).toString());
|
||||
return Core::Id::fromSetting(map.value(QLatin1String(IdKey)));
|
||||
}
|
||||
|
||||
void IDevice::fromMap(const QVariantMap &map)
|
||||
|
@@ -125,8 +125,6 @@ public:
|
||||
virtual QVariantMap toMap() const;
|
||||
virtual Ptr clone() const = 0;
|
||||
|
||||
static Core::Id invalidId();
|
||||
|
||||
static Core::Id typeFromMap(const QVariantMap &map);
|
||||
static Core::Id idFromMap(const QVariantMap &map);
|
||||
|
||||
|
@@ -308,14 +308,15 @@ KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(Kit *k) const
|
||||
|
||||
const Core::Id DeviceTypeKitInformation::deviceTypeId(const Kit *k)
|
||||
{
|
||||
// FIXME: This should be fromSetting/toSetting instead.
|
||||
if (!k)
|
||||
return Core::Id();
|
||||
return Core::Id(k->value(Core::Id(DEVICETYPE_INFORMATION)).toByteArray());
|
||||
return Core::Id::fromName(k->value(DEVICETYPE_INFORMATION).toByteArray());
|
||||
}
|
||||
|
||||
void DeviceTypeKitInformation::setDeviceTypeId(Kit *k, Core::Id type)
|
||||
{
|
||||
k->setValue(Core::Id(DEVICETYPE_INFORMATION), type.name());
|
||||
k->setValue(DEVICETYPE_INFORMATION, type.name());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -401,21 +402,17 @@ IDevice::ConstPtr DeviceKitInformation::device(const Kit *k)
|
||||
|
||||
Core::Id DeviceKitInformation::deviceId(const Kit *k)
|
||||
{
|
||||
if (k) {
|
||||
QString idname = k->value(Core::Id(DEVICE_INFORMATION)).toString();
|
||||
return idname.isEmpty() ? IDevice::invalidId() : Core::Id(idname);
|
||||
}
|
||||
return IDevice::invalidId();
|
||||
return k ? Core::Id::fromSetting(k->value(DEVICE_INFORMATION)) : Core::Id();
|
||||
}
|
||||
|
||||
void DeviceKitInformation::setDevice(Kit *k, IDevice::ConstPtr dev)
|
||||
{
|
||||
setDeviceId(k, dev ? dev->id() : IDevice::invalidId());
|
||||
setDeviceId(k, dev ? dev->id() : Core::Id());
|
||||
}
|
||||
|
||||
void DeviceKitInformation::setDeviceId(Kit *k, const Core::Id id)
|
||||
{
|
||||
k->setValue(Core::Id(DEVICE_INFORMATION), id.toString());
|
||||
k->setValue(DEVICE_INFORMATION, id.toSetting());
|
||||
}
|
||||
|
||||
void DeviceKitInformation::deviceUpdated(const Core::Id &id)
|
||||
|
Reference in New Issue
Block a user