QmlDesigner: Modernize Enumeration

Save some allocations and return a view instead of a new value. If you
want a value because you depend on a null terminated string you have to
use toScope() and toName().

Task-number: QDS-10290
Change-Id: Ia87b8d559fc1fe9bb1992e61da0aa86c68d53535
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2023-07-19 12:05:46 +02:00
parent 194b7d49b0
commit e204af5cac
3 changed files with 51 additions and 47 deletions

View File

@@ -437,7 +437,7 @@ QVariant ObjectNodeInstance::convertEnumToValue(const QVariant &value, const Pro
QVariant adjustedValue;
Enumeration enumeration = value.value<Enumeration>();
if (metaProperty.isValid() && metaProperty.isEnumType()) {
adjustedValue = metaProperty.enumerator().keyToValue(enumeration.name());
adjustedValue = metaProperty.enumerator().keyToValue(enumeration.toName());
} else {
QQmlExpression expression(context(), object(), enumeration.toString());
adjustedValue = expression.evaluate();