41 #include <QDesktopWidget> 45 #define MIN_VIEW_SCALE 0.05 46 #define MAX_VIEW_SCALE 1000.0 49 : QGraphicsView( parent )
51 setResizeAnchor( QGraphicsView::AnchorViewCenter );
52 setMouseTracking(
true );
53 viewport()->setMouseTracking(
true );
59 viewport()->setStyleSheet( QStringLiteral(
"background-color:#d7d7d7;" ) );
66 viewport()->setGraphicsEffect( mPreviewEffect );
78 return qobject_cast<
QgsLayout *>( scene() );
83 return qobject_cast<
const QgsLayout *>( scene() );
97 mSnapMarker =
new QgsLayoutViewSnapMarker();
99 layout->addItem( mSnapMarker );
100 mHorizontalSnapLine = createSnapLine();
101 mHorizontalSnapLine->hide();
102 layout->addItem( mHorizontalSnapLine );
103 mVerticalSnapLine = createSnapLine();
104 mVerticalSnapLine->hide();
105 layout->addItem( mVerticalSnapLine );
106 mSectionLabel =
nullptr;
108 if ( mHorizontalRuler )
110 connect( &layout->
guides(), &QAbstractItemModel::dataChanged, mHorizontalRuler, [ = ] { mHorizontalRuler->update(); } );
111 connect( &layout->
guides(), &QAbstractItemModel::rowsInserted, mHorizontalRuler, [ = ] { mHorizontalRuler->
update(); } );
112 connect( &layout->
guides(), &QAbstractItemModel::rowsRemoved, mHorizontalRuler, [ = ] { mHorizontalRuler->
update(); } );
113 connect( &layout->
guides(), &QAbstractItemModel::modelReset, mHorizontalRuler, [ = ] { mHorizontalRuler->
update(); } );
115 if ( mVerticalRuler )
117 connect( &layout->
guides(), &QAbstractItemModel::dataChanged, mVerticalRuler, [ = ] { mVerticalRuler->update(); } );
118 connect( &layout->
guides(), &QAbstractItemModel::rowsInserted, mVerticalRuler, [ = ] { mVerticalRuler->
update(); } );
119 connect( &layout->
guides(), &QAbstractItemModel::rowsRemoved, mVerticalRuler, [ = ] { mVerticalRuler->
update(); } );
120 connect( &layout->
guides(), &QAbstractItemModel::modelReset, mVerticalRuler, [ = ] { mVerticalRuler->
update(); } );
145 if ( mHorizontalSnapLine )
146 mHorizontalSnapLine->hide();
147 if ( mVerticalSnapLine )
148 mVerticalSnapLine->hide();
160 if ( mTool && mTool == tool )
164 setCursor( Qt::ArrowCursor );
170 mPreviewEffect->setEnabled( enabled );
175 return mPreviewEffect->isEnabled();
180 mPreviewEffect->
setMode( mode );
185 return mPreviewEffect->
mode();
190 double currentScale = transform().m11();
191 scale *= currentScale;
193 setTransform( QTransform::fromScale( scale, scale ) );
205 setTransform( QTransform::fromScale( level, level ) );
209 double dpi = QgsApplication::desktop()->logicalDpiX();
211 if ( ( dpi < 60 ) || ( dpi > 1200 ) )
217 setTransform( QTransform::fromScale( mmLevel, mmLevel ) );
225 mHorizontalRuler = ruler;
229 connect( &layout->guides(), &QAbstractItemModel::dataChanged, ruler, [ = ] { mHorizontalRuler->update(); } );
230 connect( &layout->guides(), &QAbstractItemModel::rowsInserted, ruler, [ = ] { mHorizontalRuler->update(); } );
231 connect( &layout->guides(), &QAbstractItemModel::rowsRemoved, ruler, [ = ] { mHorizontalRuler->update(); } );
232 connect( &layout->guides(), &QAbstractItemModel::modelReset, ruler, [ = ] { mHorizontalRuler->update(); } );
239 mVerticalRuler = ruler;
243 connect( &layout->guides(), &QAbstractItemModel::dataChanged, ruler, [ = ] { mVerticalRuler->update(); } );
244 connect( &layout->guides(), &QAbstractItemModel::rowsInserted, ruler, [ = ] { mVerticalRuler->update(); } );
245 connect( &layout->guides(), &QAbstractItemModel::rowsRemoved, ruler, [ = ] { mVerticalRuler->update(); } );
246 connect( &layout->guides(), &QAbstractItemModel::modelReset, ruler, [ = ] { mVerticalRuler->update(); } );
253 mMenuProvider.reset( provider );
258 return mMenuProvider.get();
264 return QList< QgsLayoutItemPage *>();
267 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
268 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
275 return QList< int >();
278 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
279 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
322 QDomElement documentElement = doc.createElement( QStringLiteral(
"LayoutItemClipboard" ) );
326 QSet< QgsLayoutMultiFrame * > copiedMultiFrames;
333 const QList<QgsLayoutItem *> groupedItems = itemGroup->items();
336 groupedItem->writeXml( documentElement, doc, context );
339 else if (
QgsLayoutFrame *frame = qobject_cast<QgsLayoutFrame *>( item ) )
342 if ( frame->multiFrame() && !copiedMultiFrames.contains( frame->multiFrame() ) )
344 frame->multiFrame()->writeXml( documentElement, doc, context );
345 copiedMultiFrames.insert( frame->multiFrame() );
348 item->writeXml( documentElement, doc, context );
352 doc.appendChild( documentElement );
360 QDomNodeList itemsNodes = doc.elementsByTagName( QStringLiteral(
"LayoutItem" ) );
361 for (
int i = 0; i < itemsNodes.count(); ++i )
363 QDomNode itemNode = itemsNodes.at( i );
364 if ( itemNode.isElement() )
366 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
369 QDomNodeList multiFrameNodes = doc.elementsByTagName( QStringLiteral(
"LayoutMultiFrame" ) );
370 for (
int i = 0; i < multiFrameNodes.count(); ++i )
372 QDomNode multiFrameNode = multiFrameNodes.at( i );
373 if ( multiFrameNode.isElement() )
375 multiFrameNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
376 QDomNodeList frameNodes = multiFrameNode.toElement().elementsByTagName( QStringLiteral(
"childFrame" ) );
377 for (
int j = 0; j < frameNodes.count(); ++j )
379 QDomNode itemNode = frameNodes.at( j );
380 if ( itemNode.isElement() )
382 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
388 QMimeData *mimeData =
new QMimeData;
389 mimeData->setData( QStringLiteral(
"text/xml" ), doc.toByteArray() );
390 QClipboard *clipboard = QApplication::clipboard();
391 clipboard->setMimeData( mimeData );
397 return QList< QgsLayoutItem * >();
399 QList< QgsLayoutItem * > pastedItems;
401 QClipboard *clipboard = QApplication::clipboard();
402 if ( doc.setContent( clipboard->mimeData()->data( QStringLiteral(
"text/xml" ) ) ) )
404 QDomElement docElem = doc.documentElement();
405 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
414 pt = mapToScene( mapFromGlobal( QCursor::pos() ) );
420 pt = mapToScene( viewport()->rect().center() );
438 return QList<QgsLayoutItem *>();
440 QList< QgsLayoutItem * > pastedItems;
442 QClipboard *clipboard = QApplication::clipboard();
443 if ( doc.setContent( clipboard->mimeData()->data( QStringLiteral(
"text/xml" ) ) ) )
445 QDomElement docElem = doc.documentElement();
446 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
461 QClipboard *clipboard = QApplication::clipboard();
462 if ( doc.setContent( clipboard->mimeData()->data( QStringLiteral(
"text/xml" ) ) ) )
464 QDomElement docElem = doc.documentElement();
465 if ( docElem.tagName() == QLatin1String(
"LayoutItemClipboard" ) )
474 double increment = 1.0;
475 if ( event->modifiers() & Qt::ShiftModifier )
480 else if ( event->modifiers() & Qt::AltModifier )
483 double viewScale = transform().m11();
486 increment = 1 / viewScale;
492 switch ( event->key() )
510 return QPointF( deltaX, deltaY );
515 mPaintingEnabled = enabled;
525 if ( !mSectionLabel )
527 mSectionLabel =
new QgsLayoutReportSectionLabel(
currentLayout(),
this );
529 mSectionLabel->setRect( 0, -200, 1000, 200 );
530 mSectionLabel->setZValue( -1 );
532 mSectionLabel->setLabel( label );
540 fitInView( scene()->sceneRect(), Qt::KeepAspectRatio );
551 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
552 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
554 double verticalCenter = ( visibleRect.top() + visibleRect.bottom() ) / 2.0;
559 const double tinyHeight = 0.01;
560 QRectF targetRect( scene()->sceneRect().left(),
561 verticalCenter - tinyHeight,
562 scene()->sceneRect().width(),
565 fitInView( targetRect, Qt::KeepAspectRatio );
599 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
600 for ( QGraphicsItem *graphicsItem : itemList )
604 if ( item && !paperItem )
641 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
642 for ( QGraphicsItem *graphicsItem : itemList )
646 if ( item && !paperItem )
649 if ( item->isSelected() || item->
isLocked() )
673 if ( !selectedItems.isEmpty() )
675 previousSelectedItem = selectedItems.at( 0 );
678 if ( !previousSelectedItem )
686 selectedItem = layout->
itemsModel()->findItemBelow( previousSelectedItem );
688 selectedItem = layout->
itemsModel()->findItemAbove( previousSelectedItem );
715 bool itemsRaised =
false;
738 bool itemsLowered =
false;
761 bool itemsRaised =
false;
784 bool itemsLowered =
false;
810 item->setLocked(
true );
830 const QList<QGraphicsItem *> itemList =
currentLayout()->items();
831 for ( QGraphicsItem *graphicItem : itemList )
905 QList< QgsLayoutItem * > ungroupedItems;
913 ungroupedItems.append(
currentLayout()->ungroupItems( itemGroup ) );
917 if ( !ungroupedItems.empty() )
919 for (
QgsLayoutItem *item : qgis::as_const( ungroupedItems ) )
933 mSnapMarker->setVisible(
false );
938 mTool->layoutPressEvent( me.get() );
939 event->setAccepted( me->isAccepted() );
942 if ( !mTool || !event->isAccepted() )
944 if ( event->button() == Qt::MidButton )
947 setTool( mMidMouseButtonPanTool );
950 else if ( event->button() == Qt::RightButton && mMenuProvider )
952 QMenu *menu = mMenuProvider->createContextMenu(
this,
currentLayout(), mapToScene( event->pos() ) );
955 menu->exec( event->globalPos() );
961 QGraphicsView::mousePressEvent( event );
974 mTool->layoutReleaseEvent( me.get() );
975 event->setAccepted( me->isAccepted() );
978 if ( !mTool || !event->isAccepted() )
979 QGraphicsView::mouseReleaseEvent( event );
987 mMouseCurrentXY =
event->pos();
989 QPointF cursorPos = mapToScene( mMouseCurrentXY );
995 me->snapPoint( mHorizontalSnapLine, mVerticalSnapLine, mTool->ignoredSnapItems() );
1000 if ( me->isSnapped() )
1002 cursorPos = me->snappedPoint();
1005 mSnapMarker->setPos( me->snappedPoint() );
1006 mSnapMarker->setVisible(
true );
1009 else if ( mSnapMarker )
1011 mSnapMarker->setVisible(
false );
1014 mTool->layoutMoveEvent( me.get() );
1015 event->setAccepted( me->isAccepted() );
1021 if ( !mTool || !event->isAccepted() )
1022 QGraphicsView::mouseMoveEvent( event );
1033 mTool->layoutDoubleClickEvent( me.get() );
1034 event->setAccepted( me->isAccepted() );
1037 if ( !mTool || !event->isAccepted() )
1038 QGraphicsView::mouseDoubleClickEvent( event );
1048 mTool->wheelEvent( event );
1051 if ( !mTool || !event->isAccepted() )
1065 mTool->keyPressEvent( event );
1068 if ( mTool && event->isAccepted() )
1071 if ( event->key() == Qt::Key_Space && !
event->isAutoRepeat() )
1073 if ( !( event->modifiers() & Qt::ControlModifier ) )
1085 else if ( event->key() == Qt::Key_Left
1086 ||
event->key() == Qt::Key_Right
1087 ||
event->key() == Qt::Key_Up
1088 ||
event->key() == Qt::Key_Down )
1099 item->attemptMoveBy( delta.x(), delta.y() );
1114 mTool->keyReleaseEvent( event );
1117 if ( !mTool || !event->isAccepted() )
1118 QGraphicsView::keyReleaseEvent( event );
1123 QGraphicsView::resizeEvent( event );
1130 QGraphicsView::scrollContentsBy( dx, dy );
1144 if ( mPaintingEnabled )
1146 QGraphicsView::paintEvent( event );
1155 void QgsLayoutView::invalidateCachedRenders()
1161 QList< QgsLayoutItem *> items;
1166 item->invalidateCache();
1172 if ( mHorizontalRuler )
1176 if ( mVerticalRuler )
1182 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
1183 QRectF visibleRect = mapToScene( viewportRect ).boundingRect();
1184 QPointF centerVisible = visibleRect.center();
1189 if ( newPage != mCurrentPage )
1191 mCurrentPage = newPage;
1202 void QgsLayoutView::wheelZoom( QWheelEvent *event )
1206 double zoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2 ).toDouble();
1209 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
1211 if ( event->modifiers() & Qt::ControlModifier )
1214 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
1218 bool zoomIn =
event->angleDelta().y() > 0;
1219 double scaleFactor = ( zoomIn ? 1 / zoomFactor : zoomFactor );
1222 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
1226 QPointF scenePoint = mapToScene( event->pos() );
1230 QgsPointXY newCenter( scenePoint.x() + ( ( oldCenter.x() - scenePoint.x() ) * scaleFactor ),
1231 scenePoint.y() + ( ( oldCenter.y() - scenePoint.y() ) * scaleFactor ) );
1232 centerOn( newCenter.x(), newCenter.y() );
1245 QGraphicsLineItem *QgsLayoutView::createSnapLine()
const 1247 std::unique_ptr< QGraphicsLineItem> item(
new QGraphicsLineItem(
nullptr ) );
1248 QPen pen = QPen( QColor( Qt::blue ) );
1249 pen.setStyle( Qt::DotLine );
1250 pen.setWidthF( 0.0 );
1251 item->setPen( pen );
1253 return item.release();
1261 QgsLayoutViewSnapMarker::QgsLayoutViewSnapMarker()
1262 : QGraphicsRectItem( QRectF( 0, 0, 0, 0 ) )
1265 QFontMetrics fm( f );
1266 mSize = fm.width( QStringLiteral(
"X" ) );
1267 setPen( QPen( Qt::transparent, mSize ) );
1269 setFlags( flags() | QGraphicsItem::ItemIgnoresTransformations );
1273 void QgsLayoutViewSnapMarker::paint( QPainter *p,
const QStyleOptionGraphicsItem *, QWidget * )
1275 QPen pen( QColor( 255, 0, 0 ) );
1278 p->setBrush( Qt::NoBrush );
1280 double halfSize = mSize / 2.0;
1281 p->drawLine( QLineF( -halfSize, -halfSize, halfSize, halfSize ) );
1282 p->drawLine( QLineF( -halfSize, halfSize, halfSize, -halfSize ) );
void setDirty(bool b=true)
Flag the project as dirty (modified).
void pushStatusMessage(const QString &message)
Pushes a new status bar message to the view.
A custom ruler widget for use with QgsLayoutView, displaying the current zoom and position of the vis...
The class is used as a container of context for various read/write operations on other objects...
void selectAll()
Selects all items in the view.
void selectNextItemBelow()
Selects the next item below the existing selection, by item z order.
A rectangle specified with double values.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
bool raiseItem(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up the z-order.
void keyPressEvent(QKeyEvent *event) override
QgsLayoutGuideCollection & guides()
Returns a reference to the layout's guide collection, which manages page snap guides.
QList< QgsLayoutItem *> pasteItems(PasteMode mode)
Pastes items from clipboard, using the specified mode.
void zoomIn()
Zooms in to the view by a preset amount.
QgsLayout * currentLayout()
Returns the current layout associated with the view.
Base class for graphical items within a QgsLayout.
QgsPreviewEffect::PreviewMode previewMode() const
Returns the preview mode which may be used to modify the view's appearance.
void toolSet(QgsLayoutViewTool *tool)
Emitted when the current tool is changed.
void moveSelectedItemsToTop()
Raises the selected items to the top of the z-order.
void distributeSelectedItems(QgsLayoutAligner::Distribution distribution)
Distributes all selected items using the specified distribution.
This class is a composition of two QSettings instances:
int pageNumberForPoint(QPointF point) const
Returns the page number corresponding to a point in the layout (in layout units). ...
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
void layoutSet(QgsLayout *layout)
Emitted when a layout is set for the view.
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)
QgsLayoutItemGroup * groupItems(const QList< QgsLayoutItem *> &items)
Creates a new group from a list of layout items and adds the group to the layout. ...
Paste items in center of view.
A class to represent a 2D point.
void setTool(QgsLayoutViewTool *tool)
Sets the tool currently being used in the view.
void resizeSelectedItems(QgsLayoutAligner::Resize resize)
Resizes all selected items using the specified resize mode.
A container for grouping several QgsLayoutItems.
Paste items at cursor position.
void setMenuProvider(QgsLayoutViewMenuProvider *provider)
Sets a provider for context menus.
void zoomActual()
Zooms to the actual size of the layout.
void scrollContentsBy(int dx, int dy) override
void zoomFull()
Zooms the view to the full extent of the layout.
Z-value for snapping indicator.
void mouseMoveEvent(QMouseEvent *event) override
void alignSelectedItems(QgsLayoutAligner::Alignment alignment)
Aligns all selected items using the specified alignment.
virtual void setSelected(bool selected)
Sets whether the item should be selected.
void mousePressEvent(QMouseEvent *event) override
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.
void changed()
Emitted when pages are added or removed from the collection.
QPointF deltaForKeyEvent(QKeyEvent *event)
Returns the delta (in layout coordinates) by which to move items for the given key event...
void pageChanged(int page)
Emitted when the page visible in the view is changed.
void paintEvent(QPaintEvent *event) override
QList< int > visiblePageNumbers(const QRectF ®ion) const
Returns a list of the page numbers which are visible within the specified region (in layout coordinat...
static void alignItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Alignment alignment)
Aligns a set of items from a layout in place.
ClipboardOperation
Clipboard operations.
void setCurrentLayout(QgsLayout *layout)
Sets the current layout to edit in the view.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
bool previewModeEnabled() const
Returns true if a preview effect is being used to alter the view's appearance.
void setHorizontalRuler(QgsLayoutRuler *ruler)
Sets a horizontal ruler to synchronize with the view state.
void cursorPosChanged(QPointF layoutPoint)
Emitted when the mouse cursor coordinates change within the view.
void layoutItems(QList< T *> &itemList) const
Returns a list of layout items of a specific type.
void setPaintingEnabled(bool enabled)
Sets whether widget repainting should be allowed for the view.
void deselectAll()
Clears any selected items in the layout.
Z-value for smart (item bounds based) guides.
void updateZValues(bool addUndoCommands=true)
Resets the z-values of items based on their position in the internal z order list.
void statusMessage(const QString &message)
Emitted when the view has a message for display in a parent window's status bar.
void zoomWidth()
Zooms the view to the full width of the layout.
QList< QgsLayoutItemPage *> visiblePages(const QRectF ®ion) const
Returns a list of the pages which are visible within the specified region (in layout coordinates)...
void endCommand()
Saves final state of an object and pushes the active command to the undo history. ...
QgsLayoutViewMenuProvider * menuProvider() const
Returns the provider for context menus.
void setLocked(bool locked)
Sets whether the item is locked, preventing mouse interactions with the item.
Distribution
Distribution options.
void mouseReleaseEvent(QMouseEvent *event) override
void wheelEvent(QWheelEvent *event) override
void raiseSelectedItems()
Raises the selected items up the z-order.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
QList< QgsLayoutItem * > selectedLayoutItems(bool includeLockedItems=true)
Returns list of selected layout items.
void selectedItemChanged(QgsLayoutItem *selected)
Emitted whenever the selected item changes.
static void distributeItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Distribution distribution)
Distributes a set of items from a layout in place.
~QgsLayoutView() override
QgsLayoutViewTool * tool()
Returns the currently active tool for the view.
void setSceneTransform(const QTransform &transform)
Sets the current scene transform.
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 resizeEvent(QResizeEvent *event) override
void lowerSelectedItems()
Lowers the selected items down the z-order.
QgsLayoutView(QWidget *parent=nullptr)
Constructor for QgsLayoutView.
void copySelectedItems(ClipboardOperation operation)
Cuts or copies the selected items, respecting the specified operation.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void setMode(PreviewMode mode)
Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance...
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void lockSelectedItems()
Locks any selected items, preventing them from being interacted with by mouse interactions.
void setLayoutView(QgsLayoutView *view)
Sets the current layout view to synchronize the ruler with.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView...
void dragEnterEvent(QDragEnterEvent *e) override
void zoomOut()
Zooms out of the view by a preset amount.
PreviewMode mode() const
Returns the mode used for the preview effect.
bool lowerItem(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down the z-order.
void invertSelection()
Inverts the current selection, selecting deselected items and deselecting and selected items...
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
void unlockAllItems()
Unlocks all locked items in the layout.
QList< int > visiblePageNumbers() const
Returns a list of page numbers for pages which are currently visible in the view. ...
QgsLayoutModel * itemsModel()
Returns the items model attached to the layout.
void unsetTool(QgsLayoutViewTool *tool)
Unsets the current view tool, if it matches the specified tool.
bool moveItemToBottom(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down to the bottom of the z-order.
void groupSelectedItems()
Groups all selected items.
double length() const
Returns the length of the measurement.
void moveSelectedItemsToBottom()
Lowers the selected items to the bottom of the z-order.
void removeLayoutItem(QgsLayoutItem *item)
Removes an item from the layout.
void scaleSafe(double scale)
Scales the view in a safe way, by limiting the acceptable range of the scale applied.
void itemFocused(QgsLayoutItem *item)
Emitted when an item is "focused" in the view, i.e.
void keyReleaseEvent(QKeyEvent *event) override
void zoomLevelChanged()
Emitted whenever the zoom level of the view is changed.
void mouseDoubleClickEvent(QMouseEvent *event) override
void deleteItems(const QList< QgsLayoutItem * > &items)
Delete the specified items.
void update()
Updates the position (and visibility) of all guide line items.
void setVerticalRuler(QgsLayoutRuler *ruler)
Sets a vertical ruler to synchronize with the view state.
QgsLayoutMeasurement convertFromLayoutUnits(double length, QgsUnitTypes::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit...
Alignment
Alignment options.
QgsProject * project() const
The project associated with the layout.
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
void selectNextItemAbove()
Selects the next item above the existing selection, by item z order.
Layout item incremental movement, e.g. as a result of a keypress.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
void setSectionLabel(const QString &label)
Sets a section label, to display above the first page shown in the view.
void setZoomLevel(double level)
Sets the zoom level for the view, where a zoom level of 1.0 corresponds to 100%.
QgsPointXY center() const
Returns the center point of the rectangle.
void endMacro()
Ends a macro command.
void ungroupSelectedItems()
Ungroups all selected items.
bool moveItemToTop(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up to the top of the z-order.
static void resizeItems(QgsLayout *layout, const QList< QgsLayoutItem * > &items, Resize resize)
Resizes a set of items from a layout in place.
void deleteSelectedItems()
Deletes all selected items.
Base class for frame items, which form a layout multiframe item.
bool hasItemsInClipboard() const
Returns true if the current clipboard contains layout items.
void setPreviewMode(QgsPreviewEffect::PreviewMode mode)
Sets the preview mode which should be used to modify the view's appearance.
void willBeDeleted()
Emitted in the destructor when the view is about to be deleted, but is still in a perfectly valid sta...
Item representing the paper in a layout.
void setPreviewModeEnabled(bool enabled)
Sets whether a preview effect should be used to alter the view's appearance.
void emitZoomLevelChanged()
Emits the zoomLevelChanged() signal.
void deselectAll()
Deselects all items in the view.