2 import QtQuick.Controls 2.15
5 id: connectionComponent
8 required
property Item from
9 required
property Item to
10 required
property Component connectionShape
11 required
property QtObject style
12 required
property bool removable
14 property Item fromNodeRoot
15 property Item toNodeRoot
18 id: connectionShapeLoader
21 property real startX: 0
22 property real startY: 0
25 property QtObject style: parent.style
26 property string state: parent.state
28 property point fromPortPosition
29 property point toPortPosition
31 sourceComponent: connectionShape
33 Binding on fromPortPosition {
34 value:
if (from) from.relativeConnectorX < 0 ?
"-1, 0" :
"1, 0"
38 Binding on toPortPosition {
39 value:
if (to) to.relativeConnectorX < 0 ?
"-1, 0" :
"1, 0"
44 Binding on fromNodeRoot {
45 value:
if (from) from.getNodeRoot()
49 Binding on toNodeRoot {
50 value:
if (to) to.getNodeRoot()
54 containmentMask: connectionShapeLoader.item
56 activeFocusOnTab:
true
71 enabled: connectionComponent.state !==
"focused"
75 enabled: connectionComponent.state !==
"focused"
76 acceptedButtons: Qt.LeftButton
77 onTapped: forceActiveFocus();
80 Keys.onPressed: (event) => {
81 if (connectionComponent.removable && event.key === nodeView.deleteKey) {
82 showConnectionDeleteDialog();
83 event.accepted =
true;
88 id: connectionDeleteConfirmationDialogLoader
89 property alias from: connectionComponent.from
90 property alias to: connectionComponent.to
91 sourceComponent: nodeView.connectionDeleteConfirmationDialog
94 target: connectionDeleteConfirmationDialogLoader.item
95 function onAccepted() {
96 connectionDeleteConfirmationDialogLoader.active =
false;
97 nodeView.connectionRemoved(connectionComponent.from.nodeId, connectionComponent.from.portId,
98 connectionComponent.to.nodeId, connectionComponent.to.portId);
101 function showConnectionDeleteDialog() {
102 connectionDeleteConfirmationDialogLoader.item.open();
105 function updateFromX() {
106 connectionShapeLoader.startX = fromNodeRoot.x + from.relativeConnectorX;
108 function updateFromY() {
109 connectionShapeLoader.startY = fromNodeRoot.y + from.relativeConnectorY;
111 function updateToX() {
112 connectionShapeLoader.endX = toNodeRoot.x + to.relativeConnectorX;
114 function updateToY() {
115 connectionShapeLoader.endY = toNodeRoot.y + to.relativeConnectorY;
117 function updateAll() {
127 function onXChanged() {
131 function onYChanged() {
139 function onXChanged() {
143 function onYChanged() {
151 function onRelativeConnectorXChanged() {
155 function onRelativeConnectorYChanged() {
163 function onRelativeConnectorXChanged() {
167 function onRelativeConnectorYChanged() {
172 Component.onCompleted: {