diff options
39 files changed, 216 insertions, 214 deletions
diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp index f190ad86b1..b6468d760f 100644 --- a/src/imports/labsmodels/qqmltablemodel.cpp +++ b/src/imports/labsmodels/qqmltablemodel.cpp @@ -271,7 +271,7 @@ QQmlTableModel::ColumnRoleMetadata QQmlTableModel::fetchColumnRoleData(const QSt if (columnRoleGetter.isString()) { // The role is set as a string, so we assume the row is a simple object. - if (firstRow.type() != QVariant::Map) { + if (firstRow.userType() != QMetaType::QVariantMap) { qmlWarning(this).quote() << "expected row for role " << roleNameKey << " of TableModelColumn at index " << columnIndex << " to be a simple object, but it's " @@ -284,7 +284,7 @@ QQmlTableModel::ColumnRoleMetadata QQmlTableModel::fetchColumnRoleData(const QSt roleData.isStringRole = true; roleData.name = rolePropertyName; - roleData.type = roleProperty.type(); + roleData.type = roleProperty.userType(); roleData.typeName = QString::fromLatin1(roleProperty.typeName()); } else if (columnRoleGetter.isCallable()) { // The role is provided via a function, which means the row is complex and @@ -296,7 +296,7 @@ QQmlTableModel::ColumnRoleMetadata QQmlTableModel::fetchColumnRoleData(const QSt // We don't know the property name since it's provided through the function. // roleData.name = ??? roleData.isStringRole = false; - roleData.type = cellData.type(); + roleData.type = cellData.userType(); roleData.typeName = QString::fromLatin1(cellData.typeName()); } else { // Invalid role. @@ -326,7 +326,7 @@ void QQmlTableModel::fetchColumnMetadata() for (const int builtInRoleKey : builtInRoleKeys) { const QString builtInRoleName = supportedRoleNames.value(builtInRoleKey); ColumnRoleMetadata roleData = fetchColumnRoleData(builtInRoleName, column, columnIndex); - if (roleData.type == QVariant::Invalid) { + if (roleData.type == QMetaType::UnknownType) { // This built-in role was not specified in this column. continue; } @@ -847,7 +847,7 @@ bool QQmlTableModel::setData(const QModelIndex &index, const QVariant &value, in // If the value set is not of the expected type, we can try to convert it automatically. const ColumnRoleMetadata roleData = columnMetadata.roles.value(roleName); QVariant effectiveValue = value; - if (value.type() != roleData.type) { + if (value.userType() != roleData.type) { if (!value.canConvert(int(roleData.type))) { qmlWarning(this).nospace() << "setData(): the value " << value << " set at row " << row << " column " << column << " with role " << roleName @@ -933,7 +933,7 @@ QQmlTableModel::ColumnRoleMetadata::ColumnRoleMetadata() } QQmlTableModel::ColumnRoleMetadata::ColumnRoleMetadata( - bool isStringRole, const QString &name, QVariant::Type type, const QString &typeName) : + bool isStringRole, const QString &name, int type, const QString &typeName) : isStringRole(isStringRole), name(name), type(type), @@ -995,7 +995,7 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro const QVariant rowAsVariant = operation == SetRowsOperation ? row : row.value<QJSValue>().toVariant(); - if (rowAsVariant.type() != QVariant::Map) { + if (rowAsVariant.userType() != QMetaType::QVariantMap) { qmlWarning(this) << functionName << ": row manipulation functions " << "do not support complex rows (row index: " << rowIndex << ")"; return false; @@ -1028,7 +1028,7 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro } const QVariant rolePropertyValue = rowAsMap.value(roleData.name); - if (rolePropertyValue.type() != roleData.type) { + if (rolePropertyValue.userType() != roleData.type) { qmlWarning(this).quote() << functionName << ": expected the property named " << roleData.name << " to be of type " << roleData.typeName << ", but got " << QString::fromLatin1(rolePropertyValue.typeName()) << " instead"; diff --git a/src/imports/labsmodels/qqmltablemodel_p.h b/src/imports/labsmodels/qqmltablemodel_p.h index 6bf3e6df19..d6e982d19a 100644 --- a/src/imports/labsmodels/qqmltablemodel_p.h +++ b/src/imports/labsmodels/qqmltablemodel_p.h @@ -116,14 +116,14 @@ private: { public: ColumnRoleMetadata(); - ColumnRoleMetadata(bool isStringRole, const QString &name, QVariant::Type type, const QString &typeName); + ColumnRoleMetadata(bool isStringRole, const QString &name, int type, const QString &typeName); bool isValid() const; // If this is false, it's a function role. bool isStringRole = false; QString name; - QVariant::Type type = QVariant::Invalid; + int type = QMetaType::UnknownType; QString typeName; }; diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index d43f9bafb7..de45f87638 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -335,7 +335,7 @@ void QQmlSettingsPrivate::load() const QVariant currentValue = instance()->value(property.name(), previousValue); if (!currentValue.isNull() && (!previousValue.isValid() - || (currentValue.canConvert(previousValue.type()) && previousValue != currentValue))) { + || (currentValue.canConvert(previousValue.userType()) && previousValue != currentValue))) { property.write(q, currentValue); qCDebug(lcSettings) << "QQmlSettings: load" << property.name() << "setting:" << currentValue << "default:" << previousValue; } diff --git a/src/imports/testlib/quicktestevent.cpp b/src/imports/testlib/quicktestevent.cpp index 56faff9f7e..f2d7f93d26 100644 --- a/src/imports/testlib/quicktestevent.cpp +++ b/src/imports/testlib/quicktestevent.cpp @@ -125,7 +125,7 @@ bool QuickTestEvent::keyClickChar(const QString &character, int modifiers, int d // valueToKeySequence() is copied from qquickshortcut.cpp static QKeySequence valueToKeySequence(const QVariant &value) { - if (value.type() == QVariant::Int) + if (value.userType() == QMetaType::Int) return QKeySequence(static_cast<QKeySequence::StandardKey>(value.toInt())); return QKeySequence::fromString(value.toString()); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 029004ffd1..a3d19841cf 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -96,7 +96,7 @@ static bool isSaveable(const QVariant &value) { NullDevice nullDevice; QDataStream fakeStream(&nullDevice); - return QMetaType::save(fakeStream, static_cast<int>(value.type()), value.constData()); + return QMetaType::save(fakeStream, static_cast<int>(value.userType()), value.constData()); } QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) : @@ -217,7 +217,7 @@ QVariant QQmlEngineDebugServiceImpl::valueContents(QVariant value) const //QObject * is not streamable. //Convert all such instances to a String value - if (value.type() == QVariant::List) { + if (value.userType() == QMetaType::QVariantList) { QVariantList contents; QVariantList list = value.toList(); int count = list.size(); @@ -227,7 +227,7 @@ QVariant QQmlEngineDebugServiceImpl::valueContents(QVariant value) const return contents; } - if (value.type() == QVariant::Map) { + if (value.userType() == QMetaType::QVariantMap) { QVariantMap contents; const auto map = value.toMap(); for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index c2957dd294..b40bc1f18b 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -314,7 +314,7 @@ bool QJSValue::isBool() const if (val) return val->isBoolean(); QVariant *variant = QJSValuePrivate::getVariant(this); - return variant && variant->type() == QVariant::Bool; + return variant && variant->userType() == QMetaType::Bool; } /*! @@ -520,9 +520,9 @@ QString QJSValue::toString() const if (!val) { QVariant *variant = QJSValuePrivate::getVariant(this); Q_ASSERT(variant); - if (variant->type() == QVariant::Map) + if (variant->userType() == QMetaType::QVariantMap) return QStringLiteral("[object Object]"); - else if (variant->type() == QVariant::List) { + else if (variant->userType() == QMetaType::QVariantList) { const QVariantList list = variant->toList(); QString result; for (int i = 0; i < list.count(); ++i) { @@ -558,7 +558,7 @@ double QJSValue::toNumber() const QVariant *variant = QJSValuePrivate::getVariant(this); Q_ASSERT(variant); - if (variant->type() == QVariant::String) + if (variant->userType() == QMetaType::QString) return RuntimeHelpers::stringToNumber(variant->toString()); else if (variant->canConvert<double>()) return variant->value<double>(); @@ -1040,7 +1040,7 @@ bool QJSValue::equals(const QJSValue& other) const Q_ASSERT(variant); if (!ov) return *variant == *QJSValuePrivate::getVariant(&other); - if (variant->type() == QVariant::Map || variant->type() == QVariant::List) + if (variant->userType() == QMetaType::QVariantMap || variant->userType() == QMetaType::QVariantList) return false; return js_equal(variant->toString(), *ov); } @@ -1083,7 +1083,7 @@ bool QJSValue::strictlyEquals(const QJSValue& other) const Q_ASSERT(variant); if (!ov) return *variant == *QJSValuePrivate::getVariant(&other); - if (variant->type() == QVariant::Map || variant->type() == QVariant::List) + if (variant->userType() == QMetaType::QVariantMap || variant->userType() == QMetaType::QVariantList) return false; if (String *s = ov->stringValue()) return variant->toString() == s->toQString(); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 14eaa5bce8..dcdebfb398 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1461,7 +1461,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int if (const QV4::VariantObject *v = value.as<QV4::VariantObject>()) return v->d()->data(); - if (typeHint == QVariant::Bool) + if (typeHint == QMetaType::Bool) return QVariant(value.toBoolean()); if (typeHint == QMetaType::QJsonValue) @@ -1533,7 +1533,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int if (String *s = value.stringValue()) { const QString &str = s->toQString(); // QChars are stored as a strings - if (typeHint == QVariant::Char && str.size() == 1) + if (typeHint == QMetaType::QChar && str.size() == 1) return str.at(0); return str; } @@ -1832,7 +1832,7 @@ QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data) Q_ASSERT(data != nullptr); QVariant variant(type, data); - if (QMetaType::Type(variant.type()) == QMetaType::QVariant) { + if (QMetaType::Type(variant.userType()) == QMetaType::QVariant) { // unwrap it: this is tested in QJSEngine, and makes the most sense for // end-user code too. return variantToJS(this, *reinterpret_cast<const QVariant*>(data)); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 5a81f24e06..9613d064c4 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1654,7 +1654,7 @@ static QV4::ReturnedValue CallOverloaded(const QQmlObjectOrGadget &object, const } CallArgument::CallArgument() -: type(QVariant::Invalid) +: type(QMetaType::UnknownType) { } diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index e117e509ab..9d7b3c6e9a 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -65,8 +65,8 @@ void Heap::VariantObject::init(const QVariant &value) bool VariantObject::Data::isScarce() const { - QVariant::Type t = data().type(); - return t == QVariant::Pixmap || t == QVariant::Image; + int t = data().userType(); + return t == QMetaType::QPixmap || t == QMetaType::QImage; } bool VariantObject::virtualIsEqualTo(Managed *m, Managed *other) @@ -139,7 +139,7 @@ ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const V RETURN_UNDEFINED(); const QVariant variant = o->d()->data(); QString result = variant.toString(); - if (result.isEmpty() && !variant.canConvert(QVariant::String)) { + if (result.isEmpty() && !variant.canConvert(QMetaType::QString)) { QDebug dbg(&result); dbg << variant; // QDebug appends a space, we're not interested in continuing the stream so we chop it off. @@ -154,17 +154,17 @@ ReturnedValue VariantPrototype::method_valueOf(const FunctionObject *b, const Va const VariantObject *o = thisObject->as<QV4::VariantObject>(); if (o) { QVariant v = o->d()->data(); - switch (v.type()) { - case QVariant::Invalid: + switch (v.userType()) { + case QMetaType::UnknownType: return Encode::undefined(); - case QVariant::String: + case QMetaType::QString: return Encode(b->engine()->newString(v.toString())); - case QVariant::Int: + case QMetaType::Int: return Encode(v.toInt()); - case QVariant::Double: - case QVariant::UInt: + case QMetaType::Double: + case QMetaType::UInt: return Encode(v.toDouble()); - case QVariant::Bool: + case QMetaType::Bool: return Encode(v.toBool()); default: if (QMetaType::typeFlags(v.userType()) & QMetaType::IsEnumeration) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 162adf8364..e14b00af22 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -479,7 +479,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, if (!propertyMetaObject.isNull()) propertyType = propertyMetaObject.className(); } - } else if (userType != QVariant::Invalid) { + } else if (userType != QMetaType::UnknownType) { if (userType == QMetaType::Nullptr || userType == QMetaType::VoidStar) valueType = "null"; else diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index d68ad69260..78df02554c 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -414,25 +414,25 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } } break; - case QVariant::String: { + case QMetaType::QString: { assertOrNull(binding->evaluatesToString()); QString value = compilationUnit->bindingValueAsString(binding); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::StringList: { + case QMetaType::QStringList: { assertOrNull(binding->evaluatesToString()); QStringList value(compilationUnit->bindingValueAsString(binding)); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::ByteArray: { + case QMetaType::QByteArray: { assertType(QV4::CompiledData::Binding::Type_String); QByteArray value(compilationUnit->bindingValueAsString(binding).toUtf8()); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Url: { + case QMetaType::QUrl: { assertType(QV4::CompiledData::Binding::Type_String); QString string = compilationUnit->bindingValueAsString(binding); // Encoded dir-separators defeat QUrl processing - decode them first @@ -444,7 +444,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::UInt: { + case QMetaType::UInt: { assertType(QV4::CompiledData::Binding::Type_Number); double d = compilationUnit->bindingValueAsNumber(binding); uint value = uint(d); @@ -452,7 +452,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const break; } break; - case QVariant::Int: { + case QMetaType::Int: { assertType(QV4::CompiledData::Binding::Type_Number); double d = compilationUnit->bindingValueAsNumber(binding); int value = int(d); @@ -466,13 +466,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Double: { + case QMetaType::Double: { assertType(QV4::CompiledData::Binding::Type_Number); double value = compilationUnit->bindingValueAsNumber(binding); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Color: { + case QMetaType::QColor: { bool ok = false; uint colorValue = QQmlStringConverters::rgbaFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); @@ -483,21 +483,21 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } break; #if QT_CONFIG(datestring) - case QVariant::Date: { + case QMetaType::QDate: { bool ok = false; QDate value = QQmlStringConverters::dateFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Time: { + case QMetaType::QTime: { bool ok = false; QTime value = QQmlStringConverters::timeFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::DateTime: { + case QMetaType::QDateTime: { bool ok = false; QDateTime value = QQmlStringConverters::dateTimeFromString(compilationUnit->bindingValueAsString(binding), &ok); // ### VME compatibility :( @@ -511,55 +511,55 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } break; #endif // datestring - case QVariant::Point: { + case QMetaType::QPoint: { bool ok = false; QPoint value = QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok).toPoint(); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::PointF: { + case QMetaType::QPointF: { bool ok = false; QPointF value = QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Size: { + case QMetaType::QSize: { bool ok = false; QSize value = QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok).toSize(); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::SizeF: { + case QMetaType::QSizeF: { bool ok = false; QSizeF value = QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Rect: { + case QMetaType::QRect: { bool ok = false; QRect value = QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok).toRect(); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::RectF: { + case QMetaType::QRectF: { bool ok = false; QRectF value = QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok); assertOrNull(ok); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Bool: { + case QMetaType::Bool: { assertType(QV4::CompiledData::Binding::Type_Boolean); bool value = binding->valueAsBoolean(); property->writeProperty(_qobject, &value, propertyWriteFlags); } break; - case QVariant::Vector2D: { + case QMetaType::QVector2D: { struct { float xp; float yp; @@ -570,7 +570,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &vec, propertyWriteFlags); } break; - case QVariant::Vector3D: { + case QMetaType::QVector3D: { struct { float xp; float yp; @@ -582,7 +582,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &vec, propertyWriteFlags); } break; - case QVariant::Vector4D: { + case QMetaType::QVector4D: { struct { float xp; float yp; @@ -595,7 +595,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &vec, propertyWriteFlags); } break; - case QVariant::Quaternion: { + case QMetaType::QQuaternion: { struct { float wp; float xp; @@ -608,7 +608,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &vec, propertyWriteFlags); } break; - case QVariant::RegExp: + case QMetaType::QRegExp: assertOrNull(!"not possible"); break; default: { @@ -673,7 +673,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const QVariant value = (*converter)(stringValue); QMetaProperty metaProperty = _qobject->metaObject()->property(property->coreIndex()); - if (value.isNull() || ((int)metaProperty.type() != property->propType() && metaProperty.userType() != property->propType())) { + if (value.isNull() || metaProperty.userType() != property->propType()) { recordError(binding->location, tr("Cannot assign value %1 to property %2").arg(stringValue).arg(QString::fromUtf8(metaProperty.name()))); break; } diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 871bec1c17..93020661e2 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -471,7 +471,7 @@ QQmlPropertyPrivate::propertyTypeCategory() const return QQmlProperty::Normal; } else if (type & QQmlProperty::Property) { int type = propertyType(); - if (type == QVariant::Invalid) + if (type == QMetaType::UnknownType) return QQmlProperty::InvalidCategory; else if (QQmlValueTypeFactory::isValueType((uint)type)) return QQmlProperty::Normal; @@ -526,7 +526,7 @@ bool QQmlProperty::operator==(const QQmlProperty &other) const */ int QQmlProperty::propertyType() const { - return d ? d->propertyType() : int(QVariant::Invalid); + return d ? d->propertyType() : int(QMetaType::UnknownType); } bool QQmlPropertyPrivate::isValueType() const @@ -542,7 +542,7 @@ int QQmlPropertyPrivate::propertyType() const } else if (type & QQmlProperty::Property) { return core.propType(); } else { - return QVariant::Invalid; + return QMetaType::UnknownType; } } @@ -1133,7 +1133,7 @@ bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QVariant v = value; if (prop.isEnumType()) { QMetaEnum menum = prop.enumerator(); - if (v.userType() == QVariant::String + if (v.userType() == QMetaType::QString #ifdef QT3_SUPPORT || v.userType() == QVariant::CString #endif @@ -1145,13 +1145,13 @@ bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, v = QVariant(menum.keyToValue(value.toByteArray(), &ok)); if (!ok) return false; - } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) { + } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) { int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name())); if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData()) return false; v = QVariant(*reinterpret_cast<const int *>(v.constData())); } - v.convert(QVariant::Int); + v.convert(QMetaType::Int); } // the status variable is changed by qt_metacall to indicate what it did @@ -1206,17 +1206,17 @@ bool QQmlPropertyPrivate::write(QObject *object, QMetaProperty prop = object->metaObject()->property(property.coreIndex()); QVariant v = value; // Enum values come through the script engine as doubles - if (variantType == QVariant::Double) { + if (variantType == QMetaType::Double) { double integral; double fractional = std::modf(value.toDouble(), &integral); if (qFuzzyIsNull(fractional)) - v.convert(QVariant::Int); + v.convert(QMetaType::Int); } return writeEnumProperty(prop, property.coreIndex(), object, v, flags); } QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(context); - const bool isUrl = propertyType == QVariant::Url; // handled separately + const bool isUrl = propertyType == QMetaType::QUrl; // handled separately // The cases below are in approximate order of likelyhood: if (propertyType == variantType && !isUrl && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) { @@ -1249,7 +1249,7 @@ bool QQmlPropertyPrivate::write(QObject *object, } else { return false; } - } else if (value.canConvert(propertyType) && !isUrl && variantType != QVariant::String && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) { + } else if (value.canConvert(propertyType) && !isUrl && variantType != QMetaType::QString && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) { // common cases: switch (propertyType) { case QMetaType::Bool: { @@ -1282,14 +1282,14 @@ bool QQmlPropertyPrivate::write(QObject *object, return property.writeProperty(object, const_cast<QVariant *>(&value), flags); } else if (isUrl) { QUrl u; - if (variantType == QVariant::Url) { + if (variantType == QMetaType::QUrl) { u = value.toUrl(); - } else if (variantType == QVariant::ByteArray) { + } else if (variantType == QMetaType::QByteArray) { QString input(QString::fromUtf8(value.toByteArray())); // Encoded dir-separators defeat QUrl processing - decode them first input.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive); u = QUrl(input); - } else if (variantType == QVariant::String) { + } else if (variantType == QMetaType::QString) { QString input(value.toString()); // Encoded dir-separators defeat QUrl processing - decode them first input.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive); @@ -1355,7 +1355,7 @@ bool QQmlPropertyPrivate::write(QObject *object, bool ok = false; QVariant v; - if (variantType == QVariant::String) + if (variantType == QMetaType::QString) v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok); if (!ok) { @@ -1368,8 +1368,8 @@ bool QQmlPropertyPrivate::write(QObject *object, // successful conversion. Q_ASSERT(v.userType() == propertyType); ok = true; - } else if (static_cast<uint>(propertyType) >= QVariant::UserType && - variantType == QVariant::String) { + } else if (static_cast<uint>(propertyType) >= QMetaType::User && + variantType == QMetaType::QString) { QQmlMetaType::StringConverter con = QQmlMetaType::customStringConverter(propertyType); if (con) { v = con(value.toString()); @@ -1383,28 +1383,28 @@ bool QQmlPropertyPrivate::write(QObject *object, // to a sequence type property (eg, an int to a QList<int> property). // or that we encountered an interface type // Note that we've already handled single-value assignment to QList<QUrl> properties. - if (variantType == QVariant::Int && propertyType == qMetaTypeId<QList<int> >()) { + if (variantType == QMetaType::Int && propertyType == qMetaTypeId<QList<int> >()) { QList<int> list; list << value.toInt(); v = QVariant::fromValue<QList<int> >(list); ok = true; - } else if ((variantType == QVariant::Double || variantType == QVariant::Int) + } else if ((variantType == QMetaType::Double || variantType == QMetaType::Int) && (propertyType == qMetaTypeId<QList<qreal> >())) { QList<qreal> list; list << value.toReal(); v = QVariant::fromValue<QList<qreal> >(list); ok = true; - } else if (variantType == QVariant::Bool && propertyType == qMetaTypeId<QList<bool> >()) { + } else if (variantType == QMetaType::Bool && propertyType == qMetaTypeId<QList<bool> >()) { QList<bool> list; list << value.toBool(); v = QVariant::fromValue<QList<bool> >(list); ok = true; - } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QList<QString> >()) { + } else if (variantType == QMetaType::QString && propertyType == qMetaTypeId<QList<QString> >()) { QList<QString> list; list << value.toString(); v = QVariant::fromValue<QList<QString> >(list); ok = true; - } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QStringList>()) { + } else if (variantType == QMetaType::QString && propertyType == qMetaTypeId<QStringList>()) { QStringList list; list << value.toString(); v = QVariant::fromValue<QStringList>(list); diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 69957ab282..bddea57622 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -92,7 +92,7 @@ static void flagsForPropertyType(int propType, QQmlPropertyData::Flags &flags) flags.type = QQmlPropertyData::Flags::QObjectDerivedType; } else if (propType == QMetaType::QVariant) { flags.type = QQmlPropertyData::Flags::QVariantType; - } else if (propType < static_cast<int>(QVariant::UserType)) { + } else if (propType < static_cast<int>(QMetaType::User)) { // nothing to do } else if (propType == qMetaTypeId<QQmlBinding *>()) { flags.type = QQmlPropertyData::Flags::QmlBindingType; @@ -136,14 +136,14 @@ static void populate(QQmlPropertyData *data, const QMetaProperty &p) void QQmlPropertyData::lazyLoad(const QMetaProperty &p) { populate(this, p); - int type = static_cast<int>(p.type()); + int type = static_cast<int>(p.userType()); if (type == QMetaType::QObjectStar) { setPropType(type); m_flags.type = Flags::QObjectDerivedType; } else if (type == QMetaType::QVariant) { setPropType(type); m_flags.type = Flags::QVariantType; - } else if (type == QVariant::UserType || type == -1) { + } else if (type >= QMetaType::User || type == 0) { m_flags.notFullyResolved = true; } else { setPropType(type); @@ -314,7 +314,7 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag const QList<QByteArray> &names) { QQmlPropertyData data; - data.setPropType(QVariant::Invalid); + data.setPropType(QMetaType::UnknownType); data.setCoreIndex(coreIndex); data.setFlags(flags); data.setArguments(nullptr); diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index 8571b0c9b3..1f636c8347 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -806,12 +806,12 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>: if (valueTypeIndex != -1) { const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(*type); if (valueTypeMetaObject->property(valueTypeIndex).isEnumType()) - *type = QVariant::Int; + *type = QMetaType::Int; else *type = valueTypeMetaObject->property(valueTypeIndex).userType(); } else { if (targetProperty->isEnum()) { - *type = QVariant::Int; + *type = QMetaType::Int; } else { // Copy type flags propertyFlags->copyPropertyTypeFlags(targetProperty->flags()); diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 238a535b89..8f6e2737cc 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -398,31 +398,31 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp switch (property->propType()) { case QMetaType::QVariant: break; - case QVariant::String: { + case QMetaType::QString: { if (!binding->evaluatesToString()) { return warnOrError(tr("Invalid property assignment: string expected")); } } break; - case QVariant::StringList: { + case QMetaType::QStringList: { if (!binding->evaluatesToString()) { return warnOrError(tr("Invalid property assignment: string or string list expected")); } } break; - case QVariant::ByteArray: { + case QMetaType::QByteArray: { if (binding->type != QV4::CompiledData::Binding::Type_String) { return warnOrError(tr("Invalid property assignment: byte array expected")); } } break; - case QVariant::Url: { + case QMetaType::QUrl: { if (binding->type != QV4::CompiledData::Binding::Type_String) { return warnOrError(tr("Invalid property assignment: url expected")); } } break; - case QVariant::UInt: { + case QMetaType::UInt: { if (binding->type == QV4::CompiledData::Binding::Type_Number) { double d = compilationUnit->bindingValueAsNumber(binding); if (double(uint(d)) == d) @@ -431,7 +431,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp return warnOrError(tr("Invalid property assignment: unsigned int expected")); } break; - case QVariant::Int: { + case QMetaType::Int: { if (binding->type == QV4::CompiledData::Binding::Type_Number) { double d = compilationUnit->bindingValueAsNumber(binding); if (double(int(d)) == d) @@ -446,13 +446,13 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Double: { + case QMetaType::Double: { if (binding->type != QV4::CompiledData::Binding::Type_Number) { return warnOrError(tr("Invalid property assignment: number expected")); } } break; - case QVariant::Color: { + case QMetaType::QColor: { bool ok = false; QQmlStringConverters::rgbaFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -461,7 +461,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } break; #if QT_CONFIG(datestring) - case QVariant::Date: { + case QMetaType::QDate: { bool ok = false; QQmlStringConverters::dateFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -469,7 +469,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Time: { + case QMetaType::QTime: { bool ok = false; QQmlStringConverters::timeFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -477,7 +477,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::DateTime: { + case QMetaType::QDateTime: { bool ok = false; QQmlStringConverters::dateTimeFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -486,7 +486,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } break; #endif // datestring - case QVariant::Point: { + case QMetaType::QPoint: { bool ok = false; QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -494,7 +494,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::PointF: { + case QMetaType::QPointF: { bool ok = false; QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -502,7 +502,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Size: { + case QMetaType::QSize: { bool ok = false; QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -510,7 +510,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::SizeF: { + case QMetaType::QSizeF: { bool ok = false; QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -518,7 +518,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Rect: { + case QMetaType::QRect: { bool ok = false; QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -526,7 +526,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::RectF: { + case QMetaType::QRectF: { bool ok = false; QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok); if (!ok) { @@ -534,13 +534,13 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Bool: { + case QMetaType::Bool: { if (binding->type != QV4::CompiledData::Binding::Type_Boolean) { return warnOrError(tr("Invalid property assignment: boolean expected")); } } break; - case QVariant::Vector2D: { + case QMetaType::QVector2D: { struct { float xp; float yp; @@ -550,7 +550,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Vector3D: { + case QMetaType::QVector3D: { struct { float xp; float yp; @@ -561,7 +561,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Vector4D: { + case QMetaType::QVector4D: { struct { float xp; float yp; @@ -573,7 +573,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::Quaternion: { + case QMetaType::QQuaternion: { struct { float wp; float xp; @@ -585,8 +585,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp } } break; - case QVariant::RegExp: - case QVariant::RegularExpression: + case QMetaType::QRegExp: + case QMetaType::QRegularExpression: return warnOrError(tr("Invalid property assignment: regular expression expected; use /pattern/ syntax")); default: { // generate single literal value assignment to a list property if required diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index 90a10c8d9a..cb3f572e1f 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -64,7 +64,7 @@ struct QQmlValueTypeFactoryImpl const QMetaObject *metaObjectForMetaType(int); QQmlValueType *valueType(int); - QQmlValueType *valueTypes[QVariant::UserType]; + QQmlValueType *valueTypes[QMetaType::User]; QHash<int, QQmlValueType *> userTypes; QMutex mutex; @@ -73,7 +73,7 @@ struct QQmlValueTypeFactoryImpl QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() { - std::fill_n(valueTypes, int(QVariant::UserType), &invalidValueType); + std::fill_n(valueTypes, int(QMetaType::User), &invalidValueType); #if QT_CONFIG(qml_itemmodel) // See types wrapped in qqmlmodelindexvaluetype_p.h @@ -120,24 +120,24 @@ bool QQmlValueTypeFactoryImpl::isValueType(int idx) const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t) { switch (t) { - case QVariant::Point: + case QMetaType::QPoint: return &QQmlPointValueType::staticMetaObject; - case QVariant::PointF: + case QMetaType::QPointF: return &QQmlPointFValueType::staticMetaObject; - case QVariant::Size: + case QMetaType::QSize: return &QQmlSizeValueType::staticMetaObject; - case QVariant::SizeF: + case QMetaType::QSizeF: return &QQmlSizeFValueType::staticMetaObject; - case QVariant::Rect: + case QMetaType::QRect: return &QQmlRectValueType::staticMetaObject; - case QVariant::RectF: + case QMetaType::QRectF: return &QQmlRectFValueType::staticMetaObject; - case QVariant::EasingCurve: + case QMetaType::QEasingCurve: return &QQmlEasingValueType::staticMetaObject; #if QT_CONFIG(qml_itemmodel) - case QVariant::ModelIndex: + case QMetaType::QModelIndex: return &QQmlModelIndexValueType::staticMetaObject; - case QVariant::PersistentModelIndex: + case QMetaType::QPersistentModelIndex: return &QQmlPersistentModelIndexValueType::staticMetaObject; #endif default: @@ -160,7 +160,7 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t) QQmlValueType *QQmlValueTypeFactoryImpl::valueType(int idx) { - if (idx >= (int)QVariant::UserType) { + if (idx >= (int)QMetaType::User) { // Protect the hash with a mutex mutex.lock(); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index f23921497c..ba5ba96cbe 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -601,7 +601,7 @@ bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &v QVariant v = v4->toVariant(value, property.userType()); - if (property.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double) + if (property.isEnumType() && (QMetaType::Type)v.userType() == QMetaType::Double) v = v.toInt(); void *gadget = r->d()->gadgetPtr(); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 42a90e234c..ecb86e2f10 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -291,7 +291,7 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a) const int valueIndex = vi->m_propertyIndex.valueTypeIndex(); int type = QQmlData::get(object)->propertyCache->property(id)->propType(); - if (type != QVariant::Invalid) { + if (type != QMetaType::UnknownType) { if (valueIndex != -1) { QQmlValueType *valueType = QQmlValueTypeFactory::valueType(type); Q_ASSERT(valueType); @@ -534,7 +534,7 @@ QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::Url) + if (!v || v->d()->data().userType() != QMetaType::QUrl) return QUrl(); return v->d()->data().value<QUrl>(); } @@ -548,7 +548,7 @@ QDate QQmlVMEMetaObject::readPropertyAsDate(int id) const QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::Date) + if (!v || v->d()->data().userType() != QMetaType::QDate) return QDate(); return v->d()->data().value<QDate>(); } @@ -562,7 +562,7 @@ QDateTime QQmlVMEMetaObject::readPropertyAsDateTime(int id) QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::DateTime) + if (!v || v->d()->data().userType() != QMetaType::QDateTime) return QDateTime(); return v->d()->data().value<QDateTime>(); } @@ -576,7 +576,7 @@ QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id) const QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::SizeF) + if (!v || v->d()->data().userType() != QMetaType::QSizeF) return QSizeF(); return v->d()->data().value<QSizeF>(); } @@ -590,7 +590,7 @@ QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id) const QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::PointF) + if (!v || v->d()->data().userType() != QMetaType::QPointF) return QPointF(); return v->d()->data().value<QPointF>(); } @@ -634,7 +634,7 @@ QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id) const QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::VariantObject *v = sv->as<QV4::VariantObject>(); - if (!v || v->d()->data().type() != QVariant::RectF) + if (!v || v->d()->data().userType() != QMetaType::QRectF) return QRectF(); return v->d()->data().value<QRectF>(); } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index f5e723419e..ac4b9b85b9 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -346,22 +346,22 @@ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value * bool ok = false; QVariant lhs = scope.engine->toVariant(argv[0], -1); - if (lhs.userType() == QVariant::String) { + if (lhs.userType() == QMetaType::QString) { lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok); if (!ok) { THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid color name"); } - } else if (lhs.userType() != QVariant::Color) { + } else if (lhs.userType() != QMetaType::QColor) { THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments"); } QVariant rhs = scope.engine->toVariant(argv[1], -1); - if (rhs.userType() == QVariant::String) { + if (rhs.userType() == QMetaType::QString) { rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok); if (!ok) { THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid color name"); } - } else if (rhs.userType() != QVariant::Color) { + } else if (rhs.userType() != QMetaType::QColor) { THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments"); } @@ -612,13 +612,13 @@ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, c THROW_GENERIC_ERROR("Qt.lighter(): Invalid arguments"); QVariant v = scope.engine->toVariant(argv[0], -1); - if (v.userType() == QVariant::String) { + if (v.userType() == QMetaType::QString) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); if (!ok) { return QV4::Encode::null(); } - } else if (v.userType() != QVariant::Color) { + } else if (v.userType() != QMetaType::QColor) { return QV4::Encode::null(); } @@ -652,13 +652,13 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co THROW_GENERIC_ERROR("Qt.darker(): Invalid arguments"); QVariant v = scope.engine->toVariant(argv[0], -1); - if (v.userType() == QVariant::String) { + if (v.userType() == QMetaType::QString) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); if (!ok) { return QV4::Encode::null(); } - } else if (v.userType() != QVariant::Color) { + } else if (v.userType() != QMetaType::QColor) { return QV4::Encode::null(); } @@ -703,25 +703,25 @@ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, cons // base color QVariant v1 = scope.engine->toVariant(argv[0], -1); - if (v1.userType() == QVariant::String) { + if (v1.userType() == QMetaType::QString) { bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); if (!ok) { return QV4::Encode::null(); } - } else if (v1.userType() != QVariant::Color) { + } else if (v1.userType() != QMetaType::QColor) { return QV4::Encode::null(); } // tint color QVariant v2 = scope.engine->toVariant(argv[1], -1); - if (v2.userType() == QVariant::String) { + if (v2.userType() == QMetaType::QString) { bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); if (!ok) { return QV4::Encode::null(); } - } else if (v2.userType() != QVariant::Color) { + } else if (v2.userType() != QMetaType::QColor) { return QV4::Encode::null(); } @@ -795,7 +795,7 @@ ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value * QVariant argVariant = scope.engine->toVariant(argv[0], -1); QTime time; - if (argv[0].as<DateObject>() || (argVariant.type() == QVariant::String)) + if (argv[0].as<DateObject>() || (argVariant.userType() == QMetaType::QString)) time = argVariant.toDateTime().time(); else // if (argVariant.type() == QVariant::Time), or invalid. time = argVariant.toTime(); diff --git a/src/qmlmodels/qqmladaptormodel.cpp b/src/qmlmodels/qqmladaptormodel.cpp index cf0d8fbb2f..fbb85327a7 100644 --- a/src/qmlmodels/qqmladaptormodel.cpp +++ b/src/qmlmodels/qqmladaptormodel.cpp @@ -367,10 +367,10 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QVariant::Invalid); + modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QMetaType::UnknownType); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, nullptr); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = scope.engine->toVariant(argv[0], QVariant::Invalid); + modelData->cachedData[0] = scope.engine->toVariant(argv[0], QMetaType::UnknownType); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, nullptr); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, nullptr); } @@ -601,7 +601,7 @@ public: if (!argc) return v4->throwTypeError(); - static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(argv[0], QVariant::Invalid)); + static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(argv[0], QMetaType::UnknownType)); return QV4::Encode::undefined(); } diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 7ad53eeb6c..3a3903965c 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -2011,7 +2011,7 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const propertyName = it.nextPropertyNameAsString(v); if (propertyName->isNull()) break; - cacheItem->setValue(propertyName->toQStringNoThrow(), scope.engine->toVariant(v, QVariant::Invalid)); + cacheItem->setValue(propertyName->toQStringNoThrow(), scope.engine->toVariant(v, QMetaType::UnknownType)); } cacheItem->groups = groups | Compositor::UnresolvedFlag | Compositor::CacheFlag; diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp index 46a11e2bc2..c450c616e7 100644 --- a/src/qmlmodels/qqmllistaccessor.cpp +++ b/src/qmlmodels/qqmllistaccessor.cpp @@ -76,11 +76,11 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine) if (!d.isValid()) { m_type = Invalid; - } else if (d.userType() == QVariant::StringList) { + } else if (d.userType() == QMetaType::QStringList) { m_type = StringList; } else if (d.userType() == QMetaType::QVariantList) { m_type = VariantList; - } else if (d.canConvert(QVariant::Int)) { + } else if (d.canConvert(QMetaType::Int)) { // Here we have to check for an upper limit, because down the line code might (well, will) // allocate memory depending on the number of elements. The upper limit cannot be INT_MAX: // QVector<QPointer<QQuickItem>> something; diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp index f79910204a..fe8fba0cca 100644 --- a/src/qmlmodels/qqmllistmodel.cpp +++ b/src/qmlmodels/qqmllistmodel.cpp @@ -219,14 +219,14 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV { Role::DataType type; - switch (data.type()) { - case QVariant::Double: type = Role::Number; break; - case QVariant::Int: type = Role::Number; break; - case QVariant::Bool: type = Role::Bool; break; - case QVariant::String: type = Role::String; break; - case QVariant::Map: type = Role::VariantMap; break; - case QVariant::DateTime: type = Role::DateTime; break; - case QVariant::UserType: { + switch (data.userType()) { + case QMetaType::Double: type = Role::Number; break; + case QMetaType::Int: type = Role::Number; break; + case QMetaType::Bool: type = Role::Bool; break; + case QMetaType::QString: type = Role::String; break; + case QMetaType::QVariantMap: type = Role::VariantMap; break; + case QMetaType::QDateTime: type = Role::DateTime; break; + default: { if (data.userType() == qMetaTypeId<QJSValue>() && data.value<QJSValue>().isCallable()) { type = Role::Function; @@ -235,12 +235,14 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV && data.value<const QV4::CompiledData::Binding*>()->isTranslationBinding()) { type = Role::String; break; - } else { + } else if (data.userType() >= QMetaType::User) { type = Role::List; break; + } else { + type = Role::Invalid; + break; } } - default: type = Role::Invalid; break; } if (type == Role::Invalid) { @@ -1740,7 +1742,7 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> if (value.userType() == qMetaTypeId<QJSValue>()) value = value.value<QJSValue>().toVariant(); - if (value.type() == QVariant::List) { + if (value.userType() == QMetaType::QVariantList) { QQmlListModel *subModel = QQmlListModel::createWithOwner(m_owner); QVariantList subArray = value.toList(); @@ -1803,7 +1805,7 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index) if (v.userType() == qMetaTypeId<QJSValue>()) v= v.value<QJSValue>().toVariant(); - if (v.type() == QVariant::List) { + if (v.userType() == QMetaType::QVariantList) { QQmlListModel *subModel = QQmlListModel::createWithOwner(parentModel); QVariantList subArray = v.toList(); diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 49552e1901..d5ab267cec 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -500,8 +500,8 @@ bool QuickTestResult::verify bool QuickTestResult::fuzzyCompare(const QVariant &actual, const QVariant &expected, qreal delta) { - if (actual.type() == QVariant::Color || expected.type() == QVariant::Color) { - if (!actual.canConvert(QVariant::Color) || !expected.canConvert(QVariant::Color)) + if (actual.userType() == QMetaType::QColor || expected.userType() == QMetaType::QColor) { + if (!actual.canConvert(QMetaType::QColor) || !expected.canConvert(QMetaType::QColor)) return false; //fuzzy color comparison @@ -556,20 +556,20 @@ void QuickTestResult::stringify(QQmlV4Function *args) && !value->as<QV4::ArrayObject>()) { QVariant v = scope.engine->toVariant(value, QMetaType::UnknownType); if (v.isValid()) { - switch (v.type()) { - case QVariant::Vector3D: + switch (v.userType()) { + case QMetaType::QVector3D: { QVector3D v3d = v.value<QVector3D>(); result = QString::fromLatin1("Qt.vector3d(%1, %2, %3)").arg(v3d.x()).arg(v3d.y()).arg(v3d.z()); break; } - case QVariant::Url: + case QMetaType::QUrl: { QUrl url = v.value<QUrl>(); result = QString::fromLatin1("Qt.url(%1)").arg(url.toString()); break; } - case QVariant::DateTime: + case QMetaType::QDateTime: { QDateTime dt = v.value<QDateTime>(); result = dt.toString(Qt::ISODateWithMs); diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp index de7da7f9be..0aa5dc2613 100644 --- a/src/quick/designer/qqmldesignermetaobject.cpp +++ b/src/quick/designer/qqmldesignermetaobject.cpp @@ -240,7 +240,7 @@ int QQmlDesignerMetaObject::metaCall(QObject *o, QMetaObject::Call call, int id, if (call == QMetaObject::WriteProperty && propertyById.userType() == QMetaType::QVariant - && reinterpret_cast<QVariant *>(a[0])->type() == QVariant::Double + && reinterpret_cast<QVariant *>(a[0])->userType() == QMetaType::Double && qt_is_nan(reinterpret_cast<QVariant *>(a[0])->toDouble())) { return -1; } diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp index 6b39f5157b..66a86bffd5 100644 --- a/src/quick/designer/qquickdesignercustomobjectdata.cpp +++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp @@ -278,7 +278,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context, //Refcounting is taking take care of deletion binding->update(); if (binding->hasError()) { - if (property.property().userType() == QVariant::String) + if (property.property().userType() == QMetaType::QString) property.write(QVariant(QLatin1Char('#') + expression + QLatin1Char('#'))); } diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 8454010ee9..b5932c6f80 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -1478,7 +1478,7 @@ QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const if (i && i->isVisible() && (i->flags() & QQuickItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? QVariant v = i->inputMethodQuery(query); - if (v.userType() == QVariant::RectF) + if (v.userType() == QMetaType::QRectF) v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? return v; } diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp index 26ef59c20e..5721f116e8 100644 --- a/src/quick/items/qquickopenglshadereffectnode.cpp +++ b/src/quick/items/qquickopenglshadereffectnode.cpp @@ -178,7 +178,7 @@ void QQuickCustomMaterialShader::updateState(const RenderState &state, QSGMateri if (state.isMatrixDirty()) program()->setUniformValue(loc, state.combinedMatrix()); } else if (d.specialType == UniformData::None) { - switch (int(d.value.type())) { + switch (int(d.value.userType())) { case QMetaType::QColor: program()->setUniformValue(loc, qt_premultiply_color(qvariant_cast<QColor>(d.value))); break; diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp index 6f6544548c..e86dae7c09 100644 --- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp +++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp @@ -136,7 +136,7 @@ void QSGRhiShaderLinker::linkTextureSubRects() // texture binding point. for (Constant &c : m_constants) { if (c.specialType == QSGShaderEffectNode::VariableData::SubRect) { - if (c.value.type() == QVariant::ByteArray) { + if (c.value.userType() == QMetaType::QByteArray) { const QByteArray name = c.value.toByteArray(); if (!m_samplerNameMap.contains(name)) qWarning("ShaderEffect: qt_SubRect_%s refers to unknown source texture", name.constData()); @@ -270,7 +270,7 @@ bool QSGRhiShaderEffectMaterialShader::updateUniformData(RenderState &state, QSG memcpy(dst, f, sizeof(f)); } else if (c.specialType == QSGShaderEffectNode::VariableData::None) { changed = true; - switch (int(c.value.type())) { + switch (int(c.value.userType())) { case QMetaType::QColor: { const QColor v = qsg_premultiply_color(qvariant_cast<QColor>(c.value)); const float f[4] = { float(v.redF()), float(v.greenF()), float(v.blueF()), float(v.alphaF()) }; diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index d6d6f1d8d4..763b0aa171 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1966,20 +1966,20 @@ QAbstractAnimationJob* QQuickParallelAnimation::transition(QQuickStateActions &a //convert a variant from string type to another animatable type void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { - if (variant.userType() != QVariant::String) { + if (variant.userType() != QMetaType::QString) { variant.convert(type); return; } switch (type) { - case QVariant::Rect: - case QVariant::RectF: - case QVariant::Point: - case QVariant::PointF: - case QVariant::Size: - case QVariant::SizeF: - case QVariant::Color: - case QVariant::Vector3D: + case QMetaType::QRect: + case QMetaType::QRectF: + case QMetaType::QPoint: + case QMetaType::QPointF: + case QMetaType::QSize: + case QMetaType::QSizeF: + case QMetaType::QColor: + case QMetaType::QVector3D: { bool ok = false; variant = QQmlStringConverters::variantFromString(variant.toString(), type, &ok); diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 527274e6be..bc5b8c4f3e 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -719,7 +719,7 @@ public: bool typedRead(const QVariant& src, int dstType, void *dst) { T *dstT = reinterpret_cast<T *>(dst); - if (src.type() == static_cast<uint>(dstType)) { + if (src.userType() == dstType) { *dstT = src.value<T>(); } else { *dstT = T(); diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 24b22f00c1..c855acc185 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -2415,7 +2415,7 @@ QVariant QQuickPathPolyline::path() const void QQuickPathPolyline::setPath(const QVariant &path) { - if (path.type() == QVariant::PolygonF) { + if (path.userType() == QMetaType::QPolygonF) { setPath(path.value<QPolygonF>()); } else if (path.canConvert<QVector<QPointF>>()) { setPath(path.value<QVector<QPointF>>()); @@ -2431,7 +2431,7 @@ void QQuickPathPolyline::setPath(const QVariant &path) pathList.append(v.toPointF()); setPath(pathList); } else { - qWarning() << "PathPolyline: path of type" << path.type() << "not supported"; + qWarning() << "PathPolyline: path of type" << path.userType() << "not supported"; } } @@ -2583,7 +2583,7 @@ void QQuickPathMultiline::setPaths(const QVariant &paths) } setPaths(pathsList); } else { - qWarning() << "PathMultiline: paths of type" << paths.type() << "not supported"; + qWarning() << "PathMultiline: paths of type" << paths.userType() << "not supported"; setPaths(QVector<QVector<QPointF>>()); } } diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp index 5d227b4613..8ef204d179 100644 --- a/src/quick/util/qquickshortcut.cpp +++ b/src/quick/util/qquickshortcut.cpp @@ -130,7 +130,7 @@ QT_BEGIN_NAMESPACE static QKeySequence valueToKeySequence(const QVariant &value) { - if (value.type() == QVariant::Int) + if (value.userType() == QMetaType::Int) return QKeySequence(static_cast<QKeySequence::StandardKey>(value.toInt())); return QKeySequence::fromString(value.toString()); } diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 0ebf43eb6f..12befeb1ec 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -280,11 +280,11 @@ void tst_QQmlEngineDebugService::recursiveObjectTest( } else { QCOMPARE(ref.name, QString("<unknown value>")); } - } else if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) { + } else if (pmeta.userType() < QMetaType::User && pmeta.userType() != QMetaType::QVariant) { const QVariant expected = pmeta.read(o); QVERIFY2(p.value == expected, QString::fromLatin1("%1 != %2. Details: %3/%4/%5/%6") .arg(QTest::toString(p.value)).arg(QTest::toString(expected)).arg(p.name) - .arg(p.valueTypeName).arg(pmeta.type()).arg(pmeta.userType()).toUtf8()); + .arg(p.valueTypeName).arg(pmeta.userType()).arg(pmeta.userType()).toUtf8()); } if (p.name == "parent") diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 66a526fda8..28efb519ee 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -1543,7 +1543,7 @@ void tst_QJSEngine::valueConversion_QVariant() { QVariant tmp1; QVariant tmp2(QMetaType::QVariant, &tmp1); - QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp2.userType()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp1); QJSValue val2 = eng.toScriptValue(tmp2); @@ -1558,9 +1558,9 @@ void tst_QJSEngine::valueConversion_QVariant() QVariant tmp1(123); QVariant tmp2(QMetaType::QVariant, &tmp1); QVariant tmp3(QMetaType::QVariant, &tmp2); - QCOMPARE(QMetaType::Type(tmp1.type()), QMetaType::Int); - QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); - QCOMPARE(QMetaType::Type(tmp3.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp1.userType()), QMetaType::Int); + QCOMPARE(QMetaType::Type(tmp2.userType()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp3.userType()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp2); QJSValue val2 = eng.toScriptValue(tmp3); diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 95f554776f..d6e85f973f 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1081,7 +1081,7 @@ void tst_QJSValue::toVariant() // We can't roundtrip a QRegExp this way, as toVariant() has no information on whether we // want QRegExp or QRegularExpression. It will always create a QRegularExpression. - QCOMPARE(var.type(), QMetaType::QRegularExpression); + QCOMPARE(var.userType(), QMetaType::QRegularExpression); QRegularExpression result = var.toRegularExpression(); QCOMPARE(result.pattern(), rx.pattern()); QCOMPARE(result.patternOptions() & QRegularExpression::CaseInsensitiveOption, 0); @@ -1134,7 +1134,7 @@ void tst_QJSValue::toVariant() QVERIFY(array.isArray()); QCOMPARE(array.property("length").toInt(), 2); QVariant ret = array.toVariant(); - QCOMPARE(ret.type(), QVariant::List); + QCOMPARE(ret.userType(), QVariant::List); QVariantList listOut = ret.toList(); QCOMPARE(listOut.size(), listIn.size()); for (int i = 0; i < listIn.size(); ++i) diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index c846ee32df..e3094db708 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -449,7 +449,7 @@ void tst_qqmllocale::firstDayOfWeek() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("firstDayOfWeek"); - QCOMPARE(val.type(), QVariant::Int); + QCOMPARE(val.userType(), QMetaType::Int); int day = int(QLocale(locale).firstDayOfWeek()); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 72295044a5..296d1b14e0 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -157,7 +157,7 @@ void tst_qqmlmetatype::initTestCase() void tst_qqmlmetatype::qmlParserStatusCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).parserStatusCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()).isValid()); @@ -177,7 +177,7 @@ void tst_qqmlmetatype::qmlParserStatusCast() void tst_qqmlmetatype::qmlPropertyValueSourceCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueSourceCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -197,7 +197,7 @@ void tst_qqmlmetatype::qmlPropertyValueSourceCast() void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueInterceptorCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -256,8 +256,8 @@ void tst_qqmlmetatype::prettyTypeName() void tst_qqmlmetatype::isList() { - QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false); - QCOMPARE(QQmlMetaType::isList(QVariant::Int), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::UnknownType), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::Int), false); QQmlListProperty<TestType> list; @@ -327,10 +327,10 @@ void tst_qqmlmetatype::externalEnums() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); QVariant a = obj->property("a"); - QCOMPARE(a.type(), QVariant::Int); + QCOMPARE(a.userType(), QVariant::Int); QCOMPARE(a.toInt(), int(QStandardPaths::DocumentsLocation)); QVariant b = obj->property("b"); - QCOMPARE(b.type(), QVariant::Int); + QCOMPARE(b.userType(), QVariant::Int); QCOMPARE(b.toInt(), int(QStandardPaths::DocumentsLocation)); } @@ -394,10 +394,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } QQmlMetaType::unregisterType(controllerId); @@ -417,10 +417,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller2 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #2")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 111); } QQmlMetaType::unregisterType(controllerId); @@ -440,10 +440,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } } @@ -489,7 +489,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } QQmlMetaType::unregisterType(staticProviderId); @@ -505,7 +505,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #2")); } QQmlMetaType::unregisterType(staticProviderId); @@ -521,7 +521,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } } diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index c37910bdaf..b563d7df95 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -509,7 +509,7 @@ QString generateCmakeIncludeFileContent(const QVariantList &importList) { QTextStream s(&content); int importsCount = 0; for (const QVariant &importVariant: importList) { - if (static_cast<QMetaType::Type>(importVariant.type()) == QMetaType::QVariantMap) { + if (static_cast<QMetaType::Type>(importVariant.userType()) == QMetaType::QVariantMap) { s << QStringLiteral("set(qml_import_scanner_import_") << importsCount << QStringLiteral(" \""); |