diff options
-rw-r--r-- | src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h | 10 | ||||
-rw-r--r-- | src/plugins/sceneparsers/gltf/gltfimporter.cpp | 4 | ||||
-rw-r--r-- | src/plugins/sceneparsers/gltfexport/gltfexporter.cpp | 12 | ||||
-rw-r--r-- | src/render/materialsystem/filterkey.cpp | 4 | ||||
-rw-r--r-- | src/render/materialsystem/qparameter.cpp | 4 | ||||
-rw-r--r-- | src/render/shadergraph/qshadergraphloader.cpp | 12 | ||||
-rw-r--r-- | src/render/shadergraph/qshadernodesloader.cpp | 12 | ||||
-rw-r--r-- | tests/auto/render/gltfplugins/tst_gltfplugins.cpp | 21 | ||||
-rw-r--r-- | tests/auto/render/qray3d/tst_qray3d.cpp | 4 |
9 files changed, 78 insertions, 5 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h b/src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h index f059012da..411c05d08 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h +++ b/src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h @@ -96,9 +96,13 @@ public: static QVarLengthArray<char, 64> array(16 * byteSize); memset(array.data(), 0, array.size()); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) switch (v.metaType().id()) { +#else + switch (v.type()) { +#endif - // 1 byte + // 1 byte case QMetaType::Bool: { T data = v.value<bool>(); memcpy(array.data(), &data, byteSize); @@ -332,7 +336,11 @@ public: } } else +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) qWarning() << Q_FUNC_INFO << "QVariant type conversion not handled for " << v.metaType().id(); +#else + qWarning() << Q_FUNC_INFO << "QVariant type conversion not handled for " << v.type(); +#endif break; } diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp index 7588eb517..f9edc158d 100644 --- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp +++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp @@ -1855,7 +1855,11 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json) target->setProperty(propName.constData(), QVariant(size)); } } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QMetaType propType = target->property(propName.constData()).metaType(); +#else + const QMetaType propType(target->property(propName.constData()).type()); +#endif if (propType.id() == QMetaType::Int) { target->setProperty(propName.constData(), QVariant(it.value().toInt())); } else { diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index 6847b4897..21396b215 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -662,7 +662,11 @@ void GLTFExporter::parseMaterials() if (material->effect()) { QList<QParameter *> parameters = material->effect()->parameters(); for (auto param : parameters) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (param->value().metaType().id() == QMetaType::QColor) { +#else + if (param->value().type() == QMetaType::QColor) { +#endif QColor color = param->value().value<QColor>(); if (param->name() == MATERIAL_AMBIENT_COLOR) { matInfo.colors.insert(QStringLiteral("ambient"), color); @@ -1799,7 +1803,11 @@ void GLTFExporter::exportParameter(QJsonObject &jsonObj, const QString &name, paramObj[typeStr] = GL_SAMPLER_2D; paramObj[valueStr] = m_textureIdMap.value(textureVariantToUrl(variant)); } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) switch (variant.metaType().id()) { +#else + switch (variant.type()) { +#endif case QMetaType::Bool: paramObj[typeStr] = GL_BOOL; paramObj[valueStr] = variant.toBool(); @@ -2071,7 +2079,11 @@ QString GLTFExporter::textureVariantToUrl(const QVariant &var) void GLTFExporter::setVarToJSonObject(QJsonObject &jsObj, const QString &key, const QVariant &var) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) switch (var.metaType().id()) { +#else + switch (var.type()) { +#endif case QMetaType::Bool: jsObj[key] = var.toBool(); break; diff --git a/src/render/materialsystem/filterkey.cpp b/src/render/materialsystem/filterkey.cpp index c3ed62924..778a9ee75 100644 --- a/src/render/materialsystem/filterkey.cpp +++ b/src/render/materialsystem/filterkey.cpp @@ -92,7 +92,11 @@ bool FilterKey::operator ==(const FilterKey &other) // https://codereview.qt-project.org/#/c/204484/ // and adding the following early comparison of the types should give // an equivalent performance gain: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return (other.value().metaType() == value().metaType() && +#else + return (other.value().type() == value().type() && +#endif other.name() == name() && other.value() == value()); } diff --git a/src/render/materialsystem/qparameter.cpp b/src/render/materialsystem/qparameter.cpp index 2ce0d172c..fc74155dc 100644 --- a/src/render/materialsystem/qparameter.cpp +++ b/src/render/materialsystem/qparameter.cpp @@ -199,7 +199,11 @@ inline QVariant toBackendValue(const QVariant &v) void QParameterPrivate::setValue(const QVariant &v) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (v.metaType().id() == QMetaType::QVariantList) { +#else + if (v.type() == QVariant::List) { +#endif QSequentialIterable iterable = v.value<QSequentialIterable>(); QVariantList variants; variants.reserve(iterable.size()); diff --git a/src/render/shadergraph/qshadergraphloader.cpp b/src/render/shadergraph/qshadergraphloader.cpp index 3d95ba69c..766140630 100644 --- a/src/render/shadergraph/qshadergraphloader.cpp +++ b/src/render/shadergraph/qshadergraphloader.cpp @@ -188,7 +188,11 @@ void QShaderGraphLoader::load() if (parameterValue.isObject()) { const QJsonObject parameterObject = parameterValue.toObject(); const QString type = parameterObject.value(QStringLiteral("type")).toString(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QMetaType typeId = QMetaType::fromName(type.toUtf8()); +#else + const QMetaType typeId(QMetaType::type(type.toUtf8())); +#endif const QString value = parameterObject.value(QStringLiteral("value")).toString(); auto variant = QVariant(value); @@ -200,9 +204,17 @@ void QShaderGraphLoader::load() const QMetaEnum metaEnum = metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); const int enumValue = metaEnum.keyToValue(value.toUtf8()); variant = QVariant(enumValue); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) variant.convert(typeId); +#else + variant.convert(typeId.id()); +#endif } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) variant.convert(typeId); +#else + variant.convert(typeId.id()); +#endif } node.setParameter(parameterName, variant); } else { diff --git a/src/render/shadergraph/qshadernodesloader.cpp b/src/render/shadergraph/qshadernodesloader.cpp index f1239d749..e20e4e3bc 100644 --- a/src/render/shadergraph/qshadernodesloader.cpp +++ b/src/render/shadergraph/qshadernodesloader.cpp @@ -162,7 +162,11 @@ void QShaderNodesLoader::load(const QJsonObject &prototypesObject) if (parameterValue.isObject()) { const QJsonObject parameterObject = parameterValue.toObject(); const QString type = parameterObject.value(QStringLiteral("type")).toString(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QMetaType typeId = QMetaType::fromName(type.toUtf8()); +#else + const QMetaType typeId(QMetaType::type(type.toUtf8())); +#endif const QString value = parameterObject.value(QStringLiteral("value")).toString(); auto variant = QVariant(value); @@ -174,9 +178,17 @@ void QShaderNodesLoader::load(const QJsonObject &prototypesObject) const QMetaEnum metaEnum = metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); const int enumValue = metaEnum.keyToValue(value.toUtf8()); variant = QVariant(enumValue); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) variant.convert(typeId); +#else + variant.convert(typeId.id()); +#endif } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) variant.convert(typeId); +#else + variant.convert(typeId.id()); +#endif } node.setParameter(parameterName, variant); } else { diff --git a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp index 751aa814a..e57829b74 100644 --- a/tests/auto/render/gltfplugins/tst_gltfplugins.cpp +++ b/tests/auto/render/gltfplugins/tst_gltfplugins.cpp @@ -789,15 +789,24 @@ void tst_gltfPlugins::compareComponents(Qt3DCore::QComponent *c1, Qt3DCore::QCom auto property = c1->metaObject()->property(i); auto v1 = c1->property(property.name()); auto v2 = c2->property(property.name()); - if (v1.metaType().id() == QMetaType::Bool) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const auto v1TypeId = v1.metaType().id(); +#else + const auto v1TypeId = v1.type(); +#endif + if (v1TypeId == QMetaType::Bool) { QCOMPARE(v1.toBool(), v2.toBool()); - } else if (v1.metaType().id() == QMetaType::QColor) { + } else if (v1TypeId == QMetaType::QColor) { QCOMPARE(v1.value<QColor>(), v2.value<QColor>()); - } else if (v1.metaType().id() == QMetaType::QVector3D) { + } else if (v1TypeId == QMetaType::QVector3D) { QCOMPARE(v1.value<QVector3D>(), v2.value<QVector3D>()); - } else if (v1.metaType().id() == QMetaType::QMatrix4x4) { + } else if (v1TypeId == QMetaType::QMatrix4x4) { QCOMPARE(v1.value<QMatrix4x4>(), v2.value<QMatrix4x4>()); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) } else if (QMetaType::canConvert(v1.metaType(), QMetaType(QMetaType::Float))) { +#else + } else if (v1.canConvert(QMetaType::Float)) { +#endif QVERIFY(qFuzzyCompare(v1.toFloat(), v2.toFloat())); } } @@ -879,7 +888,11 @@ void tst_gltfPlugins::compareParameters(const QList<Qt3DRender::QParameter *> &p for (auto p2 : params2) { if (p1->name() == p2->name()) { pMatch = true; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (p1->value().metaType().id() == QMetaType::QColor) { +#else + if (p1->value().type() == QMetaType::QColor) { +#endif // Colors are imported as QVector4Ds QColor color = p1->value().value<QColor>(); QVector4D vec = p2->value().value<QVector4D>(); diff --git a/tests/auto/render/qray3d/tst_qray3d.cpp b/tests/auto/render/qray3d/tst_qray3d.cpp index 7f8f934c6..92ee11dcb 100644 --- a/tests/auto/render/qray3d/tst_qray3d.cpp +++ b/tests/auto/render/qray3d/tst_qray3d.cpp @@ -517,7 +517,11 @@ void tst_QRay3D::properties() void tst_QRay3D::metaTypes() { int id = qMetaTypeId<Qt3DRender::RayCasting::QRay3D>(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QVERIFY(QMetaType::fromName("Qt3DRender::RayCasting::QRay3D").id() == id); +#else + QVERIFY(QMetaType::type("Qt3DRender::RayCasting::QRay3D") == id); +#endif QCOMPARE(QByteArray(QMetaType(id).name()), QByteArray("Qt3DRender::RayCasting::QRay3D")); QVERIFY(QMetaType::isRegistered(id)); } |