QmlDesigner: Equate type var to type variant

Task-number: QDS-11395
Change-Id: Id81ad38f0fa07ce783c93ece70a856ab65cfcbbf
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Aleksei German
2023-11-24 18:11:50 +01:00
parent 8238764dcd
commit ef2f76b2d8
4 changed files with 12 additions and 5 deletions

View File

@@ -516,6 +516,8 @@ Section {
return aliasEditor return aliasEditor
if (propertyType == "variant") if (propertyType == "variant")
return readonlyEditor return readonlyEditor
if (propertyType == "var")
return readonlyEditor
if (propertyType == "TextureInput") if (propertyType == "TextureInput")
return textureInputEditor return textureInputEditor
if (propertyType == "vector2d" || propertyType == "vector3d" || propertyType == "vector4d") if (propertyType == "vector2d" || propertyType == "vector3d" || propertyType == "vector4d")

View File

@@ -75,7 +75,7 @@ NodeMetaInfo dynamicTypeNameToNodeMetaInfo(const TypeName &typeName, Model *mode
return model->metaInfo("QML.string"); return model->metaInfo("QML.string");
else if (typeName == "url") else if (typeName == "url")
return model->metaInfo("QML.url"); return model->metaInfo("QML.url");
else if (typeName == "variant") else if (typeName == "var" || typeName == "variant")
return model->metaInfo("QML.variant"); return model->metaInfo("QML.variant");
else else
qWarning() << __FUNCTION__ << " type " << typeName << "not found"; qWarning() << __FUNCTION__ << " type " << typeName << "not found";
@@ -212,7 +212,7 @@ bool isDynamicVariantPropertyType(const TypeName &type)
{ {
// "variant" is considered value type as it is initialized as one. // "variant" is considered value type as it is initialized as one.
// This may need to change if we provide any kind of proper editor for it. // This may need to change if we provide any kind of proper editor for it.
static const QSet<TypeName> valueTypes{"int", "real", "color", "string", "bool", "url", "variant"}; static const QSet<TypeName> valueTypes{"int", "real", "color", "string", "bool", "url", "var", "variant"};
return valueTypes.contains(type); return valueTypes.contains(type);
} }
@@ -231,7 +231,7 @@ QVariant defaultValueForType(const TypeName &type)
value = false; value = false;
else if (type == "url") else if (type == "url")
value = ""; value = "";
else if (type == "variant") else if (type == "var" || type == "variant")
value = ""; value = "";
return value; return value;

View File

@@ -3108,7 +3108,12 @@ bool NodeMetaInfo::isVariant() const
using namespace Storage::Info; using namespace Storage::Info;
return isValid() && isTypeId(m_typeId, m_projectStorage->builtinTypeId<QVariant>()); return isValid() && isTypeId(m_typeId, m_projectStorage->builtinTypeId<QVariant>());
} else { } else {
return isValid() && simplifiedTypeName() == "QVariant"; if (!isValid())
return false;
const auto type = simplifiedTypeName();
return type == "QVariant" || type == "var" || type == "variant";
} }
} }

View File

@@ -311,7 +311,7 @@ QVariant BindingProperty::convertToLiteral(const TypeName &typeName, const QStri
qreal realValue = testExpression.toDouble(&ok); qreal realValue = testExpression.toDouble(&ok);
if (ok) if (ok)
return realValue; return realValue;
} else if ("QVariant" == typeName || "variant" == typeName) { } else if ("QVariant" == typeName || "variant" == typeName || "var" == typeName) {
bool ok; bool ok;
qreal realValue = testExpression.toDouble(&ok); qreal realValue = testExpression.toDouble(&ok);
if (ok) { if (ok) {