45#include "moc_qgslayoutview.cpp"
47#define MIN_VIEW_SCALE 0.05
48#define MAX_VIEW_SCALE 1000.0
51 : QGraphicsView( parent )
53 setResizeAnchor( QGraphicsView::AnchorViewCenter );
54 setMouseTracking(
true );
55 viewport()->setMouseTracking(
true );
61 viewport()->setStyleSheet( QStringLiteral(
"background-color:#d7d7d7;" ) );
68 viewport()->setGraphicsEffect( mPreviewEffect );
82 return qobject_cast<QgsLayout *>( scene() );
87 return qobject_cast<const QgsLayout *>( scene() );
101 mSnapMarker =
new QgsLayoutViewSnapMarker();
103 layout->addItem( mSnapMarker );
104 mHorizontalSnapLine = createSnapLine();
105 mHorizontalSnapLine->hide();
106 layout->addItem( mHorizontalSnapLine );
107 mVerticalSnapLine = createSnapLine();
108 mVerticalSnapLine->hide();
109 layout->addItem( mVerticalSnapLine );
110 mSectionLabel =
nullptr;
112 if ( mHorizontalRuler )
114 connect( &layout->
guides(), &QAbstractItemModel::dataChanged, mHorizontalRuler, [
this] { mHorizontalRuler->update(); } );
115 connect( &layout->
guides(), &QAbstractItemModel::rowsInserted, mHorizontalRuler, [
this] { mHorizontalRuler->update(); } );
116 connect( &layout->
guides(), &QAbstractItemModel::rowsRemoved, mHorizontalRuler, [
this] { mHorizontalRuler->update(); } );
117 connect( &layout->
guides(), &QAbstractItemModel::modelReset, mHorizontalRuler, [
this] { mHorizontalRuler->update(); } );
119 if ( mVerticalRuler )
121 connect( &layout->
guides(), &QAbstractItemModel::dataChanged, mVerticalRuler, [
this] { mVerticalRuler->update(); } );
122 connect( &layout->
guides(), &QAbstractItemModel::rowsInserted, mVerticalRuler, [
this] { mVerticalRuler->update(); } );
123 connect( &layout->
guides(), &QAbstractItemModel::rowsRemoved, mVerticalRuler, [
this] { mVerticalRuler->update(); } );
124 connect( &layout->
guides(), &QAbstractItemModel::modelReset, mVerticalRuler, [
this] { mVerticalRuler->update(); } );
149 if ( mHorizontalSnapLine )
150 mHorizontalSnapLine->hide();
151 if ( mVerticalSnapLine )
152 mVerticalSnapLine->hide();
164 if ( mTool && mTool ==
tool )
168 setCursor( Qt::ArrowCursor );
174 mPreviewEffect->setEnabled( enabled );
179 return mPreviewEffect->isEnabled();
184 mPreviewEffect->setMode( mode );
189 return mPreviewEffect->mode();
194 double currentScale = transform().m11();
195 scale *= currentScale;
197 setTransform( QTransform::fromScale( scale, scale ) );
209 setTransform( QTransform::fromScale( level, level ) );
213 const double dpi = mScreenHelper->screenDpi();
218 setTransform( QTransform::fromScale( mmLevel, mmLevel ) );
226 mHorizontalRuler = ruler;
230 connect( &layout->guides(), &QAbstractItemModel::dataChanged, ruler, [
this] { mHorizontalRuler->update(); } );
231 connect( &layout->guides(), &QAbstractItemModel::rowsInserted, ruler, [
this] { mHorizontalRuler->update(); } );
232 connect( &layout->guides(), &QAbstractItemModel::rowsRemoved, ruler, [
this] { mHorizontalRuler->update(); } );
233 connect( &layout->guides(), &QAbstractItemModel::modelReset, ruler, [
this] { mHorizontalRuler->update(); } );
240 mVerticalRuler = ruler;
244 connect( &layout->guides(), &QAbstractItemModel::dataChanged, ruler, [
this] { mVerticalRuler->update(); } );
245 connect( &layout->guides(), &QAbstractItemModel::rowsInserted, ruler, [
this] { mVerticalRuler->update(); } );
246 connect( &layout->guides(), &QAbstractItemModel::rowsRemoved, ruler, [
this] { mVerticalRuler->update(); } );
247 connect( &layout->guides(), &QAbstractItemModel::modelReset, ruler, [
this] { mVerticalRuler->update(); } );
254 mMenuProvider.reset( provider );
259 return mMenuProvider.get();
265 return QList<QgsLayoutItemPage *>();
268 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
269 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
279 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
280 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
323 QDomElement documentElement = doc.createElement( QStringLiteral(
"LayoutItemClipboard" ) );
327 QSet<QgsLayoutMultiFrame *> copiedMultiFrames;
334 const QList<QgsLayoutItem *> groupedItems = itemGroup->items();
337 groupedItem->writeXml( documentElement, doc, context );
340 else if (
QgsLayoutFrame *frame = qobject_cast<QgsLayoutFrame *>( item ) )
343 if ( frame->multiFrame() && !copiedMultiFrames.contains( frame->multiFrame() ) )
345 frame->multiFrame()->writeXml( documentElement, doc, context );
346 copiedMultiFrames.insert( frame->multiFrame() );
349 item->writeXml( documentElement, doc, context );
353 doc.appendChild( documentElement );
361 QDomNodeList itemsNodes = doc.elementsByTagName( QStringLiteral(
"LayoutItem" ) );
362 for (
int i = 0; i < itemsNodes.count(); ++i )
364 QDomNode itemNode = itemsNodes.at( i );
365 if ( itemNode.isElement() )
367 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
368 itemNode.toElement().removeAttribute( QStringLiteral(
"groupUuid" ) );
371 QDomNodeList multiFrameNodes = doc.elementsByTagName( QStringLiteral(
"LayoutMultiFrame" ) );
372 for (
int i = 0; i < multiFrameNodes.count(); ++i )
374 QDomNode multiFrameNode = multiFrameNodes.at( i );
375 if ( multiFrameNode.isElement() )
377 multiFrameNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
378 QDomNodeList frameNodes = multiFrameNode.toElement().elementsByTagName( QStringLiteral(
"childFrame" ) );
379 for (
int j = 0; j < frameNodes.count(); ++j )
381 QDomNode itemNode = frameNodes.at( j );
382 if ( itemNode.isElement() )
384 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
390 QMimeData *mimeData =
new QMimeData;
391 mimeData->setData( QStringLiteral(
"text/xml" ), doc.toByteArray() );
392 QClipboard *clipboard = QApplication::clipboard();
393 clipboard->setMimeData( mimeData );
399 return QList<QgsLayoutItem *>();
401 QList<QgsLayoutItem *> pastedItems;
403 QClipboard *clipboard = QApplication::clipboard();
404 const QMimeData *mimeData = clipboard->mimeData();
408 if ( doc.setContent( mimeData->data( QStringLiteral(
"text/xml" ) ) ) )
410 QDomElement docElem = doc.documentElement();
411 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
420 pt = mapToScene( mapFromGlobal( QCursor::pos() ) );
426 pt = mapToScene( viewport()->rect().center() );
444 return QList<QgsLayoutItem *>();
446 QList<QgsLayoutItem *> pastedItems;
448 QClipboard *clipboard = QApplication::clipboard();
449 const QMimeData *mimeData = clipboard->mimeData();
453 if ( doc.setContent( mimeData->data( QStringLiteral(
"text/xml" ) ) ) )
455 QDomElement docElem = doc.documentElement();
456 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
471 QClipboard *clipboard = QApplication::clipboard();
472 const QMimeData *mimeData = clipboard->mimeData();
476 if ( doc.setContent( mimeData->data( QStringLiteral(
"text/xml" ) ) ) )
478 QDomElement docElem = doc.documentElement();
479 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
488 double increment = 1.0;
489 if ( event->modifiers() & Qt::ShiftModifier )
494 else if ( event->modifiers() & Qt::AltModifier )
497 double viewScale = transform().m11();
500 increment = 1 / viewScale;
506 switch ( event->key() )
524 return QPointF( deltaX, deltaY );
529 mPaintingEnabled = enabled;
539 if ( !mSectionLabel )
541 mSectionLabel =
new QgsLayoutReportSectionLabel(
currentLayout(),
this );
543 mSectionLabel->setRect( 0, -200, 1000, 200 );
544 mSectionLabel->setZValue( -1 );
546 mSectionLabel->setLabel( label );
554 fitInView( scene()->sceneRect(), Qt::KeepAspectRatio );
565 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
566 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
568 double verticalCenter = ( visibleRect.top() + visibleRect.bottom() ) / 2.0;
573 const double tinyHeight = 0.01;
574 QRectF targetRect( scene()->sceneRect().left(), verticalCenter - tinyHeight, scene()->sceneRect().width(), tinyHeight * 2 );
576 fitInView( targetRect, Qt::KeepAspectRatio );
610 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
611 for ( QGraphicsItem *graphicsItem : itemList )
615 if ( item && !paperItem )
652 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
653 for ( QGraphicsItem *graphicsItem : itemList )
657 if ( item && !paperItem )
660 if ( item->isSelected() || item->
isLocked() )
684 if ( !selectedItems.isEmpty() )
686 previousSelectedItem = selectedItems.at( 0 );
689 if ( !previousSelectedItem )
697 selectedItem = layout->
itemsModel()->findItemBelow( previousSelectedItem );
699 selectedItem = layout->
itemsModel()->findItemAbove( previousSelectedItem );
726 bool itemsRaised =
false;
749 bool itemsLowered =
false;
772 bool itemsRaised =
false;
795 bool itemsLowered =
false;
821 item->setLocked(
true );
841 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
842 for ( QGraphicsItem *graphicItem : itemList )
903 item->setSelected(
false );
916 QList<QgsLayoutItem *> ungroupedItems;
924 ungroupedItems.append(
currentLayout()->ungroupItems( itemGroup ) );
928 if ( !ungroupedItems.empty() )
930 for (
QgsLayoutItem *item : std::as_const( ungroupedItems ) )
932 item->setSelected(
true );
944 mSnapMarker->setVisible(
false );
949 mTool->layoutPressEvent( me.get() );
950 event->setAccepted( me->isAccepted() );
953 if ( !mTool || !event->isAccepted() )
955 if ( event->button() == Qt::MiddleButton && mTool != mSpacePanTool && mTool != mSpaceZoomTool )
958 setTool( mMidMouseButtonPanTool );
961 else if ( event->button() == Qt::RightButton && mMenuProvider )
963 QMenu *menu = mMenuProvider->createContextMenu(
this,
currentLayout(), mapToScene( event->pos() ) );
966 menu->exec( event->globalPos() );
972 QGraphicsView::mousePressEvent( event );
985 mTool->layoutReleaseEvent( me.get() );
986 event->setAccepted( me->isAccepted() );
989 if ( !mTool || !event->isAccepted() )
990 QGraphicsView::mouseReleaseEvent( event );
998 mMouseCurrentXY =
event->pos();
1000 QPointF cursorPos = mapToScene( mMouseCurrentXY );
1003 auto me = std::make_unique<QgsLayoutViewMouseEvent>(
this, event,
false );
1006 me->snapPoint( mHorizontalSnapLine, mVerticalSnapLine, mTool->ignoredSnapItems() );
1011 if ( me->isSnapped() )
1013 cursorPos = me->snappedPoint();
1016 mSnapMarker->setPos( me->snappedPoint() );
1017 mSnapMarker->setVisible(
true );
1020 else if ( mSnapMarker )
1022 mSnapMarker->setVisible(
false );
1025 mTool->layoutMoveEvent( me.get() );
1026 event->setAccepted( me->isAccepted() );
1032 if ( !mTool || !event->isAccepted() )
1033 QGraphicsView::mouseMoveEvent( event );
1044 mTool->layoutDoubleClickEvent( me.get() );
1045 event->setAccepted( me->isAccepted() );
1048 if ( !mTool || !event->isAccepted() )
1049 QGraphicsView::mouseDoubleClickEvent( event );
1059 mTool->wheelEvent( event );
1062 if ( !mTool || !event->isAccepted() )
1076 mTool->keyPressEvent( event );
1079 if ( mTool && event->isAccepted() )
1082 if ( event->key() == Qt::Key_Space && !event->isAutoRepeat() && mTool != mMidMouseButtonPanTool )
1084 if ( !( event->modifiers() & Qt::ControlModifier ) )
1096 else if ( event->key() == Qt::Key_Left
1097 || event->key() == Qt::Key_Right
1098 || event->key() == Qt::Key_Up
1099 || event->key() == Qt::Key_Down )
1110 item->attemptMoveBy( delta.x(), delta.y() );
1125 mTool->keyReleaseEvent( event );
1128 if ( !mTool || !event->isAccepted() )
1129 QGraphicsView::keyReleaseEvent( event );
1134 QGraphicsView::resizeEvent( event );
1141 QGraphicsView::scrollContentsBy( dx, dy );
1155 if ( mPaintingEnabled )
1157 QGraphicsView::paintEvent( event );
1166void QgsLayoutView::invalidateCachedRenders()
1172 QList<QgsLayoutItem *> items;
1177 item->invalidateCache();
1183 if ( mHorizontalRuler )
1185 mHorizontalRuler->setSceneTransform( viewportTransform() );
1187 if ( mVerticalRuler )
1189 mVerticalRuler->setSceneTransform( viewportTransform() );
1193 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
1194 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
1195 QPointF centerVisible = visibleRect.center();
1200 if ( newPage != mCurrentPage )
1202 mCurrentPage = newPage;
1213void QgsLayoutView::wheelZoom( QWheelEvent *event )
1217 double zoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2 ).toDouble();
1218 bool reverseZoom = settings.
value( QStringLiteral(
"qgis/reverse_wheel_zoom" ),
false ).toBool();
1219 bool zoomIn = reverseZoom ?
event->angleDelta().y() < 0 :
event->angleDelta().y() > 0;
1222 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
1224 if ( event->modifiers() & Qt::ControlModifier )
1227 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
1231 double scaleFactor = (
zoomIn ? 1 / zoomFactor : zoomFactor );
1234 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
1235 QgsRectangle visibleRect = QgsRectangle( mapToScene( viewportRect ).boundingRect() );
1238#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
1239 QPointF scenePoint = mapToScene( event->pos() );
1241 QPointF scenePoint = mapToScene( event->position().x(), event->position().y() );
1245 QgsPointXY oldCenter( visibleRect.
center() );
1246 QgsPointXY newCenter( scenePoint.x() + ( ( oldCenter.x() - scenePoint.x() ) * scaleFactor ), scenePoint.y() + ( ( oldCenter.y() - scenePoint.y() ) * scaleFactor ) );
1247 centerOn( newCenter.x(), newCenter.y() );
1260QGraphicsLineItem *QgsLayoutView::createSnapLine()
const
1262 auto item = std::make_unique<QGraphicsLineItem>(
nullptr );
1263 QPen pen = QPen( QColor( Qt::blue ) );
1264 pen.setStyle( Qt::DotLine );
1265 pen.setWidthF( 0.0 );
1266 item->setPen( pen );
1268 return item.release();
1276QgsLayoutViewSnapMarker::QgsLayoutViewSnapMarker()
1277 : QGraphicsRectItem( QRectF( 0, 0, 0, 0 ) )
1280 QFontMetrics fm( f );
1281 mSize = fm.horizontalAdvance(
'X' );
1282 setPen( QPen( Qt::transparent, mSize ) );
1284 setFlags( flags() | QGraphicsItem::ItemIgnoresTransformations );
1288void QgsLayoutViewSnapMarker::paint( QPainter *p,
const QStyleOptionGraphicsItem *, QWidget * )
1290 QPen pen( QColor( 255, 0, 0 ) );
1293 p->setBrush( Qt::NoBrush );
1295 double halfSize = mSize / 2.0;
1296 p->drawLine( QLineF( -halfSize, -halfSize, halfSize, halfSize ) );
1297 p->drawLine( QLineF( -halfSize, halfSize, halfSize, -halfSize ) );
@ Millimeters
Millimeters.
Alignment
Alignment options.
static void alignItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Alignment alignment)
Aligns a set of items from a layout in place.
static void distributeItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Distribution distribution)
Distributes a set of items from a layout in place.
static void resizeItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Resize resize)
Resizes a set of items from a layout in place.
Distribution
Distribution options.
Base class for frame items, which form a layout multiframe item.
A container for grouping several QgsLayoutItems.
Item representing the paper in a layout.
@ LayoutGroup
Grouped item.
Base class for graphical items within a QgsLayout.
@ UndoIncrementalMove
Layout item incremental movement, e.g. as a result of a keypress.
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.
void setLocked(bool locked)
Sets whether the item is locked, preventing mouse interactions with the item.
double length() const
Returns the length of the measurement.
QList< int > visiblePageNumbers(const QRectF ®ion) const
Returns a list of the page numbers which are visible within the specified region (in layout coordinat...
void changed()
Emitted when pages are added or removed from the collection.
int pageNumberForPoint(QPointF point) const
Returns the page number corresponding to a point in the layout (in layout units).
QList< QgsLayoutItemPage * > visiblePages(const QRectF ®ion) const
Returns a list of the pages which are visible within the specified region (in layout coordinates).
A custom ruler widget for use with QgsLayoutView, displaying the current zoom and position of the vis...
void setLayoutView(QgsLayoutView *view)
Sets the current layout view to synchronize the ruler with.
void endCommand()
Saves final state of an object and pushes the active command to the undo history.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
void endMacro()
Ends a macro command.
void alignSelectedItems(QgsLayoutAligner::Alignment alignment)
Aligns all selected items using the specified alignment.
void zoomFull()
Zooms the view to the full extent of the layout.
void selectNextItemBelow()
Selects the next item below the existing selection, by item z order.
QgsLayoutView(QWidget *parent=nullptr)
Constructor for QgsLayoutView.
void moveSelectedItemsToBottom()
Lowers the selected items to the bottom of the z-order.
void pushStatusMessage(const QString &message)
Pushes a new status bar message to the view.
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
void cursorPosChanged(QPointF layoutPoint)
Emitted when the mouse cursor coordinates change within the view.
@ PasteModeCenter
Paste items in center of view.
@ PasteModeInPlace
Paste items in place.
@ PasteModeCursor
Paste items at cursor position.
void unlockAllItems()
Unlocks all locked items in the layout.
void deleteSelectedItems()
Deletes all selected items.
void mouseMoveEvent(QMouseEvent *event) override
QgsLayout * currentLayout
void setMenuProvider(QgsLayoutViewMenuProvider *provider)
Sets a provider for context menus.
void dragEnterEvent(QDragEnterEvent *e) override
void resizeEvent(QResizeEvent *event) override
void lowerSelectedItems()
Lowers the selected items down the z-order.
void setPaintingEnabled(bool enabled)
Sets whether widget repainting should be allowed for the view.
void mouseReleaseEvent(QMouseEvent *event) override
QgsPreviewEffect::PreviewMode previewMode() const
Returns the preview mode which may be used to modify the view's appearance.
void lockSelectedItems()
Locks any selected items, preventing them from being interacted with by mouse interactions.
void setSectionLabel(const QString &label)
Sets a section label, to display above the first page shown in the view.
void resizeSelectedItems(QgsLayoutAligner::Resize resize)
Resizes all selected items using the specified resize mode.
void setTool(QgsLayoutViewTool *tool)
Sets the tool currently being used in the view.
void zoomLevelChanged()
Emitted whenever the zoom level of the view is changed.
void deleteItems(const QList< QgsLayoutItem * > &items)
Delete the specified items.
void selectAll()
Selects all items in the view.
QList< QgsLayoutItem * > pasteItems(PasteMode mode)
Pastes items from clipboard, using the specified mode.
void willBeDeleted()
Emitted in the destructor when the view is about to be deleted, but is still in a perfectly valid sta...
QPointF deltaForKeyEvent(QKeyEvent *event)
Returns the delta (in layout coordinates) by which to move items for the given key event.
void setHorizontalRuler(QgsLayoutRuler *ruler)
Sets a horizontal ruler to synchronize with the view state.
~QgsLayoutView() override
void setPreviewMode(QgsPreviewEffect::PreviewMode mode)
Sets the preview mode which should be used to modify the view's appearance.
void deselectAll()
Deselects all items in the view.
void keyPressEvent(QKeyEvent *event) override
void zoomWidth()
Zooms the view to the full width of the layout.
void raiseSelectedItems()
Raises the selected items up the z-order.
void statusMessage(const QString &message)
Emitted when the view has a message for display in a parent window's status bar.
void itemFocused(QgsLayoutItem *item)
Emitted when an item is "focused" in the view, i.e.
void selectNextItemAbove()
Selects the next item above the existing selection, by item z order.
void moveSelectedItemsToTop()
Raises the selected items to the top of the z-order.
bool hasItemsInClipboard() const
Returns true if the current clipboard contains layout items.
void zoomActual()
Zooms to the actual size of the layout.
void setPreviewModeEnabled(bool enabled)
Sets whether a preview effect should be used to alter the view's appearance.
void layoutSet(QgsLayout *layout)
Emitted when a layout is set for the view.
void setCurrentLayout(QgsLayout *layout)
Sets the current layout to edit in the view.
void wheelEvent(QWheelEvent *event) override
ClipboardOperation
Clipboard operations.
void ungroupSelectedItems()
Ungroups all selected items.
void emitZoomLevelChanged()
Emits the zoomLevelChanged() signal.
bool previewModeEnabled() const
Returns true if a preview effect is being used to alter the view's appearance.
void zoomOut()
Zooms out of the view by a preset amount.
void setVerticalRuler(QgsLayoutRuler *ruler)
Sets a vertical ruler to synchronize with the view state.
QList< QgsLayoutItemPage * > visiblePages() const
Returns a list of page items which are currently visible in the view.
void copyItems(const QList< QgsLayoutItem * > &items, ClipboardOperation operation)
Cuts or copies the a list of items, respecting the specified operation.
void setZoomLevel(double level)
Sets the zoom level for the view, where a zoom level of 1.0 corresponds to 100%.
void distributeSelectedItems(QgsLayoutAligner::Distribution distribution)
Distributes all selected items using the specified distribution.
void unsetTool(QgsLayoutViewTool *tool)
Unsets the current view tool, if it matches the specified tool.
void invertSelection()
Inverts the current selection, selecting deselected items and deselecting and selected items.
void toolSet(QgsLayoutViewTool *tool)
Emitted when the current tool is changed.
void mouseDoubleClickEvent(QMouseEvent *event) override
void scaleSafe(double scale)
Scales the view in a safe way, by limiting the acceptable range of the scale applied.
void pageChanged(int page)
Emitted when the page visible in the view is changed.
void scrollContentsBy(int dx, int dy) override
void copySelectedItems(ClipboardOperation operation)
Cuts or copies the selected items, respecting the specified operation.
void zoomIn()
Zooms in to the view by a preset amount.
void paintEvent(QPaintEvent *event) override
void keyReleaseEvent(QKeyEvent *event) override
QgsLayoutViewMenuProvider * menuProvider() const
Returns the provider for context menus.
QList< int > visiblePageNumbers() const
Returns a list of page numbers for pages which are currently visible in the view.
void groupSelectedItems()
Groups all selected items.
void mousePressEvent(QMouseEvent *event) override
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutModel * itemsModel()
Returns the items model attached to the layout.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
QgsLayoutGuideCollection & guides()
Returns a reference to the layout's guide collection, which manages page snap guides.
bool moveItemToTop(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up to the top of the z-order.
bool moveItemToBottom(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down to the bottom of the z-order.
QgsLayoutItemGroup * groupItems(const QList< QgsLayoutItem * > &items)
Creates a new group from a list of layout items and adds the group to the layout.
QList< QgsLayoutItem * > addItemsFromXml(const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context, QPointF *position=nullptr, bool pasteInPlace=false)
Add items from an XML representation to the layout.
bool lowerItem(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down the z-order.
QgsLayoutMeasurement convertFromLayoutUnits(double length, Qgis::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit.
bool raiseItem(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up the z-order.
QList< QgsLayoutItem * > selectedLayoutItems(bool includeLockedItems=true)
Returns list of selected layout items.
void selectedItemChanged(QgsLayoutItem *selected)
Emitted whenever the selected item changes.
void deselectAll()
Clears any selected items in the layout.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
void removeLayoutItem(QgsLayoutItem *item)
Removes an item from the layout.
void updateZValues(bool addUndoCommands=true)
Resets the z-values of items based on their position in the internal z order list.
@ ZSmartGuide
Z-value for smart (item bounds based) guides.
@ ZSnapIndicator
Z-value for snapping indicator.
QgsProject * project() const
The project associated with the layout.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
void setDirty(bool b=true)
Flag the project as dirty (modified).
A container for the context for various read/write operations on objects.
A utility class for dynamic handling of changes to screen properties.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void selectNextByZOrder(QgsLayout *layout, bool above)