32 if ( event->button() != Qt::LeftButton )
38 const QList<QGraphicsItem *> itemsAtCursorPos =
view()->items( event->pos() );
39 if ( itemsAtCursorPos.isEmpty() )
44 for ( QGraphicsItem *graphicsItem : itemsAtCursorPos )
50 mMoveContentStartPos =
event->layoutPoint();
51 mMoveContentItem = item;
52 mMovingItemContent =
true;
60 if ( !mMovingItemContent || !mMoveContentItem )
68 event->
layoutPoint().y() - mMoveContentStartPos.y() );
69 mMoveContentItem->update();
74 if ( event->button() != Qt::LeftButton || !mMovingItemContent || !mMoveContentItem )
83 const double moveX =
event->layoutPoint().x() - mMoveContentStartPos.x();
84 const double moveY =
event->layoutPoint().y() - mMoveContentStartPos.y();
89 mMoveContentItem =
nullptr;
90 mMovingItemContent =
false;
97#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
98 QPointF scenePoint =
view()->mapToScene( event->pos().x(), event->pos().y() );
100 const QPointF scenePoint =
view()->mapToScene( event->position().x(), event->position().y() );
105 if ( !item || !item->isSelected() )
109 double zoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2.0 ).toDouble();
110 bool reverseZoom = settings.
value( QStringLiteral(
"qgis/reverse_wheel_zoom" ),
false ).toBool();
111 bool zoomIn = reverseZoom ?
event->angleDelta().y() < 0 :
event->angleDelta().y() > 0;
114 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
116 if ( event->modifiers() & Qt::ControlModifier )
119 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
123 const double scaleFactor = ( zoomIn ? zoomFactor : 1 / zoomFactor );
125 const QPointF itemPoint = item->mapFromScene( scenePoint );
Base class for graphical items within a QgsLayout.
@ UndoZoomContent
Item content zoomed.
virtual void zoomContent(double factor, QPointF point)
Zooms content of item.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
virtual void moveContent(double dx, double dy)
Moves the content of the item, by a specified dx and dy in layout units.
virtual void setMoveContentPreviewOffset(double dx, double dy)
Sets temporary offset for the item, by a specified dx and dy in layout units.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void endCommand()
Saves final state of an object and pushes the active command to the undo history.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
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.
void wheelEvent(QWheelEvent *event) override
Mouse wheel event for overriding.
QgsLayoutViewToolMoveItemContent(QgsLayoutView *view)
Constructor for QgsLayoutViewToolMoveItemContent.
void layoutMoveEvent(QgsLayoutViewMouseEvent *event) override
Mouse move event for overriding.
void layoutPressEvent(QgsLayoutViewMouseEvent *event) override
Mouse press event for overriding.
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
A graphical widget to display and interact with QgsLayouts.
QgsLayoutItem * layoutItemAt(QPointF position, bool ignoreLocked=false, double searchTolerance=0) const
Returns the topmost layout item at a specified position.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.