Fix QMetaType::type() related deprecation warnings

Not in sdktool, which still builds with Qt 5.15

Change-Id: I6e6f4331127b821e471e2840e7959cd65e6419e9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-05-23 09:37:34 +02:00
parent af3ab760ad
commit f30d369b99
62 changed files with 295 additions and 295 deletions

View File

@@ -447,7 +447,7 @@ JsonValue *JsonValue::build(const QVariant &variant, JsonMemoryPool *pool)
{ {
switch (variant.typeId()) { switch (variant.typeId()) {
case QVariant::List: { case QMetaType::QVariantList: {
auto newValue = new (pool) JsonArrayValue; auto newValue = new (pool) JsonArrayValue;
const QList<QVariant> list = variant.toList(); const QList<QVariant> list = variant.toList();
for (const QVariant &element : list) for (const QVariant &element : list)
@@ -455,7 +455,7 @@ JsonValue *JsonValue::build(const QVariant &variant, JsonMemoryPool *pool)
return newValue; return newValue;
} }
case QVariant::Map: { case QMetaType::QVariantMap: {
auto newValue = new (pool) JsonObjectValue; auto newValue = new (pool) JsonObjectValue;
const QVariantMap variantMap = variant.toMap(); const QVariantMap variantMap = variant.toMap();
for (QVariantMap::const_iterator it = variantMap.begin(); it != variantMap.end(); ++it) for (QVariantMap::const_iterator it = variantMap.begin(); it != variantMap.end(); ++it)
@@ -463,19 +463,19 @@ JsonValue *JsonValue::build(const QVariant &variant, JsonMemoryPool *pool)
return newValue; return newValue;
} }
case QVariant::String: case QMetaType::QString:
return new (pool) JsonStringValue(variant.toString()); return new (pool) JsonStringValue(variant.toString());
case QVariant::Int: case QMetaType::Int:
return new (pool) JsonIntValue(variant.toInt()); return new (pool) JsonIntValue(variant.toInt());
case QVariant::Double: case QMetaType::Double:
return new (pool) JsonDoubleValue(variant.toDouble()); return new (pool) JsonDoubleValue(variant.toDouble());
case QVariant::Bool: case QMetaType::Bool:
return new (pool) JsonBooleanValue(variant.toBool()); return new (pool) JsonBooleanValue(variant.toBool());
case QVariant::Invalid: case QMetaType::UnknownType:
return new (pool) JsonNullValue; return new (pool) JsonNullValue;
default: default:

View File

@@ -373,18 +373,18 @@ private:
if (value.isNull()) if (value.isNull())
return VariantType{NullValue{}}; return VariantType{NullValue{}};
switch (value.userType()) { switch (value.typeId()) {
case QVariant::Int: case QMetaType::Int:
return VariantType{static_cast<long long>(value.toInt())}; return VariantType{static_cast<long long>(value.toInt())};
case QVariant::LongLong: case QMetaType::LongLong:
return VariantType{value.toLongLong()}; return VariantType{value.toLongLong()};
case QVariant::UInt: case QMetaType::UInt:
return VariantType{static_cast<long long>(value.toUInt())}; return VariantType{static_cast<long long>(value.toUInt())};
case QVariant::Double: case QMetaType::Double:
return VariantType{value.toFloat()}; return VariantType{value.toFloat()};
case QVariant::String: case QMetaType::QString:
return VariantType{value.toString()}; return VariantType{value.toString()};
case QVariant::ByteArray: case QMetaType::QByteArray:
return VariantType{Blob{value.toByteArray()}}; return VariantType{Blob{value.toByteArray()}};
default: default:
throw CannotConvert(); throw CannotConvert();

View File

@@ -1367,7 +1367,7 @@ FilePath FilePath::fromUtf8(const char *filename, int filenameSize)
FilePath FilePath::fromSettings(const QVariant &variant) FilePath FilePath::fromSettings(const QVariant &variant)
{ {
if (variant.type() == QVariant::Url) { if (variant.typeId() == QMetaType::QUrl) {
const QUrl url = variant.toUrl(); const QUrl url = variant.toUrl();
return FilePath::fromParts(url.scheme(), url.host(), url.path()); return FilePath::fromParts(url.scheme(), url.host(), url.path());
} }

View File

@@ -284,7 +284,7 @@ QByteArray MacroExpander::expand(const QByteArray &stringWithVariables) const
QVariant MacroExpander::expandVariant(const QVariant &v) const QVariant MacroExpander::expandVariant(const QVariant &v) const
{ {
const auto type = QMetaType::Type(v.type()); const int type = v.typeId();
if (type == QMetaType::QString) { if (type == QMetaType::QString) {
return expand(v.toString()); return expand(v.toString());
} else if (type == QMetaType::QStringList) { } else if (type == QMetaType::QStringList) {

View File

@@ -106,13 +106,13 @@ const QString keyAttribute("key");
struct ParseValueStackEntry struct ParseValueStackEntry
{ {
explicit ParseValueStackEntry(QVariant::Type t = QVariant::Invalid, const QString &k = {}) : type(t), key(k) {} explicit ParseValueStackEntry(QMetaType::Type t = QMetaType::UnknownType, const QString &k = {}) : typeId(t), key(k) {}
explicit ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k); explicit ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k);
QVariant value() const; QVariant value() const;
void addChild(const QString &key, const QVariant &v); void addChild(const QString &key, const QVariant &v);
QVariant::Type type; QMetaType::Type typeId;
QString key; QString key;
QVariant simpleValue; QVariant simpleValue;
QVariantList listValue; QVariantList listValue;
@@ -120,19 +120,19 @@ struct ParseValueStackEntry
}; };
ParseValueStackEntry::ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k) ParseValueStackEntry::ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k)
: type(aSimpleValue.type()), key(k), simpleValue(aSimpleValue) : typeId(QMetaType::Type(aSimpleValue.typeId())), key(k), simpleValue(aSimpleValue)
{ {
QTC_ASSERT(simpleValue.isValid(), return); QTC_ASSERT(simpleValue.isValid(), return);
} }
QVariant ParseValueStackEntry::value() const QVariant ParseValueStackEntry::value() const
{ {
switch (type) { switch (typeId) {
case QVariant::Invalid: case QMetaType::UnknownType:
return QVariant(); return QVariant();
case QVariant::Map: case QMetaType::QVariantMap:
return QVariant(mapValue); return QVariant(mapValue);
case QVariant::List: case QMetaType::QVariantList:
return QVariant(listValue); return QVariant(listValue);
default: default:
break; break;
@@ -142,16 +142,16 @@ QVariant ParseValueStackEntry::value() const
void ParseValueStackEntry::addChild(const QString &key, const QVariant &v) void ParseValueStackEntry::addChild(const QString &key, const QVariant &v)
{ {
switch (type) { switch (typeId) {
case QVariant::Map: case QMetaType::QVariantMap:
mapValue.insert(key, v); mapValue.insert(key, v);
break; break;
case QVariant::List: case QMetaType::QVariantList:
listValue.push_back(v); listValue.push_back(v);
break; break;
default: default:
qWarning() << "ParseValueStackEntry::Internal error adding " << key << v << " to " qWarning() << "ParseValueStackEntry::Internal error adding " << key << v << " to "
<< QVariant::typeToName(type) << value(); << QMetaType(typeId).name() << value();
break; break;
} }
} }
@@ -226,14 +226,14 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r)
const QXmlStreamAttributes attributes = r.attributes(); const QXmlStreamAttributes attributes = r.attributes();
const QString key = attributes.hasAttribute(keyAttribute) ? const QString key = attributes.hasAttribute(keyAttribute) ?
attributes.value(keyAttribute).toString() : QString(); attributes.value(keyAttribute).toString() : QString();
m_valueStack.push_back(ParseValueStackEntry(QVariant::List, key)); m_valueStack.push_back(ParseValueStackEntry(QMetaType::QVariantList, key));
return false; return false;
} }
if (name == valueMapElement) { if (name == valueMapElement) {
const QXmlStreamAttributes attributes = r.attributes(); const QXmlStreamAttributes attributes = r.attributes();
const QString key = attributes.hasAttribute(keyAttribute) ? const QString key = attributes.hasAttribute(keyAttribute) ?
attributes.value(keyAttribute).toString() : QString(); attributes.value(keyAttribute).toString() : QString();
m_valueStack.push_back(ParseValueStackEntry(QVariant::Map, key)); m_valueStack.push_back(ParseValueStackEntry(QMetaType::QVariantMap, key));
return false; return false;
} }
return false; return false;
@@ -369,8 +369,8 @@ static void writeVariantValue(QXmlStreamWriter &w, const QVariant &variant, cons
w.writeAttribute(typeAttribute, QLatin1String(variant.typeName())); w.writeAttribute(typeAttribute, QLatin1String(variant.typeName()));
if (!key.isEmpty()) if (!key.isEmpty())
w.writeAttribute(keyAttribute, xmlAttrFromKey(key)); w.writeAttribute(keyAttribute, xmlAttrFromKey(key));
switch (variant.type()) { switch (variant.typeId()) {
case QVariant::Rect: case QMetaType::QRect:
w.writeCharacters(rectangleToString(variant.toRect())); w.writeCharacters(rectangleToString(variant.toRect()));
break; break;
default: default:

View File

@@ -50,10 +50,10 @@ static QVariantList mapListFromStoreList(const QVariantList &storeList);
QVariant storeEntryFromMapEntry(const QVariant &mapEntry) QVariant storeEntryFromMapEntry(const QVariant &mapEntry)
{ {
if (mapEntry.type() == QVariant::Map) if (mapEntry.typeId() == QMetaType::QVariantMap)
return QVariant::fromValue(storeFromMap(mapEntry.toMap())); return QVariant::fromValue(storeFromMap(mapEntry.toMap()));
if (mapEntry.type() == QVariant::List) if (mapEntry.typeId() == QMetaType::QVariantList)
return QVariant::fromValue(storeListFromMapList(mapEntry.toList())); return QVariant::fromValue(storeListFromMapList(mapEntry.toList()));
return mapEntry; return mapEntry;
@@ -64,7 +64,7 @@ QVariant mapEntryFromStoreEntry(const QVariant &storeEntry)
if (storeEntry.metaType() == QMetaType::fromType<Store>()) if (storeEntry.metaType() == QMetaType::fromType<Store>())
return QVariant::fromValue(mapFromStore(storeEntry.value<Store>())); return QVariant::fromValue(mapFromStore(storeEntry.value<Store>()));
if (storeEntry.type() == QVariant::List) if (storeEntry.typeId() == QMetaType::QVariantList)
return QVariant::fromValue(mapListFromStoreList(storeEntry.toList())); return QVariant::fromValue(mapListFromStoreList(storeEntry.toList()));
return storeEntry; return storeEntry;

View File

@@ -459,13 +459,13 @@ void ModelTest::data()
// General Purpose roles that should return a QString // General Purpose roles that should return a QString
QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole);
if (variant.isValid()) if (variant.isValid())
Q_ASSERT(variant.canConvert(QVariant::String)); Q_ASSERT(variant.canConvert(QMetaType::QString));
variant = model->data(model->index(0, 0), Qt::StatusTipRole); variant = model->data(model->index(0, 0), Qt::StatusTipRole);
if (variant.isValid()) if (variant.isValid())
Q_ASSERT(variant.canConvert(QVariant::String)); Q_ASSERT(variant.canConvert(QMetaType::QString));
variant = model->data(model->index(0, 0), Qt::WhatsThisRole); variant = model->data(model->index(0, 0), Qt::WhatsThisRole);
if (variant.isValid()) if (variant.isValid())
Q_ASSERT(variant.canConvert(QVariant::String)); Q_ASSERT(variant.canConvert(QMetaType::QString));
// General Purpose roles that should return a QSize // General Purpose roles that should return a QSize
variant = model->data(model->index(0, 0), Qt::SizeHintRole); variant = model->data(model->index(0, 0), Qt::SizeHintRole);

View File

@@ -365,8 +365,8 @@ QHash<QString, QVariant> Wizard::variables() const
QString typeOf(const QVariant &v) QString typeOf(const QVariant &v)
{ {
QString result; QString result;
switch (v.type()) { switch (v.typeId()) {
case QVariant::Map: case QMetaType::QVariantMap:
result = QLatin1String("Object"); result = QLatin1String("Object");
break; break;
default: default:

View File

@@ -197,7 +197,7 @@ void AndroidConfig::load(const QtcSettings &settings)
{ {
// user settings // user settings
QVariant emulatorArgs = settings.value(EmulatorArgsKey, QString("-netdelay none -netspeed full")); QVariant emulatorArgs = settings.value(EmulatorArgsKey, QString("-netdelay none -netspeed full"));
if (emulatorArgs.typeId() == QVariant::StringList) // Changed in 8.0 from QStringList to QString. if (emulatorArgs.typeId() == QMetaType::QStringList) // Changed in 8.0 from QStringList to QString.
emulatorArgs = ProcessArgs::joinArgs(emulatorArgs.toStringList()); emulatorArgs = ProcessArgs::joinArgs(emulatorArgs.toStringList());
m_emulatorArgs = emulatorArgs.toString(); m_emulatorArgs = emulatorArgs.toString();
m_sdkLocation = FilePath::fromUserInput(settings.value(SDKLocationKey).toString()).cleanPath(); m_sdkLocation = FilePath::fromUserInput(settings.value(SDKLocationKey).toString()).cleanPath();

View File

@@ -174,14 +174,14 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
if (const Store sd = runControl->settingsData(Constants::ANDROID_AM_START_ARGS); if (const Store sd = runControl->settingsData(Constants::ANDROID_AM_START_ARGS);
!sd.values().isEmpty()) { !sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String); QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QString startArgs = sd.first().toString(); const QString startArgs = sd.first().toString();
m_amStartExtraArgs = ProcessArgs::splitArgs(startArgs, OsTypeOtherUnix); m_amStartExtraArgs = ProcessArgs::splitArgs(startArgs, OsTypeOtherUnix);
} }
if (const Store sd = runControl->settingsData(Constants::ANDROID_PRESTARTSHELLCMDLIST); if (const Store sd = runControl->settingsData(Constants::ANDROID_PRESTARTSHELLCMDLIST);
!sd.values().isEmpty()) { !sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String); QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts); const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
for (const QString &shellCmd : commands) for (const QString &shellCmd : commands)
m_beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd)); m_beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
@@ -189,7 +189,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
if (const Store sd = runControl->settingsData(Constants::ANDROID_POSTFINISHSHELLCMDLIST); if (const Store sd = runControl->settingsData(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
!sd.values().isEmpty()) { !sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String); QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts); const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
for (const QString &shellCmd : commands) for (const QString &shellCmd : commands)
m_afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd)); m_afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd));

View File

@@ -957,11 +957,11 @@ VcsCommand *BazaarPluginPrivate::createInitialCheckoutCommand(const QString &url
void BazaarPluginPrivate::changed(const QVariant &v) void BazaarPluginPrivate::changed(const QVariant &v)
{ {
switch (v.type()) { switch (v.typeId()) {
case QVariant::String: case QMetaType::QString:
emit repositoryChanged(FilePath::fromVariant(v)); emit repositoryChanged(FilePath::fromVariant(v));
break; break;
case QVariant::StringList: case QMetaType::QStringList:
emit filesChanged(v.toStringList()); emit filesChanged(v.toStringList());
break; break;
default: default:

View File

@@ -800,7 +800,7 @@ void CMakeGeneratorKitAspectFactory::upgrade(Kit *k)
QTC_ASSERT(k, return); QTC_ASSERT(k, return);
const QVariant value = k->value(GENERATOR_ID); const QVariant value = k->value(GENERATOR_ID);
if (value.type() != QVariant::Map) { if (value.typeId() != QMetaType::QVariantMap) {
GeneratorInfo info; GeneratorInfo info;
const QString fullName = value.toString(); const QString fullName = value.toString();
const int pos = fullName.indexOf(" - "); const int pos = fullName.indexOf(" - ");

View File

@@ -875,7 +875,7 @@ void ActionManagerPrivate::readUserSettings(Id id, Command *cmd)
settings->beginGroup(kKeyboardSettingsKeyV2); settings->beginGroup(kKeyboardSettingsKeyV2);
if (settings->contains(id.toKey())) { if (settings->contains(id.toKey())) {
const QVariant v = settings->value(id.toKey()); const QVariant v = settings->value(id.toKey());
if (QMetaType::Type(v.type()) == QMetaType::QStringList) { if (v.typeId() == QMetaType::QStringList) {
cmd->setKeySequences(Utils::transform<QList>(v.toStringList(), [](const QString &s) { cmd->setKeySequences(Utils::transform<QList>(v.toStringList(), [](const QString &s) {
return QKeySequence::fromString(s); return QKeySequence::fromString(s);
})); }));

View File

@@ -329,7 +329,7 @@ public:
} }
if (!item.detectionSource().isEmpty() && item.detectionSource() == k->autoDetectionSource()) if (!item.detectionSource().isEmpty() && item.detectionSource() == k->autoDetectionSource())
level = DebuggerItem::MatchLevel(level + 2); level = DebuggerItem::MatchLevel(level + 2);
} else if (rawId.type() == QVariant::String) { } else if (rawId.typeId() == QMetaType::QString) {
// New structure. // New structure.
if (item.id() == rawId) { if (item.id() == rawId) {
// Detected by ID. // Detected by ID.

View File

@@ -783,7 +783,7 @@ void QmlEngine::assignValueInDebugger(WatchItem *item,
const QString &expression, const QVariant &editValue) const QString &expression, const QVariant &editValue)
{ {
if (!expression.isEmpty()) { if (!expression.isEmpty()) {
QTC_CHECK(editValue.typeId() == QVariant::String); QTC_CHECK(editValue.typeId() == QMetaType::QString);
QVariant value; QVariant value;
QString val = editValue.toString(); QString val = editValue.toString();
if (item->type == "boolean") if (item->type == "boolean")
@@ -861,7 +861,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, const QString &
QString text; QString text;
ConsoleItem *item = nullptr; ConsoleItem *item = nullptr;
if (result.typeId() == QVariant::Map) { if (result.typeId() == QMetaType::QVariantMap) {
if (key.isEmpty()) if (key.isEmpty())
text = "Object"; text = "Object";
else else
@@ -885,7 +885,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, const QString &
item->appendChild(child); item->appendChild(child);
} }
} else if (result.typeId() == QVariant::List) { } else if (result.typeId() == QMetaType::QVariantList) {
if (key.isEmpty()) if (key.isEmpty())
text = "List"; text = "List";
else else
@@ -904,7 +904,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, const QString &
if (child) if (child)
item->appendChild(child); item->appendChild(child);
} }
} else if (result.canConvert(QVariant::String)) { } else if (result.canConvert(QMetaType::QString)) {
item = new ConsoleItem(ConsoleItem::DefaultType, result.toString()); item = new ConsoleItem(ConsoleItem::DefaultType, result.toString());
} else { } else {
item = new ConsoleItem(ConsoleItem::DefaultType, "Unknown Value"); item = new ConsoleItem(ConsoleItem::DefaultType, "Unknown Value");
@@ -1356,9 +1356,9 @@ void QmlEnginePrivate::scripts(int types, const QList<int> ids, bool includeSour
if (includeSource) if (includeSource)
cmd.arg(INCLUDESOURCE, includeSource); cmd.arg(INCLUDESOURCE, includeSource);
if (filter.typeId() == QVariant::String) if (filter.typeId() == QMetaType::QString)
cmd.arg(FILTER, filter.toString()); cmd.arg(FILTER, filter.toString());
else if (filter.typeId() == QVariant::Int) else if (filter.typeId() == QMetaType::Int)
cmd.arg(FILTER, filter.toInt()); cmd.arg(FILTER, filter.toInt());
else else
QTC_CHECK(!filter.isValid()); QTC_CHECK(!filter.isValid());
@@ -2041,7 +2041,7 @@ StackFrame QmlEnginePrivate::extractStackFrame(const QVariant &bodyVal)
} }
auto extractString = [this](const QVariant &item) { auto extractString = [this](const QVariant &item) {
return (item.typeId() == QVariant::String ? item : extractData(item).value).toString(); return (item.typeId() == QMetaType::QString ? item : extractData(item).value).toString();
}; };
stackFrame.function = extractString(body.value("func")); stackFrame.function = extractString(body.value("func"));

View File

@@ -220,7 +220,7 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value,
if (m_objectTreeQueryIds.contains(queryId)) { if (m_objectTreeQueryIds.contains(queryId)) {
m_objectTreeQueryIds.removeOne(queryId); m_objectTreeQueryIds.removeOne(queryId);
if (value.typeId() == QVariant::List) { if (value.typeId() == QMetaType::QVariantList) {
const QVariantList objList = value.toList(); const QVariantList objList = value.toList();
for (const QVariant &var : objList) { for (const QVariant &var : objList) {
// TODO: check which among the list is the actual // TODO: check which among the list is the actual
@@ -289,7 +289,7 @@ static void sortChildrenIfNecessary(WatchItem *propertiesWatch)
static bool insertChildren(WatchItem *parent, const QVariant &value) static bool insertChildren(WatchItem *parent, const QVariant &value)
{ {
switch (value.typeId()) { switch (value.typeId()) {
case QVariant::Map: { case QMetaType::QVariantMap: {
const QVariantMap map = value.toMap(); const QVariantMap map = value.toMap();
for (auto it = map.begin(), end = map.end(); it != end; ++it) { for (auto it = map.begin(), end = map.end(); it != end; ++it) {
auto child = new WatchItem; auto child = new WatchItem;
@@ -303,7 +303,7 @@ static bool insertChildren(WatchItem *parent, const QVariant &value)
sortChildrenIfNecessary(parent); sortChildrenIfNecessary(parent);
return true; return true;
} }
case QVariant::List: { case QMetaType::QVariantList: {
const QVariantList list = value.toList(); const QVariantList list = value.toList();
for (int i = 0, end = list.size(); i != end; ++i) { for (int i = 0, end = list.size(); i != end; ++i) {
auto child = new WatchItem; auto child = new WatchItem;

View File

@@ -33,7 +33,7 @@ public:
QString toToolTip() const; QString toToolTip() const;
QVariant editValue() const; QVariant editValue() const;
int editType() const; QMetaType::Type editType() const;
static const qint64 InvalidId = -1; static const qint64 InvalidId = -1;
constexpr static char loadMoreName[] = "<load more>"; constexpr static char loadMoreName[] = "<load more>";

View File

@@ -189,25 +189,25 @@ void IntegerWatchLineEdit::setModelData(const QVariant &v)
qDebug(">IntegerLineEdit::setModelData(%s, '%s'): base=%d, signed=%d, bigint=%d", qDebug(">IntegerLineEdit::setModelData(%s, '%s'): base=%d, signed=%d, bigint=%d",
v.typeName(), qPrintable(v.toString()), v.typeName(), qPrintable(v.toString()),
base(), isSigned(), isBigInt()); base(), isSigned(), isBigInt());
switch (v.type()) { switch (v.typeId()) {
case QVariant::Int: case QMetaType::Int:
case QVariant::LongLong: { case QMetaType::LongLong: {
const qint64 iv = v.toLongLong(); const qint64 iv = v.toLongLong();
setSigned(true); setSigned(true);
setText(QString::number(iv, base())); setText(QString::number(iv, base()));
} }
break; break;
case QVariant::UInt: case QMetaType::UInt:
case QVariant::ULongLong: { case QMetaType::ULongLong: {
const quint64 iv = v.toULongLong(); const quint64 iv = v.toULongLong();
setSigned(false); setSigned(false);
setText(QString::number(iv, base())); setText(QString::number(iv, base()));
} }
break; break;
case QVariant::ByteArray: case QMetaType::QByteArray:
setNumberText(QString::fromLatin1(v.toByteArray())); setNumberText(QString::fromLatin1(v.toByteArray()));
break; break;
case QVariant::String: case QMetaType::QString:
setNumberText(v.toString()); setNumberText(v.toString());
break; break;
default: default:
@@ -243,12 +243,12 @@ void FloatWatchLineEdit::setModelData(const QVariant &v)
if (debug) if (debug)
qDebug("FloatWatchLineEdit::setModelData(%s, '%s')", qDebug("FloatWatchLineEdit::setModelData(%s, '%s')",
v.typeName(), qPrintable(v.toString())); v.typeName(), qPrintable(v.toString()));
switch (v.type()) { switch (v.typeId()) {
case QVariant::Double: case QMetaType::Double:
case QVariant::String: case QMetaType::QString:
setText(v.toString()); setText(v.toString());
break; break;
case QVariant::ByteArray: case QMetaType::QByteArray:
setText(QString::fromLatin1(v.toByteArray())); setText(QString::fromLatin1(v.toByteArray()));
break; break;
default: default:
@@ -259,17 +259,17 @@ void FloatWatchLineEdit::setModelData(const QVariant &v)
} }
} }
WatchLineEdit *WatchLineEdit::create(QVariant::Type t, QWidget *parent) WatchLineEdit *WatchLineEdit::create(QMetaType::Type typeId, QWidget *parent)
{ {
switch (t) { switch (typeId) {
case QVariant::Bool: case QMetaType::Bool:
case QVariant::Int: case QMetaType::Int:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::ULongLong: case QMetaType::ULongLong:
return new IntegerWatchLineEdit(parent); return new IntegerWatchLineEdit(parent);
break; break;
case QVariant::Double: case QMetaType::Double:
return new FloatWatchLineEdit(parent); return new FloatWatchLineEdit(parent);
default: default:
break; break;
@@ -297,14 +297,14 @@ void BooleanComboBox::setModelData(const QVariant &v)
qDebug("BooleanComboBox::setModelData(%s, '%s')", v.typeName(), qPrintable(v.toString())); qDebug("BooleanComboBox::setModelData(%s, '%s')", v.typeName(), qPrintable(v.toString()));
bool value = false; bool value = false;
switch (v.type()) { switch (v.typeId()) {
case QVariant::Bool: case QMetaType::Bool:
value = v.toBool(); value = v.toBool();
break; break;
case QVariant::Int: case QMetaType::Int:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::ULongLong: case QMetaType::ULongLong:
value = v.toInt() != 0; value = v.toInt() != 0;
break; break;
default: default:

View File

@@ -27,7 +27,7 @@ public:
virtual QVariant modelData() const; virtual QVariant modelData() const;
virtual void setModelData(const QVariant &); virtual void setModelData(const QVariant &);
static WatchLineEdit *create(QVariant::Type t, QWidget *parent = nullptr); static WatchLineEdit *create(QMetaType::Type typeId, QWidget *parent = nullptr);
}; };
/* Watch delegate line edit for integer numbers based on quint64/qint64. /* Watch delegate line edit for integer numbers based on quint64/qint64.

View File

@@ -844,33 +844,33 @@ static inline quint64 pointerValue(QString data)
} }
// Return the type used for editing // Return the type used for editing
int WatchItem::editType() const QMetaType::Type WatchItem::editType() const
{ {
if (type == "bool") if (type == "bool")
return QVariant::Bool; return QMetaType::Bool;
if (isIntType(type)) if (isIntType(type))
return type.contains('u') ? QVariant::ULongLong : QVariant::LongLong; return type.contains('u') ? QMetaType::ULongLong : QMetaType::LongLong;
if (isFloatType(type)) if (isFloatType(type))
return QVariant::Double; return QMetaType::Double;
// Check for pointers using hex values (0xAD00 "Hallo") // Check for pointers using hex values (0xAD00 "Hallo")
if (isPointerType(type) && value.startsWith("0x")) if (isPointerType(type) && value.startsWith("0x"))
return QVariant::ULongLong; return QMetaType::ULongLong;
return QVariant::String; return QMetaType::QString;
} }
// Convert to editable (see above) // Convert to editable (see above)
QVariant WatchItem::editValue() const QVariant WatchItem::editValue() const
{ {
switch (editType()) { switch (editType()) {
case QVariant::Bool: case QMetaType::Bool:
return value != "0" && value != "false"; return value != "0" && value != "false";
case QVariant::ULongLong: case QMetaType::ULongLong:
if (isPointerType(type)) // Fix pointer values (0xAD00 "Hallo" -> 0xAD00) if (isPointerType(type)) // Fix pointer values (0xAD00 "Hallo" -> 0xAD00)
return QVariant(pointerValue(value)); return QVariant(pointerValue(value));
return QVariant(value.toULongLong()); return QVariant(value.toULongLong());
case QVariant::LongLong: case QMetaType::LongLong:
return QVariant(value.toLongLong()); return QVariant(value.toLongLong());
case QVariant::Double: case QMetaType::Double:
return QVariant(value.toDouble()); return QVariant(value.toDouble());
default: default:
break; break;
@@ -2888,8 +2888,8 @@ public:
// Value column: Custom editor. Apply integer-specific settings. // Value column: Custom editor. Apply integer-specific settings.
if (index.column() == 1) { if (index.column() == 1) {
auto editType = QVariant::Type(item->editType()); const QMetaType::Type editType = item->editType();
if (editType == QVariant::Bool) if (editType == QMetaType::Bool)
return new BooleanComboBox(parent); return new BooleanComboBox(parent);
WatchLineEdit *edit = WatchLineEdit::create(editType, parent); WatchLineEdit *edit = WatchLineEdit::create(editType, parent);

View File

@@ -45,7 +45,7 @@ Utils::WizardPage *FormPageFactory::create(ProjectExplorer::JsonWizard *wizard,
bool FormPageFactory::validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage) bool FormPageFactory::validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage)
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) { if (!data.isNull() && (data.typeId() != QMetaType::QVariantMap || !data.toMap().isEmpty())) {
*errorMessage = ::ProjectExplorer::Tr::tr( *errorMessage = ::ProjectExplorer::Tr::tr(
"\"data\" for a \"Form\" page needs to be unset or an empty object."); "\"data\" for a \"Form\" page needs to be unset or an empty object.");
return false; return false;

View File

@@ -6123,7 +6123,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd)
FvBaseAspect *act = s.item(Utils::keyFromString(optionName)); FvBaseAspect *act = s.item(Utils::keyFromString(optionName));
if (!act) { if (!act) {
showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args); showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args);
} else if (act->defaultVariantValue().type() == QVariant::Bool) { } else if (act->defaultVariantValue().typeId() == QMetaType::Bool) {
bool oldValue = act->variantValue().toBool(); bool oldValue = act->variantValue().toBool();
if (printOption) { if (printOption) {
showMessage(MessageInfo, QLatin1String(oldValue ? "" : "no") showMessage(MessageInfo, QLatin1String(oldValue ? "" : "no")

View File

@@ -989,11 +989,11 @@ VcsCommand *FossilPluginPrivate::createInitialCheckoutCommand(const QString &sou
void FossilPluginPrivate::changed(const QVariant &v) void FossilPluginPrivate::changed(const QVariant &v)
{ {
switch (v.type()) { switch (v.typeId()) {
case QVariant::String: case QMetaType::QString:
emit repositoryChanged(FilePath::fromVariant(v)); emit repositoryChanged(FilePath::fromVariant(v));
break; break;
case QVariant::StringList: case QMetaType::QStringList:
emit filesChanged(v.toStringList()); emit filesChanged(v.toStringList());
break; break;
default: default:

View File

@@ -78,7 +78,7 @@ public:
const QVariant checkFormat = kit->value(McuDependenciesKitAspect::id()); const QVariant checkFormat = kit->value(McuDependenciesKitAspect::id());
if (!checkFormat.isValid() || checkFormat.isNull()) if (!checkFormat.isValid() || checkFormat.isNull())
return result; return result;
if (!checkFormat.canConvert(QVariant::List)) if (!checkFormat.canConvert(QMetaType::QVariantList))
return {BuildSystemTask(Task::Error, Tr::tr("The MCU dependencies setting value is invalid."))}; return {BuildSystemTask(Task::Error, Tr::tr("The MCU dependencies setting value is invalid."))};
// check paths defined in cmake variables for given dependencies exist // check paths defined in cmake variables for given dependencies exist
@@ -105,7 +105,7 @@ public:
QTC_ASSERT(kit, return ); QTC_ASSERT(kit, return );
const QVariant variant = kit->value(McuDependenciesKitAspect::id()); const QVariant variant = kit->value(McuDependenciesKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QVariant::List)) { if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList)) {
qWarning("Kit \"%s\" has a wrong mcu dependencies value set.", qWarning("Kit \"%s\" has a wrong mcu dependencies value set.",
qPrintable(kit->displayName())); qPrintable(kit->displayName()));
McuDependenciesKitAspect::setDependencies(kit, Utils::EnvironmentItems()); McuDependenciesKitAspect::setDependencies(kit, Utils::EnvironmentItems());

View File

@@ -753,11 +753,11 @@ bool MercurialPluginPrivate::sccManaged(const QString &filename)
void MercurialPluginPrivate::changed(const QVariant &v) void MercurialPluginPrivate::changed(const QVariant &v)
{ {
switch (v.type()) { switch (v.typeId()) {
case QVariant::String: case QMetaType::QString:
emit repositoryChanged(FilePath::fromVariant(v)); emit repositoryChanged(FilePath::fromVariant(v));
break; break;
case QVariant::StringList: case QMetaType::QStringList:
emit filesChanged(v.toStringList()); emit filesChanged(v.toStringList());
break; break;
default: default:

View File

@@ -118,25 +118,25 @@ bool BuidOptionsModel::hasChanges() const
QWidget *BuildOptionDelegate::makeWidget(QWidget *parent, const QVariant &data) QWidget *BuildOptionDelegate::makeWidget(QWidget *parent, const QVariant &data)
{ {
auto type = data.userType(); const int type = data.typeId();
switch (type) { switch (type) {
case QVariant::Int: { case QMetaType::Int: {
auto w = new QSpinBox{parent}; auto w = new QSpinBox{parent};
w->setValue(data.toInt()); w->setValue(data.toInt());
return w; return w;
} }
case QVariant::Bool: { case QMetaType::Bool: {
auto w = new QComboBox{parent}; auto w = new QComboBox{parent};
w->addItems({"false", "true"}); w->addItems({"false", "true"});
w->setCurrentIndex(data.toBool()); w->setCurrentIndex(data.toBool());
return w; return w;
} }
case QVariant::StringList: { case QMetaType::QStringList: {
auto w = new ArrayOptionLineEdit{parent}; auto w = new ArrayOptionLineEdit{parent};
w->setPlainText(data.toStringList().join(" ")); w->setPlainText(data.toStringList().join(" "));
return w; return w;
} }
case QVariant::String: { case QMetaType::QString: {
auto w = new QLineEdit{parent}; auto w = new QLineEdit{parent};
w->setText(data.toString()); w->setText(data.toString());
return w; return w;

View File

@@ -86,12 +86,12 @@ QVariantList PerfTimelineModel::labels() const
QString prettyPrintTraceData(const QVariant &data) QString prettyPrintTraceData(const QVariant &data)
{ {
switch (data.type()) { switch (data.typeId()) {
case QVariant::ULongLong: case QMetaType::ULongLong:
return QString::fromLatin1("0x%1").arg(data.toULongLong(), 16, 16, QLatin1Char('0')); return QString::fromLatin1("0x%1").arg(data.toULongLong(), 16, 16, QLatin1Char('0'));
case QVariant::UInt: case QMetaType::UInt:
return QString::fromLatin1("0x%1").arg(data.toUInt(), 8, 16, QLatin1Char('0')); return QString::fromLatin1("0x%1").arg(data.toUInt(), 8, 16, QLatin1Char('0'));
case QVariant::List: { case QMetaType::QVariantList: {
QStringList ret; QStringList ret;
for (const QVariant &item : data.toList()) for (const QVariant &item : data.toList())
ret.append(prettyPrintTraceData(item)); ret.append(prettyPrintTraceData(item));

View File

@@ -166,7 +166,7 @@ QVariant JsonFieldPage::Field::toSettings() const
JsonFieldPage::Field *JsonFieldPage::Field::parse(const QVariant &input, QString *errorMessage) JsonFieldPage::Field *JsonFieldPage::Field::parse(const QVariant &input, QString *errorMessage)
{ {
if (input.typeId() != QVariant::Map) { if (input.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Field is not an object."); *errorMessage = Tr::tr("Field is not an object.");
return nullptr; return nullptr;
} }
@@ -409,7 +409,7 @@ QDebug &operator<<(QDebug &debug, const JsonFieldPage::Field &field)
bool LabelField::parseData(const QVariant &data, QString *errorMessage) bool LabelField::parseData(const QVariant &data, QString *errorMessage)
{ {
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Label (\"%1\") data is not an object.").arg(name()); *errorMessage = Tr::tr("Label (\"%1\") data is not an object.").arg(name());
return false; return false;
} }
@@ -447,7 +447,7 @@ bool SpacerField::parseData(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Spacer (\"%1\") data is not an object.").arg(name()); *errorMessage = Tr::tr("Spacer (\"%1\") data is not an object.").arg(name());
return false; return false;
} }
@@ -492,7 +492,7 @@ bool LineEditField::parseData(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("LineEdit (\"%1\") data is not an object.").arg(name()); *errorMessage = Tr::tr("LineEdit (\"%1\") data is not an object.").arg(name());
return false; return false;
} }
@@ -689,7 +689,7 @@ bool TextEditField::parseData(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("TextEdit (\"%1\") data is not an object.") *errorMessage = Tr::tr("TextEdit (\"%1\") data is not an object.")
.arg(name()); .arg(name());
return false; return false;
@@ -772,7 +772,7 @@ bool PathChooserField::parseData(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("PathChooser data is not an object."); *errorMessage = Tr::tr("PathChooser data is not an object.");
return false; return false;
} }
@@ -877,7 +877,7 @@ bool CheckBoxField::parseData(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("CheckBox (\"%1\") data is not an object.").arg(name()); *errorMessage = Tr::tr("CheckBox (\"%1\") data is not an object.").arg(name());
return false; return false;
} }
@@ -966,12 +966,12 @@ QVariant CheckBoxField::toSettings() const
std::unique_ptr<QStandardItem> createStandardItemFromListItem(const QVariant &item, QString *errorMessage) std::unique_ptr<QStandardItem> createStandardItemFromListItem(const QVariant &item, QString *errorMessage)
{ {
if (item.typeId() == QVariant::List) { if (item.typeId() == QMetaType::QVariantList) {
*errorMessage = Tr::tr("No JSON lists allowed inside List items."); *errorMessage = Tr::tr("No JSON lists allowed inside List items.");
return {}; return {};
} }
auto standardItem = std::make_unique<QStandardItem>(); auto standardItem = std::make_unique<QStandardItem>();
if (item.typeId() == QVariant::Map) { if (item.typeId() == QMetaType::QVariantMap) {
QVariantMap tmp = item.toMap(); QVariantMap tmp = item.toMap();
const QString key = JsonWizardFactory::localizedString(consumeValue(tmp, "trKey", QString()).toString()); const QString key = JsonWizardFactory::localizedString(consumeValue(tmp, "trKey", QString()).toString());
const QVariant value = consumeValue(tmp, "value", key); const QVariant value = consumeValue(tmp, "value", key);
@@ -1001,7 +1001,7 @@ ListField::~ListField() = default;
bool ListField::parseData(const QVariant &data, QString *errorMessage) bool ListField::parseData(const QVariant &data, QString *errorMessage)
{ {
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("%1 (\"%2\") data is not an object.").arg(type(), name()); *errorMessage = Tr::tr("%1 (\"%2\") data is not an object.").arg(type(), name());
return false; return false;
} }
@@ -1027,7 +1027,7 @@ bool ListField::parseData(const QVariant &data, QString *errorMessage)
*errorMessage = Tr::tr("%1 (\"%2\") \"items\" missing.").arg(type(), name()); *errorMessage = Tr::tr("%1 (\"%2\") \"items\" missing.").arg(type(), name());
return false; return false;
} }
if (value.typeId() != QVariant::List) { if (value.typeId() != QMetaType::QVariantList) {
*errorMessage = Tr::tr("%1 (\"%2\") \"items\" is not a JSON list.").arg(type(), name()); *errorMessage = Tr::tr("%1 (\"%2\") \"items\" is not a JSON list.").arg(type(), name());
return false; return false;
} }

View File

@@ -124,7 +124,7 @@ QVector<JsonKitsPage::ConditionalFeature> JsonKitsPage::parseFeatures(const QVar
if (data.isNull()) if (data.isNull())
return result; return result;
if (data.type() != QVariant::List) { if (data.typeId() != QMetaType::QVariantList) {
if (errorMessage) if (errorMessage)
*errorMessage = Tr::tr("Feature list is set and not of type list."); *errorMessage = Tr::tr("Feature list is set and not of type list.");
return result; return result;
@@ -132,9 +132,9 @@ QVector<JsonKitsPage::ConditionalFeature> JsonKitsPage::parseFeatures(const QVar
const QList<QVariant> elements = data.toList(); const QList<QVariant> elements = data.toList();
for (const QVariant &element : elements) { for (const QVariant &element : elements) {
if (element.type() == QVariant::String) { if (element.typeId() == QMetaType::QString) {
result.append({ element.toString(), QVariant(true) }); result.append({ element.toString(), QVariant(true) });
} else if (element.type() == QVariant::Map) { } else if (element.typeId() == QMetaType::QVariantMap) {
const QVariantMap obj = element.toMap(); const QVariantMap obj = element.toMap();
const QString feature = obj.value(QLatin1String(KEY_FEATURE)).toString(); const QString feature = obj.value(QLatin1String(KEY_FEATURE)).toString();
if (feature.isEmpty()) { if (feature.isEmpty()) {

View File

@@ -219,14 +219,14 @@ QString JsonWizard::stringValue(const QString &n) const
if (!v.isValid()) if (!v.isValid())
return {}; return {};
if (v.typeId() == QVariant::String) { if (v.typeId() == QMetaType::QString) {
QString tmp = m_expander.expand(v.toString()); QString tmp = m_expander.expand(v.toString());
if (tmp.isEmpty()) if (tmp.isEmpty())
tmp = QString::fromLatin1(""); // Make sure isNull() is *not* true. tmp = QString::fromLatin1(""); // Make sure isNull() is *not* true.
return tmp; return tmp;
} }
if (v.typeId() == QVariant::StringList) if (v.typeId() == QMetaType::QStringList)
return stringListToArrayString(v.toStringList(), &m_expander); return stringListToArrayString(v.toStringList(), &m_expander);
return v.toString(); return v.toString();
@@ -277,7 +277,7 @@ QVariant JsonWizard::value(const QString &n) const
bool JsonWizard::boolFromVariant(const QVariant &v, MacroExpander *expander) bool JsonWizard::boolFromVariant(const QVariant &v, MacroExpander *expander)
{ {
if (v.typeId() == QVariant::String) { if (v.typeId() == QMetaType::QString) {
const QString tmp = expander->expand(v.toString()); const QString tmp = expander->expand(v.toString());
return !(tmp.isEmpty() || tmp == QLatin1String("false")); return !(tmp.isEmpty() || tmp == QLatin1String("false"));
} }
@@ -419,7 +419,7 @@ void JsonWizard::handleError(const QString &message)
QString JsonWizard::stringify(const QVariant &v) const QString JsonWizard::stringify(const QVariant &v) const
{ {
if (v.typeId() == QVariant::StringList) if (v.typeId() == QMetaType::QStringList)
return stringListToArrayString(v.toStringList(), &m_expander); return stringListToArrayString(v.toStringList(), &m_expander);
return Wizard::stringify(v); return Wizard::stringify(v);
} }

View File

@@ -147,7 +147,7 @@ static JsonWizardFactory::Generator parseGenerator(const QVariant &value, QStrin
{ {
JsonWizardFactory::Generator gen; JsonWizardFactory::Generator gen;
if (value.typeId() != QVariant::Map) { if (value.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Generator is not a object."); *errorMessage = Tr::tr("Generator is not a object.");
return gen; return gen;
} }
@@ -308,8 +308,8 @@ QVariant JsonWizardFactory::getDataValue(const QLatin1String &key, const QVarian
{ {
QVariant retVal = {}; QVariant retVal = {};
if ((valueSet.contains(key) && valueSet.value(key).typeId() == QVariant::Map) || if ((valueSet.contains(key) && valueSet.value(key).typeId() == QMetaType::QVariantMap) ||
(defaultValueSet.contains(key) && defaultValueSet.value(key).typeId() == QVariant::Map)) { (defaultValueSet.contains(key) && defaultValueSet.value(key).typeId() == QMetaType::QVariantMap)) {
retVal = mergeDataValueMaps(valueSet.value(key), defaultValueSet.value(key)); retVal = mergeDataValueMaps(valueSet.value(key), defaultValueSet.value(key));
} else { } else {
QVariant defaultValue = defaultValueSet.value(key, notExistValue); QVariant defaultValue = defaultValueSet.value(key, notExistValue);
@@ -335,7 +335,7 @@ std::pair<int, QStringList> JsonWizardFactory::screenSizeInfoFromPage(const QStr
return {}; return {};
const QVariant data = it->data; const QVariant data = it->data;
if (data.typeId() != QVariant::List) if (data.typeId() != QMetaType::QVariantList)
return {}; return {};
const QVariant screenFactorField = Utils::findOrDefault(data.toList(), const QVariant screenFactorField = Utils::findOrDefault(data.toList(),
@@ -344,11 +344,11 @@ std::pair<int, QStringList> JsonWizardFactory::screenSizeInfoFromPage(const QStr
return "ScreenFactor" == m["name"]; return "ScreenFactor" == m["name"];
}); });
if (screenFactorField.typeId() != QVariant::Map) if (screenFactorField.typeId() != QMetaType::QVariantMap)
return {}; return {};
const QVariant screenFactorData = screenFactorField.toMap()["data"]; const QVariant screenFactorData = screenFactorField.toMap()["data"];
if (screenFactorData.typeId() != QVariant::Map) if (screenFactorData.typeId() != QMetaType::QVariantMap)
return {}; return {};
const QVariantMap screenFactorDataMap = screenFactorData.toMap(); const QVariantMap screenFactorDataMap = screenFactorData.toMap();
@@ -376,7 +376,7 @@ JsonWizardFactory::Page JsonWizardFactory::parsePage(const QVariant &value, QStr
{ {
JsonWizardFactory::Page p; JsonWizardFactory::Page p;
if (value.typeId() != QVariant::Map) { if (value.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Page is not an object."); *errorMessage = Tr::tr("Page is not an object.");
return p; return p;
} }
@@ -423,9 +423,9 @@ JsonWizardFactory::Page JsonWizardFactory::parsePage(const QVariant &value, QStr
if (specifiedSubData.isNull()) if (specifiedSubData.isNull())
subData = defaultSubData; subData = defaultSubData;
else if (specifiedSubData.typeId() == QVariant::Map) else if (specifiedSubData.typeId() == QMetaType::QVariantMap)
subData = mergeDataValueMaps(specifiedSubData.toMap(), defaultSubData.toMap()); subData = mergeDataValueMaps(specifiedSubData.toMap(), defaultSubData.toMap());
else if (specifiedSubData.typeId() == QVariant::List) else if (specifiedSubData.typeId() == QMetaType::QVariantList)
subData = specifiedSubData; subData = specifiedSubData;
if (!factory->validateData(typeId, subData, errorMessage)) if (!factory->validateData(typeId, subData, errorMessage))
@@ -741,9 +741,9 @@ QList<QVariant> JsonWizardFactory::objectOrList(const QVariant &data, QString *e
QList<QVariant> result; QList<QVariant> result;
if (data.isNull()) if (data.isNull())
*errorMessage = Tr::tr("key not found."); *errorMessage = Tr::tr("key not found.");
else if (data.typeId() == QVariant::Map) else if (data.typeId() == QMetaType::QVariantMap)
result.append(data); result.append(data);
else if (data.typeId() == QVariant::List) else if (data.typeId() == QMetaType::QVariantList)
result = data.toList(); result = data.toList();
else else
*errorMessage = Tr::tr("Expected an object or a list."); *errorMessage = Tr::tr("Expected an object or a list.");
@@ -754,7 +754,7 @@ QString JsonWizardFactory::localizedString(const QVariant &value)
{ {
if (value.isNull()) if (value.isNull())
return {}; return {};
if (value.typeId() == QVariant::Map) { if (value.typeId() == QMetaType::QVariantMap) {
QVariantMap tmp = value.toMap(); QVariantMap tmp = value.toMap();
const QString locale = languageSetting().toLower(); const QString locale = languageSetting().toLower();
QStringList locales; QStringList locales;

View File

@@ -79,7 +79,7 @@ bool JsonWizardFileGenerator::setup(const QVariant &data, QString *errorMessage)
return false; return false;
for (const QVariant &d : list) { for (const QVariant &d : list) {
if (d.type() != QVariant::Map) { if (d.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Files data list entry is not an object."); *errorMessage = Tr::tr("Files data list entry is not an object.");
return false; return false;
} }

View File

@@ -114,7 +114,7 @@ WizardPage *FilePageFactory::create(JsonWizard *wizard, Id typeId, const QVarian
bool FilePageFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage) bool FilePageFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage)
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.typeId() != QVariant::Map || !data.toMap().isEmpty())) { if (!data.isNull() && (data.typeId() != QMetaType::QVariantMap || !data.toMap().isEmpty())) {
*errorMessage = Tr::tr("\"data\" for a \"File\" page needs to be unset or an empty object."); *errorMessage = Tr::tr("\"data\" for a \"File\" page needs to be unset or an empty object.");
return false; return false;
} }
@@ -174,7 +174,7 @@ bool KitsPageFactory::validateData(Id typeId, const QVariant &data, QString *err
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (data.isNull() || data.typeId() != QVariant::Map) { if (data.isNull() || data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("\"data\" must be a JSON object for \"Kits\" pages."); *errorMessage = Tr::tr("\"data\" must be a JSON object for \"Kits\" pages.");
return false; return false;
} }
@@ -242,7 +242,7 @@ bool ProjectPageFactory::validateData(Id typeId, const QVariant &data, QString *
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && data.typeId() != QVariant::Map) { if (!data.isNull() && data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("\"data\" must be empty or a JSON object for \"Project\" pages."); *errorMessage = Tr::tr("\"data\" must be empty or a JSON object for \"Project\" pages.");
return false; return false;
} }
@@ -297,7 +297,7 @@ WizardPage *SummaryPageFactory::create(JsonWizard *wizard, Id typeId, const QVar
bool SummaryPageFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage) bool SummaryPageFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage)
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.typeId() != QVariant::Map)) { if (!data.isNull() && (data.typeId() != QMetaType::QVariantMap)) {
*errorMessage = Tr::tr("\"data\" for a \"Summary\" page can be unset or needs to be an object."); *errorMessage = Tr::tr("\"data\" for a \"Summary\" page can be unset or needs to be an object.");
return false; return false;
} }

View File

@@ -46,7 +46,7 @@ bool JsonWizardScannerGenerator::setup(const QVariant &data, QString *errorMessa
if (data.isNull()) if (data.isNull())
return true; return true;
if (data.type() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Key is not an object."); *errorMessage = Tr::tr("Key is not an object.");
return false; return false;
} }

View File

@@ -26,10 +26,10 @@ inline QDebug &operator<<(QDebug &dbg, const QVariant &var)
case QMetaType::QStringList: case QMetaType::QStringList:
dbg << var.toList(); dbg << var.toList();
break; break;
case QVariant::List: case QMetaType::QVariantList:
dbg << var.toList(); dbg << var.toList();
break; break;
case QVariant::Map: case QMetaType::QVariantMap:
dbg << var.toMap(); dbg << var.toMap();
break; break;
default: { default: {

View File

@@ -1539,7 +1539,7 @@ Tasks EnvironmentKitAspectFactory::validate(const Kit *k) const
QTC_ASSERT(k, return result); QTC_ASSERT(k, return result);
const QVariant variant = k->value(EnvironmentKitAspect::id()); const QVariant variant = k->value(EnvironmentKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QVariant::List)) if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList))
result << BuildSystemTask(Task::Error, Tr::tr("The environment setting value is invalid.")); result << BuildSystemTask(Task::Error, Tr::tr("The environment setting value is invalid."));
return result; return result;
@@ -1550,7 +1550,7 @@ void EnvironmentKitAspectFactory::fix(Kit *k)
QTC_ASSERT(k, return); QTC_ASSERT(k, return);
const QVariant variant = k->value(EnvironmentKitAspect::id()); const QVariant variant = k->value(EnvironmentKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QVariant::List)) { if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList)) {
qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName())); qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName()));
EnvironmentKitAspect::setEnvironmentChanges(k, EnvironmentItems()); EnvironmentKitAspect::setEnvironmentChanges(k, EnvironmentItems());
} }

View File

@@ -401,7 +401,7 @@ void ArgumentsAspect::fromMap(const Store &map)
{ {
QVariant args = map.value(settingsKey()); QVariant args = map.value(settingsKey());
// Until 3.7 a QStringList was stored for Remote Linux // Until 3.7 a QStringList was stored for Remote Linux
if (args.typeId() == QVariant::StringList) if (args.typeId() == QMetaType::QStringList)
m_arguments = ProcessArgs::joinArgs(args.toStringList(), OsTypeLinux); m_arguments = ProcessArgs::joinArgs(args.toStringList(), OsTypeLinux);
else else
m_arguments = args.toString(); m_arguments = args.toString();

View File

@@ -453,7 +453,7 @@ Store UserFileVersion14Upgrader::upgrade(const Store &map)
{ {
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
if (it.value().typeId() == QVariant::Map) if (it.value().typeId() == QMetaType::QVariantMap)
result.insert(it.key(), variantFromStore(upgrade(storeFromVariant(it.value())))); result.insert(it.key(), variantFromStore(upgrade(storeFromVariant(it.value()))));
else if (it.key() == "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory" else if (it.key() == "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory"
|| it.key() == "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory" || it.key() == "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory"
@@ -709,13 +709,13 @@ Store UserFileVersion17Upgrader::upgrade(const Store &map)
QVariant UserFileVersion17Upgrader::process(const QVariant &entry) QVariant UserFileVersion17Upgrader::process(const QVariant &entry)
{ {
switch (entry.typeId()) { switch (entry.typeId()) {
case QVariant::List: { case QMetaType::QVariantList: {
QVariantList result; QVariantList result;
for (const QVariant &item : entry.toList()) for (const QVariant &item : entry.toList())
result.append(process(item)); result.append(process(item));
return result; return result;
} }
case QVariant::Map: { case QMetaType::QVariantMap: {
Store result = storeFromVariant(entry); Store result = storeFromVariant(entry);
for (Store::iterator i = result.begin(), end = result.end(); i != end; ++i) { for (Store::iterator i = result.begin(), end = result.end(); i != end; ++i) {
QVariant &v = i.value(); QVariant &v = i.value();
@@ -737,9 +737,9 @@ Store UserFileVersion18Upgrader::upgrade(const Store &map)
QVariant UserFileVersion18Upgrader::process(const QVariant &entry) QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
{ {
switch (entry.typeId()) { switch (entry.typeId()) {
case QVariant::List: case QMetaType::QVariantList:
return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process);
case QVariant::Map: { case QMetaType::QVariantMap: {
Store map = storeFromVariant(entry); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
@@ -793,10 +793,10 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList
static const KeyList dyldKeys = {"Qbs.RunConfiguration.UseDyldImageSuffix", static const KeyList dyldKeys = {"Qbs.RunConfiguration.UseDyldImageSuffix",
"QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix"}; "QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix"};
switch (entry.typeId()) { switch (entry.typeId()) {
case QVariant::List: case QMetaType::QVariantList:
return Utils::transform(entry.toList(), return Utils::transform(entry.toList(),
std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path)); std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path));
case QVariant::Map: { case QMetaType::QVariantMap: {
Store map = storeFromVariant(entry); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
@@ -836,9 +836,9 @@ Store UserFileVersion20Upgrader::upgrade(const Store &map)
QVariant UserFileVersion20Upgrader::process(const QVariant &entry) QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
{ {
switch (entry.typeId()) { switch (entry.typeId()) {
case QVariant::List: case QMetaType::QVariantList:
return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process);
case QVariant::Map: { case QMetaType::QVariantMap: {
Store map = storeFromVariant(entry); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
@@ -865,9 +865,9 @@ Store UserFileVersion21Upgrader::upgrade(const Store &map)
QVariant UserFileVersion21Upgrader::process(const QVariant &entry) QVariant UserFileVersion21Upgrader::process(const QVariant &entry)
{ {
switch (entry.typeId()) { switch (entry.typeId()) {
case QVariant::List: case QMetaType::QVariantList:
return Utils::transform(entry.toList(), &UserFileVersion21Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion21Upgrader::process);
case QVariant::Map: { case QMetaType::QVariantMap: {
Store entryMap = storeFromVariant(entry); Store entryMap = storeFromVariant(entry);
if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString() if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString()
== "DeployToGenericLinux") { == "DeployToGenericLinux") {

View File

@@ -60,7 +60,7 @@ QString toJSLiteral(const QVariant &val)
{ {
if (!val.isValid()) if (!val.isValid())
return QString("undefined"); return QString("undefined");
if (val.typeId() == QVariant::List || val.typeId() == QVariant::StringList) { if (val.typeId() == QMetaType::QVariantList || val.typeId() == QMetaType::QStringList) {
QString res; QString res;
const auto list = val.toList(); const auto list = val.toList();
for (const QVariant &child : list) { for (const QVariant &child : list) {
@@ -71,7 +71,7 @@ QString toJSLiteral(const QVariant &val)
res.append(']'); res.append(']');
return res; return res;
} }
if (val.typeId() == QVariant::Map) { if (val.typeId() == QMetaType::QVariantMap) {
const QVariantMap &vm = val.toMap(); const QVariantMap &vm = val.toMap();
QString str("{"); QString str("{");
for (auto it = vm.begin(); it != vm.end(); ++it) { for (auto it = vm.begin(); it != vm.end(); ++it) {
@@ -84,7 +84,7 @@ QString toJSLiteral(const QVariant &val)
} }
if (val.typeId() == QVariant::Bool) if (val.typeId() == QVariant::Bool)
return toJSLiteral(val.toBool()); return toJSLiteral(val.toBool());
if (val.canConvert(QVariant::String)) if (val.canConvert(QMetaType::QString))
return toJSLiteral(val.toString()); return toJSLiteral(val.toString());
return QString::fromLatin1("Unconvertible type %1").arg(QLatin1String(val.typeName())); return QString::fromLatin1("Unconvertible type %1").arg(QLatin1String(val.typeName()));
} }

View File

@@ -493,7 +493,7 @@ void DataStoreModelNode::assignCollectionToNode(AbstractView *view,
const QVariant currentTextRoleValue = textRoleProperty.value(); const QVariant currentTextRoleValue = textRoleProperty.value();
if (currentTextRoleValue.isValid() && !currentTextRoleValue.isNull()) { if (currentTextRoleValue.isValid() && !currentTextRoleValue.isNull()) {
if (currentTextRoleValue.type() == QVariant::String) { if (currentTextRoleValue.typeId() == QMetaType::QString) {
const QString currentTextRole = currentTextRoleValue.toString(); const QString currentTextRole = currentTextRoleValue.toString();
if (collectionHasColumn(collectionName, currentTextRole)) if (collectionHasColumn(collectionName, currentTextRole))
return; return;

View File

@@ -37,7 +37,7 @@ Type getProperty(const QmlJS::SimpleReaderNode *node, const QString &name)
{ {
if (auto property = node->property(name)) { if (auto property = node->property(name)) {
const auto &value = property.value; const auto &value = property.value;
if (value.type() == QVariant::List) { if (value.typeId() == QMetaType::QVariantList) {
auto list = value.toList(); auto list = value.toList();
if (list.size()) if (list.size())
return list.front().value<Type>(); return list.front().value<Type>();

View File

@@ -32,7 +32,7 @@ public:
if (value.typeId() == QVariant::Bool) if (value.typeId() == QVariant::Bool)
return value; return value;
if (value.typeId() == QVariant::String) { if (value.typeId() == QMetaType::QString) {
const QString text = value.toString(); const QString text = value.toString();
if (text == "true") if (text == "true")
return QVariant(true); return QVariant(true);

View File

@@ -60,10 +60,10 @@ static bool cleverColorCompare(const QVariant &value1, const QVariant &value2)
return c1.name() == c2.name() && c1.alpha() == c2.alpha(); return c1.name() == c2.name() && c1.alpha() == c2.alpha();
} }
if (value1.typeId() == QVariant::String && value2.typeId() == QVariant::Color) if (value1.typeId() == QMetaType::QString && value2.typeId() == QVariant::Color)
return cleverColorCompare(QVariant(QColor(value1.toString())), value2); return cleverColorCompare(QVariant(QColor(value1.toString())), value2);
if (value1.typeId() == QVariant::Color && value2.typeId() == QVariant::String) if (value1.typeId() == QVariant::Color && value2.typeId() == QMetaType::QString)
return cleverColorCompare(value1, QVariant(QColor(value2.toString()))); return cleverColorCompare(value1, QVariant(QColor(value2.toString())));
return false; return false;

View File

@@ -68,7 +68,7 @@ TimelineEditorDelegate::TimelineEditorDelegate(QWidget *parent)
if (factory == nullptr) { if (factory == nullptr) {
factory = new QItemEditorFactory; factory = new QItemEditorFactory;
QItemEditorCreatorBase *creator = new QItemEditorCreator<QComboBox>("currentText"); QItemEditorCreatorBase *creator = new QItemEditorCreator<QComboBox>("currentText");
factory->registerEditor(QVariant::String, creator); factory->registerEditor(QMetaType::QString, creator);
} }
setItemEditorFactory(factory); setItemEditorFactory(factory);

View File

@@ -272,7 +272,7 @@ inline QString deEscape(const QString &value)
inline QVariant deEscapeVariant(const QVariant &value) inline QVariant deEscapeVariant(const QVariant &value)
{ {
if (value.typeId() == QVariant::String) if (value.typeId() == QMetaType::QString)
return deEscape(value.toString()); return deEscape(value.toString());
return value; return value;
} }

View File

@@ -3504,7 +3504,7 @@ QVariant PropertyMetaInfo::castedValue(const QVariant &value) const
return variant; return variant;
} else if (typeId == QVariant::UserType && typeName == "var") { } else if (typeId == QVariant::UserType && typeName == "var") {
return variant; return variant;
} else if (variant.typeId() == QVariant::List) { } else if (variant.typeId() == QMetaType::QVariantList) {
// TODO: check the contents of the list // TODO: check the contents of the list
return variant; return variant;
} else if (typeName == "var" || typeName == "variant") { } else if (typeName == "var" || typeName == "variant") {

View File

@@ -41,7 +41,7 @@ PropertyName PropertyContainer::name() const
QVariant PropertyContainer::value() const QVariant PropertyContainer::value() const
{ {
if (m_value.typeId() == QVariant::String) if (m_value.typeId() == QMetaType::QString)
m_value = PropertyParser::read(m_type, m_value.toString()); m_value = PropertyParser::read(m_type, m_value.toString());
return m_value; return m_value;
} }

View File

@@ -593,7 +593,7 @@ QString RewriterView::auxiliaryDataAsQML() const
hasAuxData = true; hasAuxData = true;
QString strValue = value.toString(); QString strValue = value.toString();
auto metaType = static_cast<QMetaType::Type>(value.type()); const int metaType = value.typeId();
if (metaType == QMetaType::QString if (metaType == QMetaType::QString
|| metaType == QMetaType::QColor) { || metaType == QMetaType::QColor) {

View File

@@ -304,7 +304,7 @@ QString deEscape(const QString &value)
QVariant deEscapeVariant(const QVariant &value) QVariant deEscapeVariant(const QVariant &value)
{ {
if (value.typeId() == QVariant::String) if (value.typeId() == QMetaType::QString)
return deEscape(value.toString()); return deEscape(value.toString());
return value; return value;
} }
@@ -459,9 +459,9 @@ using json = nlohmann::json;
out = json::array({}); out = json::array({});
out.push_back(property.name); out.push_back(property.name);
out.push_back(property.type); out.push_back(property.type);
if (property.value.type() == QVariant::String) if (property.value.typeId() == QMetaType::QString)
out.push_back(Utils::PathString{property.value.toString()}); out.push_back(Utils::PathString{property.value.toString()});
else if (property.value.type() == QVariant::Int || property.value.type() == QVariant::LongLong) else if (property.value.typeId() == QMetaType::Int || property.value.typeId() == QMetaType::LongLong)
out.push_back(property.value.toLongLong()); out.push_back(property.value.toLongLong());
else else
out.push_back(property.value.toDouble()); out.push_back(property.value.toDouble());

View File

@@ -19,12 +19,12 @@ QWidget *SCAttributeItemDelegate::createEditor(QWidget *parent, const QStyleOpti
Q_UNUSED(option) Q_UNUSED(option)
switch (index.data(DataTypeRole).toInt()) { switch (index.data(DataTypeRole).toInt()) {
case QVariant::StringList: { case QMetaType::QStringList: {
auto combo = new QComboBox(parent); auto combo = new QComboBox(parent);
combo->setFocusPolicy(Qt::StrongFocus); combo->setFocusPolicy(Qt::StrongFocus);
return combo; return combo;
} }
case QVariant::String: { case QMetaType::QString: {
if (index.column() == 0) { if (index.column() == 0) {
auto edit = new QLineEdit(parent); auto edit = new QLineEdit(parent);
edit->setFocusPolicy(Qt::StrongFocus); edit->setFocusPolicy(Qt::StrongFocus);
@@ -52,7 +52,7 @@ void SCAttributeItemDelegate::updateEditorGeometry(QWidget *editor, const QStyle
void SCAttributeItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const void SCAttributeItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{ {
switch (index.data(DataTypeRole).toInt()) { switch (index.data(DataTypeRole).toInt()) {
case QVariant::StringList: { case QMetaType::QStringList: {
auto combo = qobject_cast<QComboBox*>(editor); auto combo = qobject_cast<QComboBox*>(editor);
if (combo) { if (combo) {
combo->clear(); combo->clear();

View File

@@ -84,7 +84,7 @@ QVariant SCAttributeItemModel::data(const QModelIndex &index, int role) const
} }
} else { } else {
if (bEditable) { if (bEditable) {
if (m_tag->tagType() > MetadataItem && m_tag->info()->attributes[index.row()].datatype == QVariant::StringList) if (m_tag->tagType() > MetadataItem && m_tag->info()->attributes[index.row()].datatype == QMetaType::QStringList)
return QString::fromLatin1(m_tag->info()->attributes[index.row()].value).split(";"); return QString::fromLatin1(m_tag->info()->attributes[index.row()].value).split(";");
else else
return m_tag->attribute(index.row()); return m_tag->attribute(index.row());
@@ -100,11 +100,11 @@ QVariant SCAttributeItemModel::data(const QModelIndex &index, int role) const
break; break;
case DataTypeRole: { case DataTypeRole: {
if (m_tag->tagType() == Metadata || m_tag->tagType() == MetadataItem) if (m_tag->tagType() == Metadata || m_tag->tagType() == MetadataItem)
return (int)QVariant::String; return (int)QMetaType::QString;
else if (index.column() == 1 && m_tag->info()->n_attributes > 0) else if (index.column() == 1 && m_tag->info()->n_attributes > 0)
return m_tag->info()->attributes[index.row()].datatype; return m_tag->info()->attributes[index.row()].datatype;
else else
return QVariant::Invalid; return {};
} }
case DataRole: { case DataRole: {
if (m_tag->info()->n_attributes > 0) if (m_tag->info()->n_attributes > 0)

View File

@@ -65,119 +65,119 @@ struct scxmltag_type_t
// Define tag-attributes // Define tag-attributes
const scxmltag_attribute_t scxml_scxml_attributes[] = { const scxmltag_attribute_t scxml_scxml_attributes[] = {
{"initial", nullptr, false, false, QVariant::String}, {"initial", nullptr, false, false, QMetaType::QString},
{"name", nullptr, false, true, QVariant::String}, {"name", nullptr, false, true, QMetaType::QString},
{"xmlns", "http://www.w3.org/2005/07/scxml", true, false, QVariant::String}, {"xmlns", "http://www.w3.org/2005/07/scxml", true, false, QMetaType::QString},
{"version", "1.0", true, false, QVariant::String}, {"version", "1.0", true, false, QMetaType::QString},
{"datamodel", nullptr, false, true, QVariant::String}, {"datamodel", nullptr, false, true, QMetaType::QString},
{"binding", "early;late", false, true, QVariant::StringList} {"binding", "early;late", false, true, QMetaType::QStringList}
}; };
const scxmltag_attribute_t scxml_state_attributes[] = { const scxmltag_attribute_t scxml_state_attributes[] = {
{"id", nullptr, false, true, QVariant::String}, {"id", nullptr, false, true, QMetaType::QString},
{"initial", nullptr, false, false, QVariant::String} {"initial", nullptr, false, false, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_parallel_attributes[] = { const scxmltag_attribute_t scxml_parallel_attributes[] = {
{"id", nullptr, false, true, QVariant::String} {"id", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_transition_attributes[] = { const scxmltag_attribute_t scxml_transition_attributes[] = {
{"event", nullptr, false, true, QVariant::String}, {"event", nullptr, false, true, QMetaType::QString},
{"cond", nullptr, false, true, QVariant::String}, {"cond", nullptr, false, true, QMetaType::QString},
{"target", nullptr, false, true, QVariant::String}, {"target", nullptr, false, true, QMetaType::QString},
{"type", "internal;external", false, true, QVariant::StringList} {"type", "internal;external", false, true, QMetaType::QStringList}
}; };
const scxmltag_attribute_t scxml_initialtransition_attributes[] = { const scxmltag_attribute_t scxml_initialtransition_attributes[] = {
{"target", nullptr, false, false, QVariant::String} {"target", nullptr, false, false, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_final_attributes[] = { const scxmltag_attribute_t scxml_final_attributes[] = {
{"id", nullptr, false, true, QVariant::String} {"id", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_history_attributes[] = { const scxmltag_attribute_t scxml_history_attributes[] = {
{"id", nullptr, false, true, QVariant::String}, {"id", nullptr, false, true, QMetaType::QString},
{"type", "shallow;deep", false, true, QVariant::StringList} {"type", "shallow;deep", false, true, QMetaType::QStringList}
}; };
const scxmltag_attribute_t scxml_raise_attributes[] = { const scxmltag_attribute_t scxml_raise_attributes[] = {
{"event", nullptr, true, true, QVariant::String} {"event", nullptr, true, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_if_attributes[] = { const scxmltag_attribute_t scxml_if_attributes[] = {
{"cond", nullptr, true, true, QVariant::String}, {"cond", nullptr, true, true, QMetaType::QString},
}; };
const scxmltag_attribute_t scxml_elseif_attributes[] = { const scxmltag_attribute_t scxml_elseif_attributes[] = {
{"cond", nullptr, true, true, QVariant::String} {"cond", nullptr, true, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_foreach_attributes[] = { const scxmltag_attribute_t scxml_foreach_attributes[] = {
{"array", nullptr, true, true, QVariant::String}, {"array", nullptr, true, true, QMetaType::QString},
{"item", nullptr, true, true, QVariant::String}, {"item", nullptr, true, true, QMetaType::QString},
{"index", nullptr, false, true, QVariant::String} {"index", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_log_attributes[] = { const scxmltag_attribute_t scxml_log_attributes[] = {
{"label", "", false, true, QVariant::String}, {"label", "", false, true, QMetaType::QString},
{"expr", nullptr, false, true, QVariant::String} {"expr", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_data_attributes[] = { const scxmltag_attribute_t scxml_data_attributes[] = {
{"id", nullptr, true, true, QVariant::String}, {"id", nullptr, true, true, QMetaType::QString},
{"src", nullptr, false, true, QVariant::String}, {"src", nullptr, false, true, QMetaType::QString},
{"expr", nullptr, false, true, QVariant::String} {"expr", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_assign_attributes[] = { const scxmltag_attribute_t scxml_assign_attributes[] = {
{"location", nullptr, true, true, QVariant::String}, {"location", nullptr, true, true, QMetaType::QString},
{"expr", nullptr, false, true, QVariant::String} {"expr", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_content_attributes[] = { const scxmltag_attribute_t scxml_content_attributes[] = {
{"expr", nullptr, false, true, QVariant::String} {"expr", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_param_attributes[] = { const scxmltag_attribute_t scxml_param_attributes[] = {
{"name", nullptr, true, true, QVariant::String}, {"name", nullptr, true, true, QMetaType::QString},
{"expr", nullptr, false, true, QVariant::String}, {"expr", nullptr, false, true, QMetaType::QString},
{"location", nullptr, false, true, QVariant::String} {"location", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_script_attributes[] = { const scxmltag_attribute_t scxml_script_attributes[] = {
{"src", nullptr, false, true, QVariant::String} {"src", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_send_attributes[] = { const scxmltag_attribute_t scxml_send_attributes[] = {
{"event", nullptr, false, true, QVariant::String}, {"event", nullptr, false, true, QMetaType::QString},
{"eventexpr", nullptr, false, true, QVariant::String}, {"eventexpr", nullptr, false, true, QMetaType::QString},
{"target", nullptr, false, true, QVariant::String}, {"target", nullptr, false, true, QMetaType::QString},
{"targetexpr", nullptr, false, true, QVariant::String}, {"targetexpr", nullptr, false, true, QMetaType::QString},
{"type", nullptr, false, true, QVariant::String}, {"type", nullptr, false, true, QMetaType::QString},
{"typeexpr", nullptr, false, true, QVariant::String}, {"typeexpr", nullptr, false, true, QMetaType::QString},
{"id", nullptr, false, true, QVariant::String}, {"id", nullptr, false, true, QMetaType::QString},
{"idlocation", nullptr, false, true, QVariant::String}, {"idlocation", nullptr, false, true, QMetaType::QString},
{"delay", nullptr, false, true, QVariant::String}, {"delay", nullptr, false, true, QMetaType::QString},
{"delayexpr", nullptr, false, true, QVariant::String}, {"delayexpr", nullptr, false, true, QMetaType::QString},
{"namelist", nullptr, false, true, QVariant::String} {"namelist", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_cancel_attributes[] = { const scxmltag_attribute_t scxml_cancel_attributes[] = {
{"sendid", nullptr, false, true, QVariant::String}, {"sendid", nullptr, false, true, QMetaType::QString},
{"sendidexpr", nullptr, false, true, QVariant::String} {"sendidexpr", nullptr, false, true, QMetaType::QString}
}; };
const scxmltag_attribute_t scxml_invoke_attributes[] = { const scxmltag_attribute_t scxml_invoke_attributes[] = {
{"type", nullptr, false, true, QVariant::String}, {"type", nullptr, false, true, QMetaType::QString},
{"typeexpr", nullptr, false, true, QVariant::String}, {"typeexpr", nullptr, false, true, QMetaType::QString},
{"src", nullptr, false, true, QVariant::String}, {"src", nullptr, false, true, QMetaType::QString},
{"srcexpr", nullptr, false, true, QVariant::String}, {"srcexpr", nullptr, false, true, QMetaType::QString},
{"id", nullptr, false, true, QVariant::String}, {"id", nullptr, false, true, QMetaType::QString},
{"idlocation", nullptr, false, true, QVariant::String}, {"idlocation", nullptr, false, true, QMetaType::QString},
{"namelist", nullptr, false, true, QVariant::String}, {"namelist", nullptr, false, true, QMetaType::QString},
{"autoforward", ";true;false", false, true, QVariant::StringList} {"autoforward", ";true;false", false, true, QMetaType::QStringList}
}; };
const scxmltag_type_t scxml_unknown = { const scxmltag_type_t scxml_unknown = {

View File

@@ -319,7 +319,7 @@ bool SquishFileGenerator::setup(const QVariant &data, QString *errorMessage)
if (data.isNull()) if (data.isNull())
return false; return false;
if (data.typeId() != QVariant::Map) { if (data.typeId() != QMetaType::QVariantMap) {
*errorMessage = Tr::tr("Key is not an object."); *errorMessage = Tr::tr("Key is not an object.");
return false; return false;
} }

View File

@@ -1638,7 +1638,7 @@ IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag)
const QList<IDocument *> documents = DocumentModel::openedDocuments(); const QList<IDocument *> documents = DocumentModel::openedDocuments();
for (IDocument *document : documents) { for (IDocument *document : documents) {
const QVariant tagPropertyValue = document->property(tagPropertyC); const QVariant tagPropertyValue = document->property(tagPropertyC);
if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag) if (tagPropertyValue.typeId() == QMetaType::QString && tagPropertyValue.toString() == tag)
return DocumentModel::editorsForDocument(document).constFirst(); return DocumentModel::editorsForDocument(document).constFirst();
} }
return nullptr; return nullptr;

View File

@@ -72,9 +72,9 @@ WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, const Q
QStringList args; QStringList args;
const QVariant argsVar = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); const QVariant argsVar = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS));
if (!argsVar.isNull()) { if (!argsVar.isNull()) {
if (argsVar.type() == QVariant::String) { if (argsVar.typeId() == QMetaType::QString) {
args << argsVar.toString(); args << argsVar.toString();
} else if (argsVar.type() == QVariant::List) { } else if (argsVar.typeId() == QMetaType::QVariantList) {
args = Utils::transform(argsVar.toList(), &QVariant::toString); args = Utils::transform(argsVar.toList(), &QVariant::toString);
} else { } else {
return nullptr; return nullptr;
@@ -101,7 +101,7 @@ WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, const Q
const QVariant &jobArgVar = job.value(QLatin1String(JOB_ARGUMENTS)); const QVariant &jobArgVar = job.value(QLatin1String(JOB_ARGUMENTS));
QStringList jobArgs; QStringList jobArgs;
if (!jobArgVar.isNull()) { if (!jobArgVar.isNull()) {
if (jobArgVar.type() == QVariant::List) if (jobArgVar.typeId() == QMetaType::QVariantList)
jobArgs = Utils::transform(jobArgVar.toList(), &QVariant::toString); jobArgs = Utils::transform(jobArgVar.toList(), &QVariant::toString);
else else
jobArgs << jobArgVar.toString(); jobArgs << jobArgVar.toString();
@@ -127,7 +127,7 @@ bool VcsCommandPageFactory::validateData(Id typeId, const QVariant &data, QStrin
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
QString em; QString em;
if (data.type() != QVariant::Map) if (data.typeId() != QMetaType::QVariantMap)
em = Tr::tr("\"data\" is no JSON object in \"VcsCommand\" page."); em = Tr::tr("\"data\" is no JSON object in \"VcsCommand\" page.");
if (em.isEmpty()) { if (em.isEmpty()) {
@@ -161,13 +161,13 @@ bool VcsCommandPageFactory::validateData(Id typeId, const QVariant &data, QStrin
} }
const QVariant extra = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); const QVariant extra = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS));
if (!extra.isNull() && extra.type() != QVariant::String && extra.type() != QVariant::List) { if (!extra.isNull() && extra.typeId() != QMetaType::QString && extra.typeId() != QMetaType::QVariantList) {
em = Tr::tr("\"%1\" in \"data\" section of \"VcsCommand\" page has unexpected type (unset, String or List).") em = Tr::tr("\"%1\" in \"data\" section of \"VcsCommand\" page has unexpected type (unset, String or List).")
.arg(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); .arg(QLatin1String(VCSCOMMAND_EXTRA_ARGS));
} }
const QVariant jobs = tmp.value(QLatin1String(VCSCOMMAND_JOBS)); const QVariant jobs = tmp.value(QLatin1String(VCSCOMMAND_JOBS));
if (!jobs.isNull() && extra.type() != QVariant::List) { if (!jobs.isNull() && extra.typeId() != QMetaType::QVariantList) {
em = Tr::tr("\"%1\" in \"data\" section of \"VcsCommand\" page has unexpected type (unset or List).") em = Tr::tr("\"%1\" in \"data\" section of \"VcsCommand\" page has unexpected type (unset or List).")
.arg(QLatin1String(VCSCOMMAND_JOBS)); .arg(QLatin1String(VCSCOMMAND_JOBS));
} }
@@ -178,7 +178,7 @@ bool VcsCommandPageFactory::validateData(Id typeId, const QVariant &data, QStrin
em = Tr::tr("Job in \"VcsCommand\" page is empty."); em = Tr::tr("Job in \"VcsCommand\" page is empty.");
break; break;
} }
if (j.type() != QVariant::Map) { if (j.typeId() != QMetaType::QVariantMap) {
em = Tr::tr("Job in \"VcsCommand\" page is not an object."); em = Tr::tr("Job in \"VcsCommand\" page is not an object.");
break; break;
} }

View File

@@ -56,7 +56,7 @@ bool VcsConfigurationPageFactory::validateData(Id typeId, const QVariant &data,
{ {
QTC_ASSERT(canCreate(typeId), return false); QTC_ASSERT(canCreate(typeId), return false);
if (data.isNull() || data.type() != QVariant::Map) { if (data.isNull() || data.typeId() != QMetaType::QVariantMap) {
//: Do not translate "VcsConfiguration", because it is the id of a page. //: Do not translate "VcsConfiguration", because it is the id of a page.
*errorMessage = ProjectExplorer::Tr::tr("\"data\" must be a JSON object for \"VcsConfiguration\" pages."); *errorMessage = ProjectExplorer::Tr::tr("\"data\" must be a JSON object for \"VcsConfiguration\" pages.");
return false; return false;

View File

@@ -372,7 +372,7 @@ void ObjectNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentIn
QVariant ObjectNodeInstance::convertSpecialCharacter(const QVariant& value) const QVariant ObjectNodeInstance::convertSpecialCharacter(const QVariant& value) const
{ {
QVariant specialCharacterConvertedValue = value; QVariant specialCharacterConvertedValue = value;
if (value.typeId() == QVariant::String) { if (value.typeId() == QMetaType::QString) {
QString string = value.toString(); QString string = value.toString();
string.replace(QLatin1String("\\n"), QLatin1String("\n")); string.replace(QLatin1String("\\n"), QLatin1String("\n"));
string.replace(QLatin1String("\\t"), QLatin1String("\t")); string.replace(QLatin1String("\\t"), QLatin1String("\t"));

View File

@@ -604,7 +604,7 @@ static QString qmlDesignerRCPath()
QVariant fixResourcePaths(const QVariant &value) QVariant fixResourcePaths(const QVariant &value)
{ {
if (value.typeId() == QVariant::Url) { if (value.typeId() == QMetaType::QUrl) {
const QUrl url = value.toUrl(); const QUrl url = value.toUrl();
if (url.scheme() == QLatin1String("qrc")) { if (url.scheme() == QLatin1String("qrc")) {
const QString path = QLatin1String("qrc:") + url.path(); const QString path = QLatin1String("qrc:") + url.path();
@@ -625,7 +625,7 @@ QVariant fixResourcePaths(const QVariant &value)
} }
} }
} }
if (value.typeId() == QVariant::String) { if (value.typeId() == QMetaType::QString) {
const QString str = value.toString(); const QString str = value.toString();
if (str.contains(QLatin1String("qrc:"))) { if (str.contains(QLatin1String("qrc:"))) {
if (!qmlDesignerRCPath().isEmpty()) { if (!qmlDesignerRCPath().isEmpty()) {

View File

@@ -698,17 +698,17 @@ void tst_TestCore::testRewriterDynamicProperties()
QCOMPARE(rootModelNode.properties().count(), 18); QCOMPARE(rootModelNode.properties().count(), 18);
QVERIFY(rootModelNode.hasVariantProperty("i")); QVERIFY(rootModelNode.hasVariantProperty("i"));
QCOMPARE(rootModelNode.variantProperty("i").dynamicTypeName(), QmlDesigner::TypeName("int")); QCOMPARE(rootModelNode.variantProperty("i").dynamicTypeName(), QmlDesigner::TypeName("int"));
QCOMPARE(rootModelNode.variantProperty("i").value().type(), QVariant::Int); QCOMPARE(rootModelNode.variantProperty("i").value().typeId(), QMetaType::Int);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("i").value().toInt(), 0); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("i").value().toInt(), 0);
QVERIFY(rootModelNode.hasVariantProperty("ii")); QVERIFY(rootModelNode.hasVariantProperty("ii"));
QCOMPARE(rootModelNode.variantProperty("ii").dynamicTypeName(), QmlDesigner::TypeName("int")); QCOMPARE(rootModelNode.variantProperty("ii").dynamicTypeName(), QmlDesigner::TypeName("int"));
QCOMPARE(rootModelNode.variantProperty("ii").value().type(), QVariant::Int); QCOMPARE(rootModelNode.variantProperty("ii").value().typeId(), QMetaType::Int);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("ii").value().toInt(), 1); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("ii").value().toInt(), 1);
QVERIFY(rootModelNode.hasVariantProperty("b")); QVERIFY(rootModelNode.hasVariantProperty("b"));
QCOMPARE(rootModelNode.variantProperty("b").dynamicTypeName(), QmlDesigner::TypeName("bool")); QCOMPARE(rootModelNode.variantProperty("b").dynamicTypeName(), QmlDesigner::TypeName("bool"));
QCOMPARE(rootModelNode.variantProperty("b").value().type(), QVariant::Bool); QCOMPARE(rootModelNode.variantProperty("b").value().typeId(), QMetaType::Bool);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("b").value().toBool(), false); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("b").value().toBool(), false);
QVERIFY(rootModelNode.hasVariantProperty("bb")); QVERIFY(rootModelNode.hasVariantProperty("bb"));
@@ -716,7 +716,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("d")); QVERIFY(rootModelNode.hasVariantProperty("d"));
QCOMPARE(rootModelNode.variantProperty("d").dynamicTypeName(), QmlDesigner::TypeName("double")); QCOMPARE(rootModelNode.variantProperty("d").dynamicTypeName(), QmlDesigner::TypeName("double"));
QCOMPARE(rootModelNode.variantProperty("d").value().type(), QVariant::Double); QCOMPARE(rootModelNode.variantProperty("d").value().typeId(), QMetaType::Double);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("d").value().toDouble(), 0.0); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("d").value().toDouble(), 0.0);
QVERIFY(rootModelNode.hasVariantProperty("dd")); QVERIFY(rootModelNode.hasVariantProperty("dd"));
@@ -724,7 +724,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("r")); QVERIFY(rootModelNode.hasVariantProperty("r"));
QCOMPARE(rootModelNode.variantProperty("r").dynamicTypeName(), QmlDesigner::TypeName("real")); QCOMPARE(rootModelNode.variantProperty("r").dynamicTypeName(), QmlDesigner::TypeName("real"));
QCOMPARE(rootModelNode.variantProperty("r").value().type(), QVariant::Double); QCOMPARE(rootModelNode.variantProperty("r").value().typeId(), QMetaType::Double);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("r").value().toDouble(), 0.0); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("r").value().toDouble(), 0.0);
QVERIFY(rootModelNode.hasVariantProperty("rr")); QVERIFY(rootModelNode.hasVariantProperty("rr"));
@@ -732,7 +732,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("s")); QVERIFY(rootModelNode.hasVariantProperty("s"));
QCOMPARE(rootModelNode.variantProperty("s").dynamicTypeName(), QmlDesigner::TypeName("string")); QCOMPARE(rootModelNode.variantProperty("s").dynamicTypeName(), QmlDesigner::TypeName("string"));
QCOMPARE(rootModelNode.variantProperty("s").value().type(), QVariant::String); QCOMPARE(rootModelNode.variantProperty("s").value().typeId(), QMetaType::QString);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("s").value().toString(), QString()); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("s").value().toString(), QString());
QVERIFY(rootModelNode.hasVariantProperty("ss")); QVERIFY(rootModelNode.hasVariantProperty("ss"));
@@ -740,7 +740,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("u")); QVERIFY(rootModelNode.hasVariantProperty("u"));
QCOMPARE(rootModelNode.variantProperty("u").dynamicTypeName(), QmlDesigner::TypeName("url")); QCOMPARE(rootModelNode.variantProperty("u").dynamicTypeName(), QmlDesigner::TypeName("url"));
QCOMPARE(rootModelNode.variantProperty("u").value().type(), QVariant::Url); QCOMPARE(rootModelNode.variantProperty("u").value().typeId(), QMetaType::QUrl);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("u").value().toUrl(), QUrl()); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("u").value().toUrl(), QUrl());
QVERIFY(rootModelNode.hasVariantProperty("uu")); QVERIFY(rootModelNode.hasVariantProperty("uu"));
@@ -748,7 +748,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("c")); QVERIFY(rootModelNode.hasVariantProperty("c"));
QCOMPARE(rootModelNode.variantProperty("c").dynamicTypeName(), QmlDesigner::TypeName("color")); QCOMPARE(rootModelNode.variantProperty("c").dynamicTypeName(), QmlDesigner::TypeName("color"));
QCOMPARE(rootModelNode.variantProperty("c").value().type(), QVariant::Color); QCOMPARE(rootModelNode.variantProperty("c").value().typeId(), QMetaType::QColor);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("c").value().value<QColor>(), QColor()); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("c").value().value<QColor>(), QColor());
QVERIFY(rootModelNode.hasVariantProperty("cc")); QVERIFY(rootModelNode.hasVariantProperty("cc"));
@@ -756,7 +756,7 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("t")); QVERIFY(rootModelNode.hasVariantProperty("t"));
QCOMPARE(rootModelNode.variantProperty("t").dynamicTypeName(), QmlDesigner::TypeName("date")); QCOMPARE(rootModelNode.variantProperty("t").dynamicTypeName(), QmlDesigner::TypeName("date"));
QCOMPARE(rootModelNode.variantProperty("t").value().type(), QVariant::Date); QCOMPARE(rootModelNode.variantProperty("t").value().typeId(), QMetaType::QDate);
QCOMPARE(testRewriterView1->rootModelNode().variantProperty("t").value().value<QDate>(), QDate()); QCOMPARE(testRewriterView1->rootModelNode().variantProperty("t").value().value<QDate>(), QDate());
QVERIFY(rootModelNode.hasVariantProperty("tt")); QVERIFY(rootModelNode.hasVariantProperty("tt"));
@@ -764,8 +764,8 @@ void tst_TestCore::testRewriterDynamicProperties()
QVERIFY(rootModelNode.hasVariantProperty("v")); QVERIFY(rootModelNode.hasVariantProperty("v"));
QCOMPARE(rootModelNode.variantProperty("v").dynamicTypeName(), QmlDesigner::TypeName("variant")); QCOMPARE(rootModelNode.variantProperty("v").dynamicTypeName(), QmlDesigner::TypeName("variant"));
const int type = rootModelNode.variantProperty("v").value().type(); const int type = rootModelNode.variantProperty("v").value().typeId();
QCOMPARE(type, QMetaType::type("QVariant")); QCOMPARE(type, QMetaType::fromName("QVariant").id());
QVERIFY(rootModelNode.hasVariantProperty("vv")); QVERIFY(rootModelNode.hasVariantProperty("vv"));
const QString inThere = testRewriterView1->rootModelNode().variantProperty("vv").value().value<QString>(); const QString inThere = testRewriterView1->rootModelNode().variantProperty("vv").value().value<QString>();
@@ -3872,8 +3872,8 @@ void tst_TestCore::testRewriterPreserveType()
QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle"));
ModelNode textNode = rootNode.directSubModelNodes().first(); ModelNode textNode = rootNode.directSubModelNodes().first();
QCOMPARE(QVariant::Bool, textNode.variantProperty("font.bold").value().type()); QCOMPARE(QMetaType::Bool, textNode.variantProperty("font.bold").value().typeId());
QCOMPARE(QVariant::Double, textNode.variantProperty("font.pointSize").value().type()); QCOMPARE(QMetaType::Double, textNode.variantProperty("font.pointSize").value().typeId());
textNode.variantProperty("font.bold").setValue(QVariant(false)); textNode.variantProperty("font.bold").setValue(QVariant(false));
textNode.variantProperty("font.bold").setValue(QVariant(true)); textNode.variantProperty("font.bold").setValue(QVariant(true));
textNode.variantProperty("font.pointSize").setValue(QVariant(13.0)); textNode.variantProperty("font.pointSize").setValue(QVariant(13.0));
@@ -3883,8 +3883,8 @@ void tst_TestCore::testRewriterPreserveType()
newTextNode.variantProperty("font.bold").setValue(QVariant(true)); newTextNode.variantProperty("font.bold").setValue(QVariant(true));
newTextNode.variantProperty("font.pointSize").setValue(QVariant(13.0)); newTextNode.variantProperty("font.pointSize").setValue(QVariant(13.0));
QCOMPARE(QVariant::Bool, newTextNode.variantProperty("font.bold").value().type()); QCOMPARE(QMetaType::Bool, newTextNode.variantProperty("font.bold").value().typeId());
QCOMPARE(QVariant::Double, newTextNode.variantProperty("font.pointSize").value().type()); QCOMPARE(QMetaType::Double, newTextNode.variantProperty("font.pointSize").value().typeId());
} }
void tst_TestCore::testRewriterForArrayMagic() void tst_TestCore::testRewriterForArrayMagic()
@@ -6957,9 +6957,9 @@ void tst_TestCore::testModelPropertyValueTypes()
ModelNode rootModelNode(testRewriterView1->rootModelNode()); ModelNode rootModelNode(testRewriterView1->rootModelNode());
QVERIFY(rootModelNode.isValid()); QVERIFY(rootModelNode.isValid());
QCOMPARE(rootModelNode.variantProperty("width").value().type(), QVariant::Double); QCOMPARE(rootModelNode.variantProperty("width").value().typeId(), QMetaType::Double);
QCOMPARE(rootModelNode.variantProperty("radius").value().type(), QVariant::Double); QCOMPARE(rootModelNode.variantProperty("radius").value().typeId(), QMetaType::Double);
QCOMPARE(rootModelNode.variantProperty("color").value().type(), QVariant::Color); QCOMPARE(rootModelNode.variantProperty("color").value().typeId(), QMetaType::QColor);
} }
void tst_TestCore::testModelNodeInHierarchy() void tst_TestCore::testModelNodeInHierarchy()
@@ -8963,18 +8963,18 @@ void tst_TestCore::loadGradient()
QCOMPARE(pOne.id(), QString("pOne")); QCOMPARE(pOne.id(), QString("pOne"));
QCOMPARE(pOne.directSubModelNodes().size(), 0); QCOMPARE(pOne.directSubModelNodes().size(), 0);
QCOMPARE(pOne.propertyNames().size(), 2); QCOMPARE(pOne.propertyNames().size(), 2);
QCOMPARE(pOne.variantProperty("position").value().type(), QVariant::Double); QCOMPARE(pOne.variantProperty("position").value().typeId(), QMetaType::Double);
QCOMPARE(pOne.variantProperty("position").value().toDouble(), 0.0); QCOMPARE(pOne.variantProperty("position").value().toDouble(), 0.0);
QCOMPARE(pOne.variantProperty("color").value().type(), QVariant::Color); QCOMPARE(pOne.variantProperty("color").value().typeId(), QMetaType::QColor);
QCOMPARE(pOne.variantProperty("color").value().value<QColor>(), QColor("lightsteelblue")); QCOMPARE(pOne.variantProperty("color").value().value<QColor>(), QColor("lightsteelblue"));
QCOMPARE(pTwo.type(), QmlDesigner::TypeName("QtQuick.GradientStop")); QCOMPARE(pTwo.type(), QmlDesigner::TypeName("QtQuick.GradientStop"));
QCOMPARE(pTwo.id(), QString("pTwo")); QCOMPARE(pTwo.id(), QString("pTwo"));
QCOMPARE(pTwo.directSubModelNodes().size(), 0); QCOMPARE(pTwo.directSubModelNodes().size(), 0);
QCOMPARE(pTwo.propertyNames().size(), 2); QCOMPARE(pTwo.propertyNames().size(), 2);
QCOMPARE(pTwo.variantProperty("position").value().type(), QVariant::Double); QCOMPARE(pTwo.variantProperty("position").value().typeId(), QMetaType::Double);
QCOMPARE(pTwo.variantProperty("position").value().toDouble(), 1.0); QCOMPARE(pTwo.variantProperty("position").value().toDouble(), 1.0);
QCOMPARE(pTwo.variantProperty("color").value().type(), QVariant::Color); QCOMPARE(pTwo.variantProperty("color").value().typeId(), QMetaType::QColor);
QCOMPARE(pTwo.variantProperty("color").value().value<QColor>(), QColor("blue")); QCOMPARE(pTwo.variantProperty("color").value().value<QColor>(), QColor("blue"));
} }
@@ -9003,18 +9003,18 @@ void tst_TestCore::loadGradient()
QCOMPARE(nOne.id(), QString("nOne")); QCOMPARE(nOne.id(), QString("nOne"));
QCOMPARE(nOne.directSubModelNodes().size(), 0); QCOMPARE(nOne.directSubModelNodes().size(), 0);
QCOMPARE(nOne.propertyNames().size(), 2); QCOMPARE(nOne.propertyNames().size(), 2);
QCOMPARE(nOne.variantProperty("position").value().type(), QVariant::Double); QCOMPARE(nOne.variantProperty("position").value().typeId(), QMetaType::Double);
QCOMPARE(nOne.variantProperty("position").value().toDouble(), 0.0); QCOMPARE(nOne.variantProperty("position").value().toDouble(), 0.0);
QCOMPARE(nOne.variantProperty("color").value().type(), QVariant::Color); QCOMPARE(nOne.variantProperty("color").value().typeId(), QMetaType::QColor);
QCOMPARE(nOne.variantProperty("color").value().value<QColor>(), QColor("blue")); QCOMPARE(nOne.variantProperty("color").value().value<QColor>(), QColor("blue"));
QCOMPARE(nTwo.type(), QmlDesigner::TypeName("QtQuick.GradientStop")); QCOMPARE(nTwo.type(), QmlDesigner::TypeName("QtQuick.GradientStop"));
QCOMPARE(nTwo.id(), QString("nTwo")); QCOMPARE(nTwo.id(), QString("nTwo"));
QCOMPARE(nTwo.directSubModelNodes().size(), 0); QCOMPARE(nTwo.directSubModelNodes().size(), 0);
QCOMPARE(nTwo.propertyNames().size(), 2); QCOMPARE(nTwo.propertyNames().size(), 2);
QCOMPARE(nTwo.variantProperty("position").value().type(), QVariant::Double); QCOMPARE(nTwo.variantProperty("position").value().typeId(), QMetaType::Double);
QCOMPARE(nTwo.variantProperty("position").value().toDouble(), 1.0); QCOMPARE(nTwo.variantProperty("position").value().toDouble(), 1.0);
QCOMPARE(nTwo.variantProperty("color").value().type(), QVariant::Color); QCOMPARE(nTwo.variantProperty("color").value().typeId(), QMetaType::QColor);
QCOMPARE(nTwo.variantProperty("color").value().value<QColor>(), QColor("lightsteelblue")); QCOMPARE(nTwo.variantProperty("color").value().value<QColor>(), QColor("lightsteelblue"));
} }
} }

View File

@@ -61,18 +61,18 @@ void PersistentSettingsTest::tst_readwrite()
auto found = restored.find(it.key()); auto found = restored.find(it.key());
QVERIFY(found != restoredEnd); QVERIFY(found != restoredEnd);
QVERIFY(found.value().isValid()); QVERIFY(found.value().isValid());
if (it.value().type() == QVariant::List) { if (it.value().typeId() == QMetaType::QVariantList) {
const QVariantList origList = it.value().toList(); const QVariantList origList = it.value().toList();
const QVariantList foundList = found.value().toList(); const QVariantList foundList = found.value().toList();
QCOMPARE(foundList.size(), origList.size()); QCOMPARE(foundList.size(), origList.size());
for (int i = 0, vEnd = foundList.size(); i < vEnd; ++i) { for (int i = 0, vEnd = foundList.size(); i < vEnd; ++i) {
if (foundList.at(i).type() == QVariant::Rect) if (foundList.at(i).typeId() == QMetaType::QRect)
qDebug() << foundList.at(i).toRect() << origList.at(i).toRect(); qDebug() << foundList.at(i).toRect() << origList.at(i).toRect();
QCOMPARE(foundList.at(i), origList.at(i)); QCOMPARE(foundList.at(i), origList.at(i));
} }
} }
if (it.value().type() == QVariant::Rect) if (it.value().typeId() == QMetaType::QRect)
qDebug() << found.value().toRect() << "vs" << it.value().toRect(); qDebug() << found.value().toRect() << "vs" << it.value().toRect();
QCOMPARE(found.value(), it.value()); QCOMPARE(found.value(), it.value());
} }

View File

@@ -74,7 +74,7 @@ protected:
{ {
if (auto property = node->property(name)) { if (auto property = node->property(name)) {
const auto &value = property.value; const auto &value = property.value;
if (value.type() == QVariant::List) { if (value.typeId() == QMetaType::QVariantList) {
auto list = value.toList(); auto list = value.toList();
if (list.size()) if (list.size())
return list.front().value<Type>(); return list.front().value<Type>();

View File

@@ -511,7 +511,7 @@ TEST_F(ListModelEditor, convert_string_float_to_float)
model.setValue(1, 1, "25.5"); model.setValue(1, 1, "25.5");
ASSERT_THAT(element2.variantProperty("name").value().value<double>(), 25.5); ASSERT_THAT(element2.variantProperty("name").value().value<double>(), 25.5);
ASSERT_THAT(element2.variantProperty("name").value().type(), QVariant::Double); ASSERT_THAT(element2.variantProperty("name").value().typeId(), QMetaType::Double);
} }
TEST_F(ListModelEditor, convert_string_integer_to_double) TEST_F(ListModelEditor, convert_string_integer_to_double)
@@ -521,7 +521,7 @@ TEST_F(ListModelEditor, convert_string_integer_to_double)
model.setValue(1, 1, "25"); model.setValue(1, 1, "25");
ASSERT_THAT(element2.variantProperty("name").value().value<double>(), 25); ASSERT_THAT(element2.variantProperty("name").value().value<double>(), 25);
ASSERT_THAT(element2.variantProperty("name").value().type(), QVariant::Double); ASSERT_THAT(element2.variantProperty("name").value().typeId(), QMetaType::Double);
} }
TEST_F(ListModelEditor, dont_convert_string_to_number) TEST_F(ListModelEditor, dont_convert_string_to_number)
@@ -531,7 +531,7 @@ TEST_F(ListModelEditor, dont_convert_string_to_number)
model.setValue(1, 1, "hello"); model.setValue(1, 1, "hello");
ASSERT_THAT(element2.variantProperty("name").value().value<QString>(), u"hello"); ASSERT_THAT(element2.variantProperty("name").value().value<QString>(), u"hello");
ASSERT_THAT(element2.variantProperty("name").value().type(), QVariant::String); ASSERT_THAT(element2.variantProperty("name").value().typeId(), QMetaType::QString);
} }
TEST_F(ListModelEditor, empty_strings_removes_property) TEST_F(ListModelEditor, empty_strings_removes_property)
@@ -558,7 +558,7 @@ TEST_F(ListModelEditor, dispay_value_is_changed_to_double)
model.setValue(1, 1, "25.5"); model.setValue(1, 1, "25.5");
ASSERT_THAT(displayValues()[1][1].type(), QVariant::Double); ASSERT_THAT(displayValues()[1][1].typeId(), QMetaType::Double);
} }
TEST_F(ListModelEditor, string_dispay_value_is_not_changed) TEST_F(ListModelEditor, string_dispay_value_is_not_changed)
@@ -567,7 +567,7 @@ TEST_F(ListModelEditor, string_dispay_value_is_not_changed)
model.setValue(1, 1, "25.5a"); model.setValue(1, 1, "25.5a");
ASSERT_THAT(displayValues()[1][1].type(), QVariant::String); ASSERT_THAT(displayValues()[1][1].typeId(), QMetaType::QString);
} }
TEST_F(ListModelEditor, set_invalid_to_dark_yellow_background_color) TEST_F(ListModelEditor, set_invalid_to_dark_yellow_background_color)