QmlNodeEditor
NodeView Class Reference
Inheritance diagram for NodeView:
Collaboration diagram for NodeView:

Signals

void connectionAdded (int fromNodeId, int fromPortId, int toNodeId, int toPortId)
 
void connectionRemoved (int fromNodeId, int fromPortId, int toNodeId, int toPortId)
 
void nodeRemoved (int nodeId)
 
void nodePositionChanged (int nodeId, real x, real y)
 

Public Member Functions

PortsDockRow findConnectorRow (int nodeId, int portId)
 
void updateAllConnectionComponents ()
 
void updateAllConnectionComponentsByNodeId (int nodeId)
 
void addConnectionComponent (ConnectionComponent from, ConnectionComponent to, bool removable)
 
void removeAllConnectionComponents ()
 
void removeAllConnectionComponentsByNodeId (int nodeId)
 
bool removeConnectionComponent (ConnectionComponent from, ConnectionComponent to)
 
void setPortsState (string state, string filter)
 
bool checkFilterOnTags (string tags, string filter)
 

Properties

var model
 
int deleteKey
 
QtObject style
 
Component connectionShape
 
Component connectionComponent
 
Dialog nodeDeleteConfirmationDialog
 
Dialog connectionDeleteConfirmationDialog
 
Component nodeHeaderComponent
 
Component nodeTopContentComponent
 
Component nodeCenterContentComponent
 
Component nodeLeftPortComponent
 
Component nodeRightPortComponent
 
Component nodePortConnectorComponent
 
Component nodePortConnectorMouseArea
 
Component snapGridComponent
 
ObjectModel connectionsModel
 

Detailed Description

Since
1.0 The base view that manages and showing Nodes. The only required property is NodeView.model.

Node layout:

  _______________________________________________________
  |            NodeView.nodeHeaderComponent             |
  |-----------------------------------------------------|
  |          NodeView.nodeTopContentComponent           |
  |                                                     |
  |-----------------------------------------------------|
o | left  |                                     | right | o <- NodeView.nodePortConnectorComponent
o | ports | NodeView.nodeCenterContentComponent | ports | o
o | dock  |                                     | dock  | o
  |     ^ |                                     |       |
  ------|------------------------------------------------
      NodeView.nodeLeftPortComponent

Node.width = NodeView.nodeCenterContentComponent.width + NodeView.style.leftPortDockWidth + NodeView.style.rightPortDockWidth

Node.height = NodeView.nodeHeaderComponent.height + NodeView.nodeTopContentComponent.height + max(left ports dock, NodeView.nodeCenterContentComponent, right ports dock)

Definition at line 31 of file NodeView.qml.

Member Function Documentation

◆ addConnectionComponent()

void NodeView::addConnectionComponent ( ConnectionComponent  from,
ConnectionComponent  to,
bool  removable 
)

Create ConnectionComponent and add it to the NodeView.connectionsModel

Parameters
fromConnection from
toConnection to
removableIs connection removable

◆ checkFilterOnTags()

bool NodeView::checkFilterOnTags ( string  tags,
string  filter 
)

Check the filter on the given tags

Parameters
tagsTags to check. If tags are not defined, then only undefined filter will match them.
filterFilter string to check. Undefined filter always match.
Returns
Match or not.

◆ connectionAdded

void NodeView::connectionAdded ( int  fromNodeId,
int  fromPortId,
int  toNodeId,
int  toPortId 
)
signal

Connection between two ports added.

Note
connections list in the NodeView.model will not be updated by the NodeView, it should be updated explicitly.
Parameters
fromNodeIdconnection added from Node id
fromPortIdconnection added from Port id
toNodeIdconnection added to Node id
toPortIdconnection added to Port id

◆ connectionRemoved

void NodeView::connectionRemoved ( int  fromNodeId,
int  fromPortId,
int  toNodeId,
int  toPortId 
)
signal

Connection between two ports removed.

Note
connections list in the NodeView.model will not be updated by the NodeView, it should be updated explicitly.
Parameters
fromNodeIdconnection removed from Node id
fromPortIdconnection removed from Port id
toNodeIdconnection removed to Node id
toPortIdconnection removed to Port id

◆ findConnectorRow()

PortsDockRow NodeView::findConnectorRow ( int  nodeId,
int  portId 
)

Find the PortsDockRow by Node id and Port id.

Parameters
nodeIdNode id
portIdPort id
Returns
PortsDockRow or undefined

