forked from qt-creator/qt-creator
QmlDesigner: Create connections inside the target element
Change-Id: I29e00e4f90d1fec2f230a989c7b04f64e8b81a9b Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <nodeabstractproperty.h>
|
#include <nodeabstractproperty.h>
|
||||||
#include <exception.h>
|
#include <exception.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
|
#include <nodelistproperty.h>
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -210,6 +211,10 @@ void ConnectionModel::updateTargetNode(int rowNumber)
|
|||||||
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
|
||||||
|
|
||||||
if (!newTarget.isEmpty()) {
|
if (!newTarget.isEmpty()) {
|
||||||
|
const ModelNode parent = connectionView()->modelNodeForId(newTarget);
|
||||||
|
if (parent.isValid() && QmlItemNode::isValidQmlItemNode(parent))
|
||||||
|
parent.nodeListProperty("data").reparentHere(connectionNode);
|
||||||
|
|
||||||
connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){
|
connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){
|
||||||
connectionNode.bindingProperty("target").setExpression(newTarget);
|
connectionNode.bindingProperty("target").setExpression(newTarget);
|
||||||
});
|
});
|
||||||
@@ -255,14 +260,21 @@ void ConnectionModel::addConnection()
|
|||||||
nodeMetaInfo.majorVersion(),
|
nodeMetaInfo.majorVersion(),
|
||||||
nodeMetaInfo.minorVersion());
|
nodeMetaInfo.minorVersion());
|
||||||
|
|
||||||
rootModelNode.nodeAbstractProperty(rootModelNode.metaInfo().defaultPropertyName()).reparentHere(newNode);
|
|
||||||
newNode.signalHandlerProperty("onClicked").setSource(QLatin1String("print(\"clicked\")"));
|
newNode.signalHandlerProperty("onClicked").setSource(QLatin1String("print(\"clicked\")"));
|
||||||
|
|
||||||
if (connectionView()->selectedModelNodes().count() == 1
|
if (connectionView()->selectedModelNodes().count() == 1) {
|
||||||
&& !connectionView()->selectedModelNodes().constFirst().id().isEmpty()) {
|
|
||||||
const ModelNode selectedNode = connectionView()->selectedModelNodes().constFirst();
|
const ModelNode selectedNode = connectionView()->selectedModelNodes().constFirst();
|
||||||
|
if (QmlItemNode::isValidQmlItemNode(selectedNode))
|
||||||
|
selectedNode.nodeAbstractProperty("data").reparentHere(newNode);
|
||||||
|
else
|
||||||
|
rootModelNode.nodeAbstractProperty(rootModelNode.metaInfo().defaultPropertyName()).reparentHere(newNode);
|
||||||
|
|
||||||
|
if (!connectionView()->selectedModelNodes().constFirst().id().isEmpty())
|
||||||
newNode.bindingProperty("target").setExpression(selectedNode.id());
|
newNode.bindingProperty("target").setExpression(selectedNode.id());
|
||||||
|
else
|
||||||
|
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
||||||
} else {
|
} else {
|
||||||
|
rootModelNode.nodeAbstractProperty(rootModelNode.metaInfo().defaultPropertyName()).reparentHere(newNode);
|
||||||
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user