From 715ce2c36b2476bf68112bc43f1343c05d3a5791 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 11 Mar 2025 14:06:48 +0200 Subject: [PATCH] QmlDesigner: List type properties should never be split to subproperties Skip subproperty generation for list properties, as it doesn't make sense to have subproperties for them. Fixes: QDS-14882 Change-Id: I751a603ad375cc00b46652f46e80a9f65b132d8e Reviewed-by: Marco Bubke --- .../libs/designercore/metainfo/nodemetainfo.cpp | 16 ++++++++++------ .../unittests/metainfo/nodemetainfo-test.cpp | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp index 4c98763660d..f863cc1addf 100644 --- a/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/libs/designercore/metainfo/nodemetainfo.cpp @@ -4733,6 +4733,13 @@ void addSubProperties(CompoundPropertyMetaInfos &inflatedProperties, inflatedProperties.emplace_back(std::move(propertyMetaInfo)); } +bool isValueOrNonListReadOnlyReference(const NodeMetaInfo &propertyType, + const PropertyMetaInfo &property) +{ + return propertyType.type() == MetaInfoType::Value + || (property.isReadOnly() && !property.isListProperty()); +} + } // namespace CompoundPropertyMetaInfos MetaInfoUtils::inflateValueProperties(PropertyMetaInfos properties) @@ -4756,12 +4763,10 @@ CompoundPropertyMetaInfos MetaInfoUtils::inflateValueAndReadOnlyProperties(Prope inflatedProperties.reserve(properties.size() * 2); for (auto &property : properties) { - if (auto propertyType = property.propertyType(); - propertyType.type() == MetaInfoType::Value || property.isReadOnly()) { + if (auto propertyType = property.propertyType(); isValueOrNonListReadOnlyReference(propertyType, property)) addSubProperties(inflatedProperties, property, propertyType); - } else { + else inflatedProperties.emplace_back(std::move(property)); - } } return inflatedProperties; @@ -4773,8 +4778,7 @@ CompoundPropertyMetaInfos MetaInfoUtils::addInflatedValueAndReadOnlyProperties(P inflatedProperties.reserve(properties.size() * 2); for (auto &property : properties) { - if (auto propertyType = property.propertyType(); - propertyType.type() == MetaInfoType::Value || property.isReadOnly()) { + if (auto propertyType = property.propertyType(); isValueOrNonListReadOnlyReference(propertyType, property)) { addSubProperties(inflatedProperties, property, propertyType); if (!property.isReadOnly()) inflatedProperties.emplace_back(std::move(property)); diff --git a/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp b/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp index 0ace7a2c578..5b957f15b8d 100644 --- a/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp +++ b/tests/unit/tests/unittests/metainfo/nodemetainfo-test.cpp @@ -487,6 +487,11 @@ TEST_F(NodeMetaInfo, inflate_value_and_readonly_properties) PropertyDeclarationTraits::IsReadOnly, inputDeviceId); auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName"); + auto listPropertyId = projectStorageMock.createProperty(metaInfo.id(), + "transform", + PropertyDeclarationTraits::IsList + | PropertyDeclarationTraits::IsReadOnly, + inputDeviceId); auto properties = QmlDesigner::MetaInfoUtils::inflateValueAndReadOnlyProperties( metaInfo.properties()); @@ -497,7 +502,8 @@ TEST_F(NodeMetaInfo, inflate_value_and_readonly_properties) Not(Contains(CompoundPropertyIds(fontPropertyId, IsFalse(), _))), Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")), Contains(CompoundPropertyIds(pixelSizePropertyId, fontPropertyId, "font.pixelSize")), - Contains(CompoundPropertyIds(seatNamePropertyId, devicePropertyId, "device.seatName")))); + Contains(CompoundPropertyIds(seatNamePropertyId, devicePropertyId, "device.seatName")), + Not(Contains(CompoundPropertyIds(seatNamePropertyId, listPropertyId, _))))); } TEST_F(NodeMetaInfo, inflate_value_and_readonly_properties_handles_invalid) @@ -525,6 +531,11 @@ TEST_F(NodeMetaInfo, add_inflated_value_and_readonly_properties) PropertyDeclarationTraits::IsReadOnly, inputDeviceId); auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName"); + auto listPropertyId = projectStorageMock.createProperty(metaInfo.id(), + "transform", + PropertyDeclarationTraits::IsList + | PropertyDeclarationTraits::IsReadOnly, + inputDeviceId); auto properties = QmlDesigner::MetaInfoUtils::addInflatedValueAndReadOnlyProperties( metaInfo.properties()); @@ -536,7 +547,8 @@ TEST_F(NodeMetaInfo, add_inflated_value_and_readonly_properties) Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")), Contains(CompoundPropertyIds(pixelSizePropertyId, fontPropertyId, "font.pixelSize")), Not(Contains(CompoundPropertyIds(devicePropertyId, IsFalse(), _))), - Contains(CompoundPropertyIds(seatNamePropertyId, devicePropertyId, "device.seatName")))); + Contains(CompoundPropertyIds(seatNamePropertyId, devicePropertyId, "device.seatName")), + Not(Contains(CompoundPropertyIds(seatNamePropertyId, listPropertyId, _))))); } TEST_F(NodeMetaInfo, add_inflated_value_and_readonly_properties_handles_invalid)