forked from qt-creator/qt-creator
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:
@@ -4733,6 +4733,13 @@ void addSubProperties(CompoundPropertyMetaInfos &inflatedProperties,
|
|||||||
inflatedProperties.emplace_back(std::move(propertyMetaInfo));
|
inflatedProperties.emplace_back(std::move(propertyMetaInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValueOrNonListReadOnlyReference(const NodeMetaInfo &propertyType,
|
||||||
|
const PropertyMetaInfo &property)
|
||||||
|
{
|
||||||
|
return propertyType.type() == MetaInfoType::Value
|
||||||
|
|| (property.isReadOnly() && !property.isListProperty());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CompoundPropertyMetaInfos MetaInfoUtils::inflateValueProperties(PropertyMetaInfos properties)
|
CompoundPropertyMetaInfos MetaInfoUtils::inflateValueProperties(PropertyMetaInfos properties)
|
||||||
@@ -4756,12 +4763,10 @@ CompoundPropertyMetaInfos MetaInfoUtils::inflateValueAndReadOnlyProperties(Prope
|
|||||||
inflatedProperties.reserve(properties.size() * 2);
|
inflatedProperties.reserve(properties.size() * 2);
|
||||||
|
|
||||||
for (auto &property : properties) {
|
for (auto &property : properties) {
|
||||||
if (auto propertyType = property.propertyType();
|
if (auto propertyType = property.propertyType(); isValueOrNonListReadOnlyReference(propertyType, property))
|
||||||
propertyType.type() == MetaInfoType::Value || property.isReadOnly()) {
|
|
||||||
addSubProperties(inflatedProperties, property, propertyType);
|
addSubProperties(inflatedProperties, property, propertyType);
|
||||||
} else {
|
else
|
||||||
inflatedProperties.emplace_back(std::move(property));
|
inflatedProperties.emplace_back(std::move(property));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return inflatedProperties;
|
return inflatedProperties;
|
||||||
@@ -4773,8 +4778,7 @@ CompoundPropertyMetaInfos MetaInfoUtils::addInflatedValueAndReadOnlyProperties(P
|
|||||||
inflatedProperties.reserve(properties.size() * 2);
|
inflatedProperties.reserve(properties.size() * 2);
|
||||||
|
|
||||||
for (auto &property : properties) {
|
for (auto &property : properties) {
|
||||||
if (auto propertyType = property.propertyType();
|
if (auto propertyType = property.propertyType(); isValueOrNonListReadOnlyReference(propertyType, property)) {
|
||||||
propertyType.type() == MetaInfoType::Value || property.isReadOnly()) {
|
|
||||||
addSubProperties(inflatedProperties, property, propertyType);
|
addSubProperties(inflatedProperties, property, propertyType);
|
||||||
if (!property.isReadOnly())
|
if (!property.isReadOnly())
|
||||||
inflatedProperties.emplace_back(std::move(property));
|
inflatedProperties.emplace_back(std::move(property));
|
||||||
|
@@ -487,6 +487,11 @@ TEST_F(NodeMetaInfo, inflate_value_and_readonly_properties)
|
|||||||
PropertyDeclarationTraits::IsReadOnly,
|
PropertyDeclarationTraits::IsReadOnly,
|
||||||
inputDeviceId);
|
inputDeviceId);
|
||||||
auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName");
|
auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName");
|
||||||
|
auto listPropertyId = projectStorageMock.createProperty(metaInfo.id(),
|
||||||
|
"transform",
|
||||||
|
PropertyDeclarationTraits::IsList
|
||||||
|
| PropertyDeclarationTraits::IsReadOnly,
|
||||||
|
inputDeviceId);
|
||||||
|
|
||||||
auto properties = QmlDesigner::MetaInfoUtils::inflateValueAndReadOnlyProperties(
|
auto properties = QmlDesigner::MetaInfoUtils::inflateValueAndReadOnlyProperties(
|
||||||
metaInfo.properties());
|
metaInfo.properties());
|
||||||
@@ -497,7 +502,8 @@ TEST_F(NodeMetaInfo, inflate_value_and_readonly_properties)
|
|||||||
Not(Contains(CompoundPropertyIds(fontPropertyId, IsFalse(), _))),
|
Not(Contains(CompoundPropertyIds(fontPropertyId, IsFalse(), _))),
|
||||||
Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")),
|
Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")),
|
||||||
Contains(CompoundPropertyIds(pixelSizePropertyId, fontPropertyId, "font.pixelSize")),
|
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)
|
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,
|
PropertyDeclarationTraits::IsReadOnly,
|
||||||
inputDeviceId);
|
inputDeviceId);
|
||||||
auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName");
|
auto seatNamePropertyId = projectStorageMock.propertyDeclarationId(inputDeviceId, "seatName");
|
||||||
|
auto listPropertyId = projectStorageMock.createProperty(metaInfo.id(),
|
||||||
|
"transform",
|
||||||
|
PropertyDeclarationTraits::IsList
|
||||||
|
| PropertyDeclarationTraits::IsReadOnly,
|
||||||
|
inputDeviceId);
|
||||||
|
|
||||||
auto properties = QmlDesigner::MetaInfoUtils::addInflatedValueAndReadOnlyProperties(
|
auto properties = QmlDesigner::MetaInfoUtils::addInflatedValueAndReadOnlyProperties(
|
||||||
metaInfo.properties());
|
metaInfo.properties());
|
||||||
@@ -536,7 +547,8 @@ TEST_F(NodeMetaInfo, add_inflated_value_and_readonly_properties)
|
|||||||
Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")),
|
Contains(CompoundPropertyIds(familyPropertyId, fontPropertyId, "font.family")),
|
||||||
Contains(CompoundPropertyIds(pixelSizePropertyId, fontPropertyId, "font.pixelSize")),
|
Contains(CompoundPropertyIds(pixelSizePropertyId, fontPropertyId, "font.pixelSize")),
|
||||||
Not(Contains(CompoundPropertyIds(devicePropertyId, IsFalse(), _))),
|
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)
|
TEST_F(NodeMetaInfo, add_inflated_value_and_readonly_properties_handles_invalid)
|
||||||
|
Reference in New Issue
Block a user