nodeviewscene: skip add duplicate edges
This commit is contained in:
@@ -171,9 +171,15 @@ void NodeViewScene::RemoveNode(Node *node)
|
||||
delete item_map_.take(node);
|
||||
}
|
||||
|
||||
void NodeViewScene::AddEdge(const NodeOutput &output, const NodeInput &input)
|
||||
NodeViewEdge* NodeViewScene::AddEdge(const NodeOutput &output, const NodeInput &input)
|
||||
{
|
||||
AddEdgeInternal(output, input, NodeToUIObject(output.node()), NodeToUIObject(input.node()));
|
||||
NodeViewEdge *edge = EdgeToUIObject(output, input);
|
||||
|
||||
if (!edge) {
|
||||
edge = AddEdgeInternal(output, input, NodeToUIObject(output.node()), NodeToUIObject(input.node()));
|
||||
}
|
||||
|
||||
return edge;
|
||||
}
|
||||
|
||||
void NodeViewScene::RemoveEdge(const NodeOutput &output, const NodeInput &input)
|
||||
@@ -202,7 +208,7 @@ int NodeViewScene::DetermineWeight(Node *n)
|
||||
return qMax(1, weight);
|
||||
}
|
||||
|
||||
void NodeViewScene::AddEdgeInternal(const NodeOutput& output, const NodeInput& input, NodeViewItem *from, NodeViewItem *to)
|
||||
NodeViewEdge* NodeViewScene::AddEdgeInternal(const NodeOutput& output, const NodeInput& input, NodeViewItem *from, NodeViewItem *to)
|
||||
{
|
||||
NodeViewEdge* edge_ui = new NodeViewEdge(output, input, from, to);
|
||||
|
||||
@@ -214,6 +220,8 @@ void NodeViewScene::AddEdgeInternal(const NodeOutput& output, const NodeInput& i
|
||||
|
||||
addItem(edge_ui);
|
||||
edges_.append(edge_ui);
|
||||
|
||||
return edge_ui;
|
||||
}
|
||||
|
||||
Qt::Orientation NodeViewScene::GetFlowOrientation() const
|
||||
|
||||
@@ -98,7 +98,7 @@ public slots:
|
||||
*/
|
||||
void RemoveNode(Node* node);
|
||||
|
||||
void AddEdge(const NodeOutput& output, const NodeInput& input);
|
||||
NodeViewEdge *AddEdge(const NodeOutput& output, const NodeInput& input);
|
||||
void RemoveEdge(const NodeOutput& output, const NodeInput& input);
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public slots:
|
||||
private:
|
||||
static int DetermineWeight(Node* n);
|
||||
|
||||
void AddEdgeInternal(const NodeOutput &output, const NodeInput &input, NodeViewItem* from, NodeViewItem* to);
|
||||
NodeViewEdge* AddEdgeInternal(const NodeOutput &output, const NodeInput &input, NodeViewItem* from, NodeViewItem* to);
|
||||
|
||||
QHash<Node*, NodeViewItem*> item_map_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user