QmlDesigner: Add QmlObjectNode::getAllConnections

Change-Id: Id6fa6ecdf1173eea1087057f4317dd1a9c3f6b17
Reviewed-by: Aleksei German <aleksei.german@qt.io>
This commit is contained in:
Thomas Hartmann
2022-09-19 17:07:40 +02:00
parent 9ffc004beb
commit f639f72c14
2 changed files with 15 additions and 0 deletions

View File

@@ -140,6 +140,8 @@ public:
QList<ModelNode> allTimelines() const;
QList<ModelNode> getAllConnections() const;
protected:
NodeInstance nodeInstance() const;
QmlObjectNode nodeForInstance(const NodeInstance &instance) const;

View File

@@ -45,6 +45,7 @@
#include <qmldesignerplugin.h>
#endif
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QRegularExpression>
@@ -608,6 +609,18 @@ QList<ModelNode> QmlObjectNode::allTimelines() const
return timelineNodes;
}
QList<ModelNode> QmlObjectNode::getAllConnections() const
{
if (!isValid())
return {};
auto list = view()->allModelNodesOfType("QtQuick.Connections");
return Utils::filtered(list, [this](const ModelNode &connection) {
return connection.hasBindingProperty("target")
&& connection.bindingProperty("target").resolveToModelNode() == modelNode();
});
}
/*!
Removes a variant property of the object specified by \a name from the
model.