17#include "moc_qgslayoutviewtoolmoveitemcontent.cpp"
33 if ( event->button() != Qt::LeftButton )
39 const QList<QGraphicsItem *> itemsAtCursorPos =
view()->items( event->pos() );
40 if ( itemsAtCursorPos.isEmpty() )
45 for ( QGraphicsItem *graphicsItem : itemsAtCursorPos )
51 mMoveContentStartPos =
event->layoutPoint();
52 mMoveContentItem = item;
53 mMovingItemContent =
true;
61 if ( !mMovingItemContent || !mMoveContentItem )
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 const QPointF scenePoint =
view()->mapToScene( event->position().x(), event->position().y() );
101 if ( !item || !item->isSelected() )
105 double zoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2.0 ).toDouble();
106 bool reverseZoom = settings.
value( QStringLiteral(
"qgis/reverse_wheel_zoom" ),
false ).toBool();
107 bool zoomIn = reverseZoom ?
event->angleDelta().y() < 0 :
event->angleDelta().y() > 0;
110 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
112 if ( event->modifiers() & Qt::ControlModifier )
115 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
119 const double scaleFactor = ( zoomIn ? zoomFactor : 1 / zoomFactor );
121 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.