| 616 | { |
| 617 | |
| 618 | Node* |
| 619 | locateNodeAt(QPointF scenePoint, FlowScene &scene, |
| 620 | QTransform const & viewTransform) |
| 621 | { |
| 622 | // items under cursor |
| 623 | QList<QGraphicsItem*> items = |
| 624 | scene.items(scenePoint, |
| 625 | Qt::IntersectsItemShape, |
| 626 | Qt::DescendingOrder, |
| 627 | viewTransform); |
| 628 | |
| 629 | //// items convertable to NodeGraphicsObject |
| 630 | std::vector<QGraphicsItem*> filteredItems; |
| 631 | |
| 632 | std::copy_if(items.begin(), |
| 633 | items.end(), |
| 634 | std::back_inserter(filteredItems), |
| 635 | [] (QGraphicsItem * item) |
| 636 | { |
| 637 | return (dynamic_cast<NodeGraphicsObject*>(item) != nullptr); |
| 638 | }); |
| 639 | |
| 640 | Node* resultNode = nullptr; |
| 641 | |
| 642 | if (!filteredItems.empty()) |
| 643 | { |
| 644 | QGraphicsItem* graphicsItem = filteredItems.front(); |
| 645 | auto ngo = dynamic_cast<NodeGraphicsObject*>(graphicsItem); |
| 646 | |
| 647 | resultNode = &ngo->node(); |
| 648 | } |
| 649 | |
| 650 | return resultNode; |
| 651 | } |
| 652 | } |
no test coverage detected