◆ nodePositionChanged

void NodeView::nodePositionChanged ( int  nodeId,
real  x,
real  y 
)
signal

Node position changed.

Note
model will be updated by the NodeView
Parameters
nodeIdremoved Node id
xx coordinate relative to NodeView
yy coordinate relative to NodeView

◆ nodeRemoved

void NodeView::nodeRemoved ( int  nodeId)
signal

Node removed

Note
NodeView.model will not be updated by the NodeView, it should be updated explicitly.
Parameters
nodeIdremoved Node id

◆ removeAllConnectionComponents()

void NodeView::removeAllConnectionComponents ( )

Remove all ConnectionComponent from NodeView.connectionsModel and destroy them.

◆ removeAllConnectionComponentsByNodeId()

void NodeView::removeAllConnectionComponentsByNodeId ( int  nodeId)

Remove ConnectionComponent from or to specified Node from NodeView.connectionsModel and destroy them.

Parameters
nodeIdNode id

◆ removeConnectionComponent()

bool NodeView::removeConnectionComponent ( ConnectionComponent  from,
ConnectionComponent  to 
)

Remove ConnectionComponent from NodeView.connectionsModel and destroy it.

Parameters
from
to
Returns
true if first found connection was removed

◆ setPortsState()

void NodeView::setPortsState ( string  state,
string  filter 
)

Set the state of PortsDockRow

Parameters
statePortsDockRow.state, see PortsDockRow.states
filterSet the state to the filtered PortsDockRow, use undefined to apply state for all PortsDockRow.

◆ updateAllConnectionComponents()

void NodeView::updateAllConnectionComponents ( )

Clear NodeView.connectionsModel and recreate them from NodeView.model.

◆ updateAllConnectionComponentsByNodeId()

void NodeView::updateAllConnectionComponentsByNodeId ( int  nodeId)

Remove connections from and to specified Node from NodeView.connectionsModel and recreate them from NodeView.model.

Parameters
nodeIdNode id

Property Documentation

◆ connectionComponent

Component NodeView::connectionComponent
read

Underlaying component that manages the connectionShape position, state and events.

Default: ConnectionComponent.

Definition at line 1 of file NodeView.qml.

◆ connectionDeleteConfirmationDialog

Dialog NodeView::connectionDeleteConfirmationDialog
read

Connection deletion comfirmation dialog.

Default: ConnectionDeleteConfirmationDialog.

PortsDockRow from and PortsDockRow to are available in the scope.

Definition at line 1 of file NodeView.qml.

◆ connectionShape

Component NodeView::connectionShape
read

The Shape that renders Connection, see ConnectionShape. Following properties can be bound to the parent component:

property real startX: parent.startX
property real startY: parent.startY
property real endX: parent.endX
property real endY: parent.endY
property string state: parent.state // "focused", "hovered"
property QtObject style: parent.style
property point fromPortPosition: parent.fromPortPosition // From Port side on the Node, fromPortPosition.x === -1 if port is on the left side, 1 on the right
property point toPortPosition: parent.toPortPosition // To Port side on the Node, toPortPosition.x === -1 if port is on the left side, 1 on the right
QtObject style
Definition: NodeView.qml:141

Definition at line 1 of file NodeView.qml.

◆ connectionsModel

ObjectModel NodeView::connectionsModel
read

The underlaying model with the list of ConnectionComponent items.

Definition at line 1 of file NodeView.qml.

◆ deleteKey

int NodeView::deleteKey
read

Key that can be used to show Node or Connection Delete dialog on selected Node or Connection. Default Qt.Key_Delete.

Definition at line 1 of file NodeView.qml.

◆ model

var NodeView::model
read

Any row-based model should be supported, tested with a ListModel and a custom implementation of QAbstractListModel. The following roles are used by the NodeView in the model:

  • Node 1:
    • nodeId: int Required. Used to identify the Node
    • x: int Required. Horizontal Node position relative to the NodeView
    • y: int Required. Vertical Node position relative to the NodeView
    • removable: bool. Whether this Node can be removed.
    • leftPorts: [map<string, var>] or [ListElement] Required. Connection Ports that will be displayed at the left side
      • portId: int Required. Used to identify the Port in the Node, must be unique for the Node
      • filter: string. Comma separated string with the Tags. If specified, the Port can be connected with the another Port only when any Tag from the filter property matches with any tag from the tags property of the another port.
      • tags: string. Comma separated string with the Tags, see filter.
    • rightPorts: [map<string, var>] or [ListElement] Required. Connection Ports that will be displayed at the right side.
      • ...see leftPorts
    • connections: [map<string, var>] or [ListElement] Required. The list of connections between Ports.
      • fromNodeId: int Required. Connection from Node with nodeId.
      • fromPortId: int Required. Connection from Port width portId.
      • toNodeId: int Required. Connection to Node with nodeId.
      • toPortId: int Required. Connection to Port with portId.
      • removable: bool. Whether this Connection can be removed.

