[ui] support display of edges on ListAttribute children

This commit is contained in:
Yann Lanthony 2017-11-10 16:42:18 +01:00
parent bf747f69d6
commit a56ffa83b3
3 changed files with 27 additions and 4 deletions

View file

@ -14,16 +14,31 @@ Row {
readonly property point edgeAnchorPos: Qt.point(edgeAnchor.x + edgeAnchor.width/2,
edgeAnchor.y + edgeAnchor.height/2)
readonly property bool isList: attribute.type == "ListAttribute"
signal childPinCreated(var childAttribute, var pin)
signal childPinDeleted(var childAttribute, var pin)
objectName: attribute.name + "."
layoutDirection: attribute.isOutput ? Qt.RightToLeft : Qt.LeftToRight
spacing: 1
// Instantiate empty Items for each child attribute
Repeater {
model: isList ? attribute.value : ""
onItemAdded: {childPinCreated(item.childAttribute, item)}
onItemRemoved: {childPinDeleted(item.childAttribute, item)}
delegate: Item {
property var childAttribute: object
}
}
Rectangle {
id: edgeAnchor
width: 6
height: width
radius: width/2
radius: isList ? 0 : width/2
anchors.verticalCenter: parent.verticalCenter
border.color: "#3e3e3e"
color: (dropArea.containsDrag && dropArea.containsDrag) || attribute.isLink ? "#3e3e3e" : "white"
@ -59,6 +74,7 @@ Row {
readonly property alias attribute: root.attribute
readonly property alias nodeItem: root.nodeItem
readonly property bool isOutput: attribute.isOutput
readonly property alias isList: root.isList
anchors.centerIn: root.state == "Dragging" ? undefined : parent
//anchors.verticalCenter: root.verticalCenter
width: 2

View file

@ -104,7 +104,7 @@ Item {
radius: 1
border.color: root.selectedNode == node ? Qt.darker(color, 1.8) : Qt.darker(color, 1.1)
onAttributePinCreated: root._attributeToDelegate[attribute] = pin
onAttributePinCreated: registerAttributePin(attribute, pin)
onPressed: {
root.selectedNode = object
@ -137,6 +137,11 @@ Item {
}
}
function registerAttributePin(attribute, pin)
{
root._attributeToDelegate[attribute] = pin
}
// Fit graph to fill root
function fit() {
// compute bounding box

View file

@ -68,13 +68,15 @@ Rectangle {
Repeater {
model: node.attributes
delegate: Loader {
active: !object.isOutput && object.type == "File" // TODO: review this
active: !object.isOutput && object.type == "File"
|| (object.type == "ListAttribute" && object.desc.elementDesc.type == "File") // TODO: review this
sourceComponent: AttributePin {
id: inPin
nodeItem: root
attribute: object
Component.onCompleted: attributePinCreated(object, inPin)
Component.onCompleted: attributePinCreated(attribute, inPin)
onChildPinCreated: attributePinCreated(childAttribute, inPin)
}
}
}