Skip to content

Commit

Permalink
Merge pull request #230 from BioDataAnalysis/bda_return_node_as_reque…
Browse files Browse the repository at this point in the history
…sted_type

Return nodes as the requested type in templated creation methods
  • Loading branch information
cneben authored Aug 11, 2024
2 parents 700384a + bfebd34 commit c0a19f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/qanGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ class Graph : public gtpo::graph<QQuickItem, qan::Node, qan::Group, qan::Edge>
* \note trigger nodeInserted() signal after insertion and generate a call to onNodeInserted().
*/
template <class Node_t>
qan::Node* insertNode(QQmlComponent* nodeComponent = nullptr, qan::NodeStyle* nodeStyle = nullptr);
Node_t* insertNode(QQmlComponent* nodeComponent = nullptr, qan::NodeStyle* nodeStyle = nullptr);

/*! \brief Same semantic than insertNode<>() but for non visual nodes.
*
* \note trigger nodeInserted() signal after insertion and generate a call to onNodeInserted().
*/
template <class Node_t>
qan::Node* insertNonVisualNode();
Node_t* insertNonVisualNode();

/*! \brief Insert and existing node with a specific delegate component and a custom style.
*
Expand Down
5 changes: 2 additions & 3 deletions src/qanGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace qan { // ::qan

/* Graph Factories *///--------------------------------------------------------
template <class Node_t>
qan::Node* Graph::insertNode(QQmlComponent* nodeComponent, qan::NodeStyle* nodeStyle)
Node_t* Graph::insertNode(QQmlComponent* nodeComponent, qan::NodeStyle* nodeStyle)
{
if (nodeComponent == nullptr) {
const auto engine = qmlEngine(this);
Expand Down Expand Up @@ -108,7 +108,7 @@ qan::Node* Graph::insertNode(QQmlComponent* nodeComponent, qan::NodeStyle* node
}

template <class Node_t>
qan::Node* Graph::insertNonVisualNode()
Node_t* Graph::insertNonVisualNode()
{
const auto node = new Node_t();
try {
Expand Down Expand Up @@ -217,4 +217,3 @@ qan::Group* Graph::insertTable(int cols, int rows)
//-----------------------------------------------------------------------------

} // ::qan

0 comments on commit c0a19f2

Please sign in to comment.