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(), nullptr );
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(), nullptr );
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 );
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
Base class for graphical items within a QgsLayout.
A graphical widget to display and interact with QgsLayouts.
A container for grouping several QgsLayoutItems.
virtual void setSelected(bool selected)
Sets whether the item should be selected.
Z-value for mouse handles.
QList< QgsLayoutItem * > selectedLayoutItems(bool includeLockedItems=true)
Returns list of selected layout items.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
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...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
QgsLayoutItem * layoutItemAt(QPointF position, bool ignoreLocked=false) const
Returns the topmost layout item at a specified position.
QgsLayoutItemGroup * parentGroup() const
Returns the item's parent group, if the item is part of a QgsLayoutItemGroup group.
Item representing the paper in a layout.