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 ) )
53 if ( mMouseHandles->isVisible() )
56 QgsLayoutMouseHandles::MouseAction mouseAction = mMouseHandles->mouseActionForScenePos( event->
layoutPoint() );
58 if ( mouseAction != QgsLayoutMouseHandles::MoveItem
59 && mouseAction != QgsLayoutMouseHandles::NoAction
60 && mouseAction != QgsLayoutMouseHandles::SelectItem )
68 if ( event->button() != Qt::LeftButton )
73 mRubberBand->finish();
84 if ( event->modifiers() & Qt::ControlModifier )
88 if ( !selectedItems.isEmpty() )
90 previousSelectedItem = selectedItems.at( 0 );
94 if ( previousSelectedItem )
119 selectedItem = group;
125 mMousePressStartPos =
event->pos();
126 mRubberBand->start( event->
layoutPoint(), Qt::KeyboardModifiers() );
130 if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
137 if ( !selectedItems.isEmpty() )
148 if ( ( !selectedItem->isSelected() ) &&
149 !( event->modifiers() & Qt::ShiftModifier ) )
166 mRubberBand->update( event->
layoutPoint(), Qt::KeyboardModifiers() );
176 if ( event->button() != Qt::LeftButton && mMouseHandles->shouldBlockEvent( event ) )
182 if ( !mIsSelecting || event->button() != Qt::LeftButton )
188 mIsSelecting =
false;
189 bool wasClick = !
isClickAndDrag( mMousePressStartPos, event->pos() );
193 QRectF rect = mRubberBand->finish( event->
layoutPoint() );
195 bool subtractingSelection =
false;
196 if ( event->modifiers() & Qt::ShiftModifier )
200 else if ( event->modifiers() & Qt::ControlModifier )
203 subtractingSelection =
true;
212 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
213 if ( event->modifiers() & Qt::AltModifier )
216 selectionMode = Qt::ContainsItemShape;
220 QList<QGraphicsItem *> itemList;
222 itemList =
layout()->items( rect.center(), selectionMode );
224 itemList =
layout()->items( rect, selectionMode );
227 for ( QGraphicsItem *item : std::as_const( itemList ) )
232 focusedPaperItem = paperItem;
234 if ( layoutItem && !paperItem )
238 if ( subtractingSelection )
258 if ( !selectedItemList.isEmpty() )
262 else if ( focusedPaperItem )
270 mMouseHandles->selectionChanged();
275 if ( mMouseHandles->shouldBlockEvent( event ) )
288 if ( mMouseHandles->isDragging() || mMouseHandles->isResizing() )
302 mRubberBand->finish();
303 mIsSelecting =
false;
309 QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
311 return mMouseHandles;
318 mMouseHandles->deleteLater();
321 mMouseHandles =
new QgsLayoutMouseHandles(
layout,
view() );
322 mMouseHandles->hide();
324 layout->addItem( mMouseHandles );