21 #include "qgssettings.h"
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 double moveX =
event->layoutPoint().x() - mMoveContentStartPos.x();
84 double moveY =
event->layoutPoint().y() - mMoveContentStartPos.y();
89 mMoveContentItem =
nullptr;
90 mMovingItemContent =
false;
97 QPointF scenePoint =
view()->mapToScene( event->pos() );
100 if ( !item || !item->isSelected() )
103 QgsSettings settings;
104 double zoomFactor = settings.value( QStringLiteral(
"qgis/zoom_factor" ), 2.0 ).toDouble();
107 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
109 if ( event->modifiers() & Qt::ControlModifier )
112 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
116 bool zoomIn =
event->angleDelta().y() > 0;
117 double scaleFactor = ( zoomIn ? zoomFactor : 1 / zoomFactor );
119 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) 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 ...