32 if ( mNodesItem && mNodesItemIndex != -1 )
35 if ( mNodesItem->removeNode( mNodesItemIndex ) )
38 if ( mNodesItem->nodesSize() > 0 )
40 mNodesItemIndex = mNodesItem->selectedNode();
66 if ( event->button() != Qt::LeftButton )
72 const QList<QGraphicsItem *> itemsAtCursorPos =
view()->items( event->pos().x(), event->pos().y(),
73 mMoveContentSearchRadius,
74 mMoveContentSearchRadius );
75 if ( itemsAtCursorPos.isEmpty() )
82 for ( QGraphicsItem *graphicsItem : itemsAtCursorPos )
91 mNodesItemIndex = index;
93 mMoveContentStartPos =
event->layoutPoint();
97 if ( mNodesItem && mNodesItemIndex != -1 )
100 setSelectedNode( mNodesItem, mNodesItemIndex );
115 if ( mNodesItem && mNodesItemIndex != -1 && event->
layoutPoint() != mMoveContentStartPos )
117 mNodesItem->moveNode( mNodesItemIndex, event->
snappedPoint() );
123 if ( event->button() != Qt::LeftButton || !isMoving )
130 if ( mNodesItemIndex != -1 )
132 if ( event->
layoutPoint() != mMoveContentStartPos )
145 if ( event->button() != Qt::LeftButton )
152 if ( mNodesItemIndex != -1 )
154 mNodesItem =
nullptr;
155 mNodesItemIndex = -1;
160 const QList<QGraphicsItem *> itemsAtCursorPos =
view()->items( event->pos().x(), event->pos().y(),
161 mMoveContentSearchRadius,
162 mMoveContentSearchRadius );
164 if ( itemsAtCursorPos.isEmpty() )
168 for ( QGraphicsItem *graphicsItem : itemsAtCursorPos )
181 mNodesItemIndex = mNodesItem->nodeAtPosition( event->
layoutPoint() );
193 setSelectedNode( mNodesItem, mNodesItemIndex );
194 mNodesItem->update();
200 if ( mNodesItem && mNodesItemIndex != -1 && ( event->key() == Qt::Key_Left
201 || event->key() == Qt::Key_Right
202 || event->key() == Qt::Key_Up
203 || event->key() == Qt::Key_Down ) )
207 if ( mNodesItem->nodePosition( mNodesItemIndex, currentPos ) )
211 currentPos.setX( currentPos.x() + delta.x() );
212 currentPos.setY( currentPos.y() + delta.y() );
215 mNodesItem->moveNode( mNodesItemIndex, currentPos );
228 displayNodes(
false );
235 QList< QgsLayoutItem * > items;
241 void QgsLayoutViewToolEditNodes::displayNodes(
bool display )
243 QList<QgsLayoutNodesItem *> nodesShapes;
248 item->setDisplayNodes( display );
253 void QgsLayoutViewToolEditNodes::deselectNodes()
255 QList<QgsLayoutNodesItem *> nodesShapes;
260 item->deselectNode();
265 void QgsLayoutViewToolEditNodes::setSelectedNode(
QgsLayoutNodesItem *shape,
int index )
267 QList<QgsLayoutNodesItem *> nodesShapes;
274 item->setSelectedNode( index );
280 item->deselectNode();