31 mRubberBand->setBrush( QBrush( QColor( 224, 178, 76, 63 ) ) );
32 mRubberBand->setPen( QPen( QBrush( QColor( 254, 58, 29, 100 ) ), 0, Qt::DotLine ) );
40 if ( mMouseHandles->scene() )
41 mMouseHandles->scene()->removeItem( mMouseHandles );
42 mMouseHandles->deleteLater();
48 if ( mMouseHandles->shouldBlockEvent( event ) )
54 if ( mMouseHandles->isVisible() )
57 QgsLayoutMouseHandles::MouseAction mouseAction = mMouseHandles->mouseActionForScenePos( event->
layoutPoint() );
59 if ( mouseAction != QgsLayoutMouseHandles::MoveItem
60 && mouseAction != QgsLayoutMouseHandles::NoAction
61 && mouseAction != QgsLayoutMouseHandles::SelectItem )
69 if ( event->button() != Qt::LeftButton )
80 if ( event->modifiers() & Qt::ControlModifier )
84 if ( !selectedItems.isEmpty() )
86 previousSelectedItem = selectedItems.at( 0 );
90 if ( previousSelectedItem )
115 selectedItem = group;
121 mMousePressStartPos =
event->pos();
122 mRubberBand->start( event->
layoutPoint(), Qt::KeyboardModifiers() );
126 if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
133 if ( !selectedItems.isEmpty() )
144 if ( ( !selectedItem->isSelected() ) &&
145 !( event->modifiers() & Qt::ShiftModifier ) )
162 mRubberBand->update( event->
layoutPoint(), Qt::KeyboardModifiers() );
172 if ( event->button() != Qt::LeftButton && mMouseHandles->shouldBlockEvent( event ) )
178 if ( !mIsSelecting || event->button() != Qt::LeftButton )
184 mIsSelecting =
false;
185 bool wasClick = !
isClickAndDrag( mMousePressStartPos, event->pos() );
189 QRectF rect = mRubberBand->finish( event->
layoutPoint() );
191 bool subtractingSelection =
false;
192 if ( event->modifiers() & Qt::ShiftModifier )
196 else if ( event->modifiers() & Qt::ControlModifier )
199 subtractingSelection =
true;
208 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
209 if ( event->modifiers() & Qt::AltModifier )
212 selectionMode = Qt::ContainsItemShape;
216 QList<QGraphicsItem *> itemList;
218 itemList =
layout()->items( rect.center(), selectionMode );
220 itemList =
layout()->items( rect, selectionMode );
221 for ( QGraphicsItem *item : qgis::as_const( itemList ) )
225 if ( layoutItem && !paperItem )
229 if ( subtractingSelection )
248 if ( !selectedItemList.isEmpty() )
256 mMouseHandles->selectionChanged();
261 if ( mMouseHandles->shouldBlockEvent( event ) )
274 if ( mMouseHandles->isDragging() || mMouseHandles->isResizing() )
288 mRubberBand->finish();
289 mIsSelecting =
false;
295 QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
297 return mMouseHandles;
304 mMouseHandles->deleteLater();
307 mMouseHandles =
new QgsLayoutMouseHandles(
layout,
view() );
308 mMouseHandles->hide();
310 layout->addItem( mMouseHandles );