From 737442e5136bbe135e9af4116fb8c6c4a7b1018b Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 13 Aug 2019 18:40:39 +1000 Subject: [PATCH] added takenode function to graph --- app/node/graph.cpp | 14 ++++++++++++++ app/node/graph.h | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/node/graph.cpp b/app/node/graph.cpp index d31946ef2..6a99cd7b5 100644 --- a/app/node/graph.cpp +++ b/app/node/graph.cpp @@ -53,6 +53,20 @@ void NodeGraph::AddNodeWithDependencies(Node *node) } } +void NodeGraph::RemoveNode(Node *node) +{ + if (!ContainsNode(node)) { + return; + } + + node->setParent(nullptr); + + disconnect(node, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SIGNAL(EdgeAdded(NodeEdgePtr))); + disconnect(node, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SIGNAL(EdgeRemoved(NodeEdgePtr))); + + emit NodeRemoved(node); +} + QList NodeGraph::nodes() { return static_qobjectlist_cast(children()); diff --git a/app/node/graph.h b/app/node/graph.h index b32fec5d6..84010d172 100644 --- a/app/node/graph.h +++ b/app/node/graph.h @@ -54,9 +54,9 @@ public: void AddNodeWithDependencies(Node* node); /** - * @brief Removes a Node from the graph and destroys it + * @brief Removes a Node from the graph BUT doesn't destroy it. Ownership is returned to the caller. */ - void RemoveNode(Node* node); + void TakeNode(Node* node); /** * @brief Retrieve a complete list of the nodes belonging to this graph