QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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() )
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 );
void layoutMoveEvent(QgsLayoutViewMouseEvent *event) override
Mouse move event for overriding.
const QgsLayout * layout() const
Returns the layout the object is attached to.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void wheelEvent(QWheelEvent *event) override
Mouse wheel event for overriding.
@ UndoZoomContent
Item content zoomed.
This class is a composition of two QSettings instances:
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
QgsLayoutItem * layoutItemAt(QPointF position, bool ignoreLocked=false) const
Returns the topmost layout item at a specified position.
virtual void zoomContent(double factor, QPointF point)
Zooms content of item.
Base class for graphical items within a QgsLayout.
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 graphical widget to display and interact with QgsLayouts.
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
void layoutPressEvent(QgsLayoutViewMouseEvent *event) override
Mouse press event for overriding.
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.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
QgsLayoutViewToolMoveItemContent(QgsLayoutView *view)
Constructor for QgsLayoutViewToolMoveItemContent.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.