paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework
BSD 3-Clause "New" or "Revised" License
2.92k stars 795 forks source link

BasicGraphicsScene::nodeMoved is not being emitted anywhere #364

Closed rayment closed 1 year ago

rayment commented 1 year ago

I require the use of BasicGraphicsScene::nodeMoved (via. DataFlowGraphicsScene) for my project as I wish to determine when nodes have been moved. When I checked the code, the signal is not being emitted anywhere at all.

Under the assumption that this signal should be implemented and not left to the user, I have thought of two simple solutions, though each are diametric to one another:

I liked the second solution better, and have implemented it in my fork here. Alternatively, my implementation for the first solution is as follows:

void BasicGraphicsScene::onNodePositionUpdated(NodeId const nodeId)
{
    auto node = nodeGraphicsObject(nodeId);
    if (node) {
        auto pos = _graphModel.nodeData(nodeId, NodeRole::Position).value<QPointF>();
        node->setPos(pos);
        node->update();
        Q_EMIT nodeMoved(nodeId, pos);
    }
}

Please let me know if this change is useful, and if so, I'll open a PR.

rayment commented 1 year ago

Looks like this issue is much bigger than this. After the version upgrade to 3.x.x, a lot of these slots are no longer called including inputConnectionCreated/Deleted and outputConnectionCreated/outputConnectionDeleted after src/FlowScene.cpp was removed (see PR 211 when it was introduced).

Edit: I've fixed these functions and will be opening a PR because now I think this warrants the fix.

paceholder commented 1 year ago

Thanks for addressing it. Indeed, some slots might have gone lost during refactoring (unintentionally). I'll have a look at your PR