forked from qt-creator/qt-creator
Kits: update Core::Id usage to new interface
Change-Id: I653827e8a11e56975e1b2cb1b791e9ea9408f54c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -44,6 +44,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char ID_KEY[] = "PE.Profile.Id";
|
const char ID_KEY[] = "PE.Profile.Id";
|
||||||
@@ -81,7 +83,7 @@ namespace Internal {
|
|||||||
class KitPrivate
|
class KitPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KitPrivate(Core::Id id) :
|
KitPrivate(Id id) :
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_autodetected(false),
|
m_autodetected(false),
|
||||||
m_isValid(true),
|
m_isValid(true),
|
||||||
@@ -89,11 +91,11 @@ public:
|
|||||||
m_mustNotify(false)
|
m_mustNotify(false)
|
||||||
{
|
{
|
||||||
if (!id.isValid())
|
if (!id.isValid())
|
||||||
m_id = Core::Id(QUuid::createUuid().toString().toLatin1());
|
m_id = Id::fromString(QUuid::createUuid().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
Core::Id m_id;
|
Id m_id;
|
||||||
bool m_autodetected;
|
bool m_autodetected;
|
||||||
bool m_isValid;
|
bool m_isValid;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
@@ -279,7 +281,7 @@ bool Kit::isAutoDetected() const
|
|||||||
return d->m_autodetected;
|
return d->m_autodetected;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Id Kit::id() const
|
Id Kit::id() const
|
||||||
{
|
{
|
||||||
return d->m_id;
|
return d->m_id;
|
||||||
}
|
}
|
||||||
@@ -308,17 +310,17 @@ void Kit::setIconPath(const QString &path)
|
|||||||
kitUpdated();
|
kitUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Kit::value(const Core::Id &key, const QVariant &unset) const
|
QVariant Kit::value(Id key, const QVariant &unset) const
|
||||||
{
|
{
|
||||||
return d->m_data.value(key, unset);
|
return d->m_data.value(key, unset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Kit::hasValue(const Core::Id &key) const
|
bool Kit::hasValue(Id key) const
|
||||||
{
|
{
|
||||||
return d->m_data.contains(key);
|
return d->m_data.contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kit::setValue(const Core::Id &key, const QVariant &value)
|
void Kit::setValue(Id key, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (d->m_data.value(key) == value)
|
if (d->m_data.value(key) == value)
|
||||||
return;
|
return;
|
||||||
@@ -326,7 +328,7 @@ void Kit::setValue(const Core::Id &key, const QVariant &value)
|
|||||||
kitUpdated();
|
kitUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kit::removeKey(const Core::Id &key)
|
void Kit::removeKey(Id key)
|
||||||
{
|
{
|
||||||
if (!d->m_data.contains(key))
|
if (!d->m_data.contains(key))
|
||||||
return;
|
return;
|
||||||
@@ -355,7 +357,7 @@ QVariantMap Kit::toMap() const
|
|||||||
data.insert(QLatin1String(ICON_KEY), d->m_iconPath);
|
data.insert(QLatin1String(ICON_KEY), d->m_iconPath);
|
||||||
|
|
||||||
QVariantMap extra;
|
QVariantMap extra;
|
||||||
foreach (const Core::Id &key, d->m_data.keys())
|
foreach (const Id key, d->m_data.keys())
|
||||||
extra.insert(QString::fromLatin1(key.name().constData()), d->m_data.value(key));
|
extra.insert(QString::fromLatin1(key.name().constData()), d->m_data.value(key));
|
||||||
data.insert(QLatin1String(DATA_KEY), extra);
|
data.insert(QLatin1String(DATA_KEY), extra);
|
||||||
|
|
||||||
@@ -428,17 +430,17 @@ QString Kit::toHtml()
|
|||||||
bool Kit::fromMap(const QVariantMap &data)
|
bool Kit::fromMap(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
KitGuard g(this);
|
KitGuard g(this);
|
||||||
const QString id = data.value(QLatin1String(ID_KEY)).toString();
|
Id id = Id::fromSetting(data.value(QLatin1String(ID_KEY)));
|
||||||
if (id.isEmpty())
|
if (!id.isValid())
|
||||||
return false;
|
return false;
|
||||||
d->m_id = Core::Id(id);
|
d->m_id = id;
|
||||||
d->m_autodetected = data.value(QLatin1String(AUTODETECTED_KEY)).toBool();
|
d->m_autodetected = data.value(QLatin1String(AUTODETECTED_KEY)).toBool();
|
||||||
setDisplayName(data.value(QLatin1String(DISPLAYNAME_KEY)).toString());
|
setDisplayName(data.value(QLatin1String(DISPLAYNAME_KEY)).toString());
|
||||||
setIconPath(data.value(QLatin1String(ICON_KEY)).toString());
|
setIconPath(data.value(QLatin1String(ICON_KEY)).toString());
|
||||||
|
|
||||||
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
|
QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
|
||||||
foreach (const QString &key, extra.keys())
|
foreach (const QString &key, extra.keys())
|
||||||
setValue(Core::Id(key), extra.value(key));
|
setValue(Id(key), extra.value(key));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -81,10 +81,10 @@ public:
|
|||||||
QString iconPath() const;
|
QString iconPath() const;
|
||||||
void setIconPath(const QString &path);
|
void setIconPath(const QString &path);
|
||||||
|
|
||||||
QVariant value(const Core::Id &key, const QVariant &unset = QVariant()) const;
|
QVariant value(Core::Id key, const QVariant &unset = QVariant()) const;
|
||||||
bool hasValue(const Core::Id &key) const;
|
bool hasValue(Core::Id key) const;
|
||||||
void setValue(const Core::Id &key, const QVariant &value);
|
void setValue(Core::Id key, const QVariant &value);
|
||||||
void removeKey(const Core::Id &key);
|
void removeKey(Core::Id key);
|
||||||
|
|
||||||
bool isDataEqual(const Kit *other) const;
|
bool isDataEqual(const Kit *other) const;
|
||||||
bool isEqual(const Kit *other) const;
|
bool isEqual(const Kit *other) const;
|
||||||
|
@@ -373,8 +373,7 @@ void DeviceKitInformation::fix(Kit *k)
|
|||||||
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString id = defaultValue(k).toString();
|
setDeviceId(k, Core::Id::fromSetting(defaultValue(k)));
|
||||||
setDeviceId(k, id.isEmpty() ? Core::Id() : Core::Id(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
|
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
|
||||||
|
Reference in New Issue
Block a user