Example model:

ListModel {
ListElement {
nodeId: 1
name: "Node 1"
x: 100
y: 100
leftPorts: [
ListElement {
portId: 1
name: "Port 1"
filter: "output"
tags: "input"
},
ListElement {
portId: 2
name: "Port 2"
filter: "output"
tags: "input"
}
]
rightPorts: [
ListElement {
portId: 3
name: "Port 3"
},
ListElement {
portId: 4
name: "Port 4"
}
]
connections: []
}
ListElement {
nodeId: 2
x: 300
y: 200
name: "Node 2"
removable: true
leftPorts: [
ListElement {
portId: 1
name: "Port 1"
},
ListElement {
portId: 2
name: "Port 2"
}
]
rightPorts: [
ListElement {
portId: 3
name: "Port 3"
filter: "input"
tags: "output"
}
]
connections: [
ListElement {
fromNodeId: 2
fromPortId: 1
toNodeId: 1
toPortId: 2
},
ListElement {
fromNodeId: 2
fromPortId: 1
toNodeId: 1
toPortId: 1
removable: true
}
]
}
}

Definition at line 1 of file NodeView.qml.

◆ nodeCenterContentComponent

Component NodeView::nodeCenterContentComponent
read

Renders center content area in the Node, between left and right PortsDock. Component height must be defined, because it's used to calculate Node height.

Default: NodeCenterContent.

var nodeModel is available in the scope.

Definition at line 1 of file NodeView.qml.

◆ nodeDeleteConfirmationDialog

Dialog NodeView::nodeDeleteConfirmationDialog
read

Node deletion comfirmation dialog.

Default: NodeDeleteConfirmationDialog.

var nodeModel is available in the scope.

Definition at line 1 of file NodeView.qml.

◆ nodeHeaderComponent

Component NodeView::nodeHeaderComponent
read

Renders the Node header. Component height must be defined, because it's used to calculate Node height.

Default: NodeHeader.

var nodeModel is available in the scope.

Definition at line 1 of file NodeView.qml.

◆ nodeLeftPortComponent

Component NodeView::nodeLeftPortComponent
read

Renders left port description.

Default: NodeLeftPort

The following properties are available in the scope:

  • var portModel
  • var nodeModel
  • string state // "highlighted", "hovered"
  • QtObject style

Definition at line 1 of file NodeView.qml.

◆ nodePortConnectorComponent

Component NodeView::nodePortConnectorComponent
read

Renders connection point near the PortsDockRow

Default: NodePortConnector

The following properties are available in the scope:

  • var portModel
  • var nodeModel
  • string state // "highlighted", "hovered"
  • QtObject style

Definition at line 1 of file NodeView.qml.

◆ nodePortConnectorMouseArea

Component NodeView::nodePortConnectorMouseArea
read

Underlaying component that manages the NodePortConnector events.

Default: NodePortConnectorMouseArea

Definition at line 1 of file NodeView.qml.

◆ nodeRightPortComponent

Component NodeView::nodeRightPortComponent
read

Renders right port description.

Default: NodeRightPort

The following properties are available in the scope:

  • var portModel
  • var nodeModel
  • string state // "highlighted", "hovered"
  • QtObject style

Definition at line 1 of file NodeView.qml.

◆ nodeTopContentComponent

Component NodeView::nodeTopContentComponent
read

Renders top content area in the Node. Component height must be defined, because it's used to calculate Node height.

Default: NodeTopContent.

var nodeModel is available in the scope.

Definition at line 1 of file NodeView.qml.

◆ snapGridComponent

Component NodeView::snapGridComponent
read

The SnapGrid component.

Default: SnapGrid

An implementation should provide function function snapPosition(point) => point

Definition at line 1 of file NodeView.qml.

◆ style

QtObject NodeView::style
read

Style object, see NodeViewStyle

Definition at line 1 of file NodeView.qml.


The documentation for this class was generated from the following file: