BasicGraphicsScene::nodeMoved is not being emitted anywhere
rayment opened this issue · comments
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:
- Emit the signal directly in
BasicGraphicssScene::onNodePositionUpdated
. This produces a signal on every draw frame that the node is being dragged on. It's also redundant becausenodePositionUpdated
is already a signal. - Emit the signal from a new slot called
BasicGraphicsScene::onNodeClicked
. This can produce a signal once, when the node has been dragged after at least one frame, and the mouse has been released.
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.
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.
Thanks for addressing it. Indeed, some slots might have gone lost during refactoring (unintentionally).
I'll have a look at your PR