From fdc55ec837c79f1b42896b56f5be2c4abb5183ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 18 May 2012 17:30:03 +0200 Subject: [PATCH] Simplify QVariant::convert and QVariant::canConvert calls. QVariant::Type casts are not necessary in Qt5. Change-Id: Ia2e7d8fa367a59c23bd06993db36d96a0a46a229 Reviewed-by: Roberto Raggi --- src/qml/qml/qqmlproperty.cpp | 2 +- src/qml/qml/v4/qv4bindings.cpp | 4 ++-- src/qml/qml/v8/qv8engine.cpp | 4 ++-- src/qml/qml/v8/qv8qobjectwrapper.cpp | 4 ++-- src/quick/util/qquickanimation.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index d68d8a9..761b75a 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1371,7 +1371,7 @@ bool QQmlPropertyPrivate::write(QObject *object, v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok); if (!ok) { v = value; - if (v.convert((QVariant::Type)propertyType)) { + if (v.convert(propertyType)) { ok = true; } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) { QQmlMetaType::StringConverter con = QQmlMetaType::customStringConverter(propertyType); diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp index f25bfcc..d4665ac 100644 --- a/src/qml/qml/v4/qv4bindings.cpp +++ b/src/qml/qml/v4/qv4bindings.cpp @@ -455,8 +455,8 @@ static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4) QVariant qtscript = qtscriptRaw; if (qtscript.userType() == v4.userType()) { - } else if (qtscript.canConvert((QVariant::Type)v4.userType())) { - qtscript.convert((QVariant::Type)v4.userType()); + } else if (qtscript.canConvert(v4.userType())) { + qtscript.convert(v4.userType()); } else if (qtscript.userType() == QVariant::Invalid && v4.userType() == QMetaType::QObjectStar) { qtscript = qVariantFromValue(0); } else { diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 5fecd71..275b648 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -1182,9 +1182,9 @@ bool QV8Engine::metaTypeFromJS(v8::Handle value, int type, void *data QMetaType::constructInPlace(type, data, var.constData()); return true; } - if (var.canConvert(QVariant::Type(type))) { + if (var.canConvert(type)) { QVariant vv = var; - vv.convert(QVariant::Type(type)); + vv.convert(type); Q_ASSERT(vv.userType() == type); QMetaType::constructInPlace(type, data, vv.constData()); return true; diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 95e2be7..aab66e3 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -2137,9 +2137,9 @@ void CallArgument::fromValue(int callType, QV8Engine *engine, v8::Handleconvert((QVariant::Type)callType); + qvariantPtr->convert(callType); } else if (const QMetaObject *mo = ep ? ep->rawMetaObjectForType(callType) : 0) { QObject *obj = ep->toQObject(v); diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index 2fca7ba..77d4809 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1763,7 +1763,7 @@ QAbstractAnimationJob* QQuickParallelAnimation::transition(QQuickStateActions &a void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { if (variant.userType() != QVariant::String) { - variant.convert((QVariant::Type)type); + variant.convert(type); return; } @@ -1783,7 +1783,7 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) break; default: if (QQmlValueTypeFactory::isValueType((uint)type)) { - variant.convert((QVariant::Type)type); + variant.convert(type); } else { QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type); if (converter) -- 2.7.4