forked from qt-creator/qt-creator
QmlDesigner: Fix excessive number of dot properties
In some cases there is an excessive number of dot properties. We need to check for this and filter the number of dot properties. QQmlPropertyMap cannot handle this number of objects. Task-number: QDS-13176 Change-Id: Ic0ea2c3c3d77aaab21a3219f8591a421bca3d7ef Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -821,6 +821,7 @@ extend_qtc_plugin(QmlDesigner
|
||||
qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h
|
||||
qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h
|
||||
quick2propertyeditorview.cpp quick2propertyeditorview.h
|
||||
propertyeditorutils.cpp propertyeditorutils.h
|
||||
)
|
||||
|
||||
extend_qtc_plugin(QmlDesigner
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
#include "abstractview.h"
|
||||
#include "easingcurvedialog.h"
|
||||
#include "nodemetainfo.h"
|
||||
#include "qmldesignerconstants.h"
|
||||
#include "propertyeditorutils.h"
|
||||
#include "qml3dnode.h"
|
||||
#include "qmldesignerconstants.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "qmlmodelnodeproxy.h"
|
||||
#include "qmlobjectnode.h"
|
||||
@@ -204,10 +205,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
|
||||
}
|
||||
|
||||
// Create a list of properties available for the new type
|
||||
auto propertiesAndSignals = Utils::transform<PropertyNameList>(metaInfo.properties(),
|
||||
[](const auto &property) {
|
||||
return property.name();
|
||||
});
|
||||
auto propertiesAndSignals = Utils::transform<PropertyNameList>(
|
||||
PropertyEditorUtils::filteredPropertes(metaInfo),
|
||||
[](const auto &property) { return property.name(); });
|
||||
// Add signals to the list
|
||||
for (const auto &signal : metaInfo.signalNames()) {
|
||||
if (signal.isEmpty())
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "propertyeditorqmlbackend.h"
|
||||
|
||||
#include "propertyeditortransaction.h"
|
||||
#include "propertyeditorutils.h"
|
||||
#include "propertyeditorvalue.h"
|
||||
#include "propertymetainfo.h"
|
||||
|
||||
@@ -454,7 +455,7 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q
|
||||
if (propertyEditorBenchmark().isInfoEnabled())
|
||||
time.start();
|
||||
|
||||
for (const auto &property : qmlObjectNode.modelNode().metaInfo().properties()) {
|
||||
for (const auto &property : PropertyEditorUtils::filteredPropertes(qmlObjectNode.metaInfo())) {
|
||||
auto propertyName = property.name();
|
||||
createPropertyEditorValue(qmlObjectNode,
|
||||
propertyName,
|
||||
@@ -564,7 +565,7 @@ void PropertyEditorQmlBackend::initialSetup(const TypeName &typeName, const QUrl
|
||||
{
|
||||
NodeMetaInfo metaInfo = propertyEditor->model()->metaInfo(typeName);
|
||||
|
||||
for (const auto &property : metaInfo.properties()) {
|
||||
for (const auto &property : PropertyEditorUtils::filteredPropertes(metaInfo)) {
|
||||
setupPropertyEditorValue(property.name(), propertyEditor, property.propertyType());
|
||||
}
|
||||
|
||||
@@ -683,7 +684,7 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &metaTyp
|
||||
PropertyMetaInfos separateSectionProperties;
|
||||
|
||||
// Iterate over all properties and isolate the properties which have their own template
|
||||
for (const auto &property : metaType.properties()) {
|
||||
for (const auto &property : PropertyEditorUtils::filteredPropertes(metaType)) {
|
||||
const auto &propertyName = property.name();
|
||||
if (propertyName.startsWith("__"))
|
||||
continue; // private API
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "propertyeditorutils.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
namespace PropertyEditorUtils {
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
|
||||
static bool checkIfUnkownTypeProperty(const std::vector<PropertyName> &propertyNames,
|
||||
const PropertyName &name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
PropertyName prefix = name + '.';
|
||||
|
||||
for (auto propertyName : propertyNames) {
|
||||
if (propertyName.startsWith(prefix))
|
||||
i++;
|
||||
|
||||
if (i > 10)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif //QDS_USE_PROJECTSTORAGE
|
||||
|
||||
PropertyMetaInfos filteredPropertes(const NodeMetaInfo &metaInfo)
|
||||
{
|
||||
auto properties = metaInfo.properties();
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
std::vector<TypeName> names = Utils::transform(properties, [](const PropertyMetaInfo &info) {
|
||||
return info.name();
|
||||
});
|
||||
|
||||
std::vector<PropertyName> itemProperties;
|
||||
|
||||
for (const auto &property : properties) {
|
||||
if (!property.name().contains('.') && property.propertyType().prototypes().size() == 0
|
||||
&& checkIfUnkownTypeProperty(names, property.name())) {
|
||||
itemProperties.push_back(property.name());
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.size() > 1000) {
|
||||
properties = Utils::filtered(properties, [&itemProperties](const PropertyMetaInfo &metaInfo) {
|
||||
if (metaInfo.name().contains('.')) {
|
||||
const auto splitted = metaInfo.name().split('.');
|
||||
if (std::find(itemProperties.begin(), itemProperties.end(), splitted.first())
|
||||
!= itemProperties.end())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#endif //QDS_USE_PROJECTSTORAGE
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
} // End namespace PropertyEditorUtils.
|
||||
|
||||
} // End namespace QmlDesigner.
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodemetainfo.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
namespace PropertyEditorUtils {
|
||||
|
||||
PropertyMetaInfos filteredPropertes(const NodeMetaInfo &metaInfo);
|
||||
|
||||
} // End namespace PropertyEditorUtils.
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "designmodewidget.h"
|
||||
#include "nodemetainfo.h"
|
||||
#include "nodeproperty.h"
|
||||
#include "propertyeditorutils.h"
|
||||
#include "propertyeditorview.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "qmlitemnode.h"
|
||||
@@ -713,7 +714,8 @@ void PropertyEditorNodeWrapper::setup()
|
||||
qDeleteAll(m_valuesPropertyMap.children());
|
||||
|
||||
if (QmlObjectNode qmlObjectNode = m_modelNode) {
|
||||
const PropertyMetaInfos props = m_modelNode.metaInfo().properties();
|
||||
const PropertyMetaInfos props = PropertyEditorUtils::filteredPropertes(
|
||||
m_modelNode.metaInfo());
|
||||
for (const auto &property : props) {
|
||||
const auto &propertyName = property.name();
|
||||
auto valueObject = new PropertyEditorValue(&m_valuesPropertyMap);
|
||||
@@ -834,9 +836,12 @@ PropertyEditorSubSelectionWrapper::PropertyEditorSubSelectionWrapper(const Model
|
||||
{
|
||||
QmlObjectNode qmlObjectNode(modelNode);
|
||||
|
||||
return;
|
||||
|
||||
QTC_ASSERT(qmlObjectNode.isValid(), return );
|
||||
|
||||
for (const auto &property : qmlObjectNode.modelNode().metaInfo().properties()) {
|
||||
for (const auto &property :
|
||||
PropertyEditorUtils::filteredPropertes(qmlObjectNode.modelNode().metaInfo())) {
|
||||
auto propertyName = property.name();
|
||||
createPropertyEditorValue(qmlObjectNode,
|
||||
propertyName,
|
||||
|
||||
Reference in New Issue
Block a user