Skip to content

Commit

Permalink
#241 Fix node dragging cosmetic issue.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <[email protected]>
  • Loading branch information
cneben committed Aug 21, 2024
1 parent bf5a69f commit e5aa0b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/qanDraggableCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ void DraggableCtrl::beginDragMove(const QPointF& sceneDragPos, bool dragSelec
_targetItem->setDragged(true);

_initialSceneDragPos = sceneDragPos;
if (!_target->isGroup()) {
_initialTargetZ = _targetItem->z(); // 20240821: Force maximum graph z when dragging a node (not a group), restored
_targetItem->setZ(graph->getMaxZ()); // in endDragMove
}
const auto rootItem = getGraph()->getContainerItem();
if (rootItem != nullptr) // Project in scene rect (for example if a node is part of a group)
_initialTargetScenePos = rootItem->mapFromItem(_targetItem, QPointF{0,0});
Expand Down Expand Up @@ -419,6 +423,11 @@ void DraggableCtrl::endDragMove(bool dragSelection, bool notify)
!_targetItem)
return;

if (!_target->isGroup()) {
_targetItem->setZ(_initialTargetZ);
_initialTargetZ = 0.;
}

if (_target->getIsProtected() || // Prevent dragging of protected or locked objects
_target->getLocked())
return;
Expand Down
2 changes: 2 additions & 0 deletions src/qanDraggableCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class DraggableCtrl : public qan::AbstractDraggableCtrl
QPointF _initialSceneDragPos{0., 0.};
//! Internal (target) initial dragging position.
QPointF _initialTargetScenePos{0., 0.};
//! Internal (target) initial dragging z.
double _initialTargetZ = 0.;

//! Last group hovered during a node drag (cached to generate a dragLeave signal on qan::Group).
QPointer<qan::Group> _lastProposedGroup{nullptr};
Expand Down

0 comments on commit e5aa0b5

Please sign in to comment.