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 <marco.bubke@qt.io>
This commit is contained in:
Miikka Heikkinen
2025-03-11 14:06:48 +02:00
parent 9057a796e9
commit 715ce2c36b
2 changed files with 24 additions and 8 deletions

View File

@@ -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,13 +4763,11 @@ 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));

View File

@@ -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)