Skip to content

Commit

Permalink
Add Graph::hasSelection() method.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <benoit@destrat.io>
  • Loading branch information
cneben committed Dec 10, 2023
1 parent e0dddb5 commit 629c92f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/qanGraph.cpp
Expand Up @@ -1401,6 +1401,13 @@ void Graph::clearSelection()
_selectedEdges.clear();
}

bool Graph::hasSelection() const
{
return (_selectedNodes.size() >= 1 ||
_selectedGroups.size() >= 1 ||
_selectedEdges.size() >= 1);
}

bool Graph::hasMultipleSelection() const
{
// Note 20231104: There is still no support for multiple edge selection,
Expand All @@ -1410,7 +1417,6 @@ bool Graph::hasMultipleSelection() const
_selectedEdges.size() > 1;
}


std::vector<QQuickItem*> Graph::getSelectedItems() const
{
using item_vector_t = std::vector<QQuickItem*>;
Expand Down
5 changes: 4 additions & 1 deletion src/qanGraph.h
Expand Up @@ -762,7 +762,10 @@ class Graph : public gtpo::graph<QQuickItem, qan::Node, qan::Group, qan::Edge>
//! Clear the current selection.
Q_INVOKABLE void clearSelection();

//! Return true if multiple node are selected.
//! Return true if either a nodes, groups, edges (or multiple nodes, groups, edges) is selected.
Q_INVOKABLE bool hasSelection() const;

//! Return true if multiple nodes, groups or edges are selected.
Q_INVOKABLE bool hasMultipleSelection() const;

public:
Expand Down

0 comments on commit 629c92f

Please sign in to comment.