29 mRubberBand->setBrush( QBrush( QColor( 224, 178, 76, 63 ) ) );
30 mRubberBand->setPen( QPen( QBrush( QColor( 254, 58, 29, 100 ) ), 0, Qt::DotLine ) );
38 if ( mMouseHandles->scene() )
39 mMouseHandles->scene()->removeItem( mMouseHandles );
40 mMouseHandles->deleteLater();
46 if ( mMouseHandles->shouldBlockEvent( event ) )
52 if ( mMouseHandles->isVisible() )
55 QgsLayoutMouseHandles::MouseAction mouseAction = mMouseHandles->mouseActionForScenePos( event->
layoutPoint() );
57 if ( mouseAction != QgsLayoutMouseHandles::MoveItem
58 && mouseAction != QgsLayoutMouseHandles::NoAction
59 && mouseAction != QgsLayoutMouseHandles::SelectItem )
67 if ( event->button() != Qt::LeftButton )
78 if ( event->modifiers() & Qt::ControlModifier )
82 if ( !selectedItems.isEmpty() )
84 previousSelectedItem = selectedItems.at( 0 );
88 if ( previousSelectedItem )
110 mMousePressStartPos =
event->pos();
111 mRubberBand->start( event->
layoutPoint(), nullptr );
115 if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
122 if ( !selectedItems.isEmpty() )
133 if ( ( !selectedItem->isSelected() ) &&
134 !( event->modifiers() & Qt::ShiftModifier ) )
151 mRubberBand->update( event->
layoutPoint(), nullptr );
161 if ( event->button() != Qt::LeftButton && mMouseHandles->shouldBlockEvent( event ) )
167 if ( !mIsSelecting || event->button() != Qt::LeftButton )
173 mIsSelecting =
false;
174 bool wasClick = !
isClickAndDrag( mMousePressStartPos, event->pos() );
176 QRectF rect = mRubberBand->finish( event->
layoutPoint(),
event->modifiers() );
178 bool subtractingSelection =
false;
179 if ( event->modifiers() & Qt::ShiftModifier )
183 else if ( event->modifiers() & Qt::ControlModifier )
186 subtractingSelection =
true;
195 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
196 if ( event->modifiers() & Qt::AltModifier )
199 selectionMode = Qt::ContainsItemShape;
203 QList<QGraphicsItem *> itemList;
205 itemList =
layout()->items( rect.center(), selectionMode );
207 itemList =
layout()->items( rect, selectionMode );
208 for ( QGraphicsItem *item : qgis::as_const( itemList ) )
212 if ( layoutItem && !paperItem )
216 if ( subtractingSelection )
235 if ( !selectedItemList.isEmpty() )
243 mMouseHandles->selectionChanged();
248 if ( mMouseHandles->shouldBlockEvent( event ) )
261 if ( mMouseHandles->isDragging() || mMouseHandles->isResizing() )
275 mRubberBand->finish();
276 mIsSelecting =
false;
282 QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
284 return mMouseHandles;
291 mMouseHandles->deleteLater();
294 mMouseHandles =
new QgsLayoutMouseHandles( layout,
view() );
295 mMouseHandles->hide();
297 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.
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...
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.
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
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.
Item representing the paper in a layout.