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;
309QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
311 return mMouseHandles;
318 mMouseHandles->deleteLater();
321 mMouseHandles =
new QgsLayoutMouseHandles(
layout,
view() );
322 mMouseHandles->hide();
324 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.