diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 96feb7eac9d..4a13ee3ee9c 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -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 diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 591ce5a57fe..4eacc575baa 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -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(metaInfo.properties(), - [](const auto &property) { - return property.name(); - }); + auto propertiesAndSignals = Utils::transform( + PropertyEditorUtils::filteredPropertes(metaInfo), + [](const auto &property) { return property.name(); }); // Add signals to the list for (const auto &signal : metaInfo.signalNames()) { if (signal.isEmpty()) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index b4f0e3ea2f3..36af894db15 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -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 diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.cpp new file mode 100644 index 00000000000..3af4c1abe83 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.cpp @@ -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 &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 names = Utils::transform(properties, [](const PropertyMetaInfo &info) { + return info.name(); + }); + + std::vector 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. diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.h new file mode 100644 index 00000000000..2d675d37ba2 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorutils.h @@ -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 + +namespace QmlDesigner { + +namespace PropertyEditorUtils { + +PropertyMetaInfos filteredPropertes(const NodeMetaInfo &metaInfo); + +} // End namespace PropertyEditorUtils. + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index f8e1711d7df..91eb87e339f 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -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,