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 )
79 if ( event->modifiers() & Qt::ControlModifier )
83 if ( !selectedItems.isEmpty() )
85 previousSelectedItem = selectedItems.at( 0 );
89 if ( previousSelectedItem )
114 selectedItem = group;
120 mMousePressStartPos =
event->pos();
121 mRubberBand->start( event->
layoutPoint(), Qt::KeyboardModifiers() );
125 if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
132 if ( !selectedItems.isEmpty() )
143 if ( ( !selectedItem->isSelected() ) &&
144 !( event->modifiers() & Qt::ShiftModifier ) )
161 mRubberBand->update( event->
layoutPoint(), Qt::KeyboardModifiers() );
171 if ( event->button() != Qt::LeftButton && mMouseHandles->shouldBlockEvent( event ) )
177 if ( !mIsSelecting || event->button() != Qt::LeftButton )
183 mIsSelecting =
false;
184 bool wasClick = !
isClickAndDrag( mMousePressStartPos, event->pos() );
188 QRectF rect = mRubberBand->finish( event->
layoutPoint() );
190 bool subtractingSelection =
false;
191 if ( event->modifiers() & Qt::ShiftModifier )
195 else if ( event->modifiers() & Qt::ControlModifier )
198 subtractingSelection =
true;
207 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
208 if ( event->modifiers() & Qt::AltModifier )
211 selectionMode = Qt::ContainsItemShape;
215 QList<QGraphicsItem *> itemList;
217 itemList =
layout()->items( rect.center(), selectionMode );
219 itemList =
layout()->items( rect, selectionMode );
222 for ( QGraphicsItem *item : std::as_const( itemList ) )
227 focusedPaperItem = paperItem;
229 if ( layoutItem && !paperItem )
233 if ( subtractingSelection )
253 if ( !selectedItemList.isEmpty() )
257 else if ( focusedPaperItem )
265 mMouseHandles->selectionChanged();
270 if ( mMouseHandles->shouldBlockEvent( event ) )
283 if ( mMouseHandles->isDragging() || mMouseHandles->isResizing() )
297 mRubberBand->finish();
298 mIsSelecting =
false;
304 QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
306 return mMouseHandles;
313 mMouseHandles->deleteLater();
316 mMouseHandles =
new QgsLayoutMouseHandles(
layout,
view() );
317 mMouseHandles->hide();
319 layout->addItem( mMouseHandles );
A container for grouping several QgsLayoutItems.
Item representing the paper in a layout.
Base class for graphical items within a QgsLayout.
QgsLayoutItemGroup * parentGroup() const
Returns the item's parent group, if the item is part of a QgsLayoutItemGroup group.
virtual void setSelected(bool selected)
Sets whether the item should be selected.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
QgsLayoutViewRectangularRubberBand is rectangular rubber band for use within QgsLayoutView widgets.
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutItem * layoutItemAt(QPointF position, bool ignoreLocked=false) const
Returns the topmost layout item at a specified position.
QList< QgsLayoutItem * > selectedLayoutItems(bool includeLockedItems=true)
Returns list of selected layout items.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
@ ZMouseHandles
Z-value for mouse handles.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.