forked from qt-creator/qt-creator
Remove connected edge when Pin is hidden
Change-Id: I327a49846dce161cc1968428f497d56809c81050 Reviewed-by: Karol Herda <khe@spyro-soft.com>
This commit is contained in:
@@ -123,12 +123,12 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
delegate: StudioControls.CheckBox {
|
delegate: StudioControls.CheckBox {
|
||||||
actionIndicator.visible: false
|
actionIndicator.visible: false
|
||||||
checkState: (modelData.enabled === undefined || modelData.enabled === true) ? Qt.Checked : Qt.UnChecked
|
checked: (modelData.enabled === undefined || modelData.enabled === true)
|
||||||
text: "pin: " + modelData.name
|
text: "pin: " + modelData.name
|
||||||
width: implicitWidth + StudioTheme.Values.toolbarHorizontalMargin
|
width: implicitWidth + StudioTheme.Values.toolbarHorizontalMargin
|
||||||
|
|
||||||
onToggled: {
|
onToggled: {
|
||||||
contextMenu.node.item.switchPin(modelData.id);
|
contextMenu.node.item.switchPin(modelData.id, checked);
|
||||||
contextMenu.node.item.updatePinVisibility(modelData.id);
|
contextMenu.node.item.updatePinVisibility(modelData.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,27 +27,49 @@ Qan.NodeItem {
|
|||||||
property string type
|
property string type
|
||||||
property string uuid: NodeGraphEditorBackend.widget.generateUUID()
|
property string uuid: NodeGraphEditorBackend.widget.generateUUID()
|
||||||
|
|
||||||
function switchPin(pin_id) {
|
function switchPin(pin_id, value) {
|
||||||
root.portsMetaData.pin.forEach(data => {
|
root.portsMetaData.pin.forEach(data => {
|
||||||
if (data.id == pin_id) {
|
if (data.id == pin_id) {
|
||||||
if (data.enabled === false)
|
data.enabled = value;
|
||||||
data.enabled = true;
|
|
||||||
else
|
|
||||||
data.enabled = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePinVisibility(pin_id) {
|
function updatePinVisibility(pin_id) {
|
||||||
|
var edgeToDelete = null;
|
||||||
internal.createdPorts.forEach(data => {
|
internal.createdPorts.forEach(data => {
|
||||||
if (data.dataId === pin_id) {
|
if (data.dataId === pin_id) {
|
||||||
root.portsMetaData.pin.forEach(data2 => {
|
root.portsMetaData.pin.forEach(data2 => {
|
||||||
if (data2.id === pin_id) {
|
if (data2.id === pin_id) {
|
||||||
|
// Hide/show Pin
|
||||||
data.visible = data2.enabled;
|
data.visible = data2.enabled;
|
||||||
|
// Find edge for hidden Pin, for removal
|
||||||
|
if (!data2.enabled) {
|
||||||
|
for (var i = 0; i < graphView.graph.edges.length; i++) {
|
||||||
|
var edge = graphView.graph.edges.at(i);
|
||||||
|
var destItem = edge.item.destinationItem;
|
||||||
|
if (destItem === data) {
|
||||||
|
edgeToDelete = edge;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (edgeToDelete) {
|
||||||
|
// Remove from ports first
|
||||||
|
if (edgeToDelete.item.sourceItem) {
|
||||||
|
edgeToDelete.item.sourceItem.onEdgeItemDestroyed(edgeToDelete.item);
|
||||||
|
}
|
||||||
|
if (edgeToDelete.item.destinationItem) {
|
||||||
|
edgeToDelete.item.destinationItem.onEdgeItemDestroyed(edgeToDelete.item);
|
||||||
|
}
|
||||||
|
// Remove edge
|
||||||
|
graphView.graph.removeEdge(edgeToDelete);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout.preferredHeight: 60
|
Layout.preferredHeight: 60
|
||||||
|
@@ -160,7 +160,7 @@ protected:
|
|||||||
EdgeItems _outEdgeItems;
|
EdgeItems _outEdgeItems;
|
||||||
|
|
||||||
//! Used internally to automatically monitor in/out edges items destruction.
|
//! Used internally to automatically monitor in/out edges items destruction.
|
||||||
void onEdgeItemDestroyed(QObject* obj);
|
Q_INVOKABLE void onEdgeItemDestroyed(QObject* obj);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Force input/output edge update.
|
//! Force input/output edge update.
|
||||||
|
Reference in New Issue
Block a user