QGIS API Documentation 3.41.0-Master (25ec5511245)
|
A graphical widget to display and interact with QgsLayouts. More...
#include <qgslayoutview.h>
Public Types | |
enum | ClipboardOperation { ClipboardCut , ClipboardCopy } |
Clipboard operations. More... | |
enum | PasteMode { PasteModeCursor , PasteModeCenter , PasteModeInPlace } |
Paste modes. More... | |
Public Slots | |
void | deleteItems (const QList< QgsLayoutItem * > &items) |
Delete the specified items. | |
void | deleteSelectedItems () |
Deletes all selected items. | |
void | deselectAll () |
Deselects all items in the view. | |
void | emitZoomLevelChanged () |
Emits the zoomLevelChanged() signal. | |
void | groupSelectedItems () |
Groups all selected items. | |
void | invertSelection () |
Inverts the current selection, selecting deselected items and deselecting and selected items. | |
void | lockSelectedItems () |
Locks any selected items, preventing them from being interacted with by mouse interactions. | |
void | lowerSelectedItems () |
Lowers the selected items down the z-order. | |
void | moveSelectedItemsToBottom () |
Lowers the selected items to the bottom of the z-order. | |
void | moveSelectedItemsToTop () |
Raises the selected items to the top of the z-order. | |
void | pushStatusMessage (const QString &message) |
Pushes a new status bar message to the view. | |
void | raiseSelectedItems () |
Raises the selected items up the z-order. | |
void | selectAll () |
Selects all items in the view. | |
void | selectNextItemAbove () |
Selects the next item above the existing selection, by item z order. | |
void | selectNextItemBelow () |
Selects the next item below the existing selection, by item z order. | |
void | ungroupSelectedItems () |
Ungroups all selected items. | |
void | unlockAllItems () |
Unlocks all locked items in the layout. | |
void | viewChanged () |
Updates associated rulers and other widgets after view extent or zoom has changed. | |
void | zoomActual () |
Zooms to the actual size of the layout. | |
void | zoomFull () |
Zooms the view to the full extent of the layout. | |
void | zoomIn () |
Zooms in to the view by a preset amount. | |
void | zoomOut () |
Zooms out of the view by a preset amount. | |
void | zoomWidth () |
Zooms the view to the full width of the layout. | |
Signals | |
void | cursorPosChanged (QPointF layoutPoint) |
Emitted when the mouse cursor coordinates change within the view. | |
void | itemFocused (QgsLayoutItem *item) |
Emitted when an item is "focused" in the view, i.e. | |
void | layoutSet (QgsLayout *layout) |
Emitted when a layout is set for the view. | |
void | pageChanged (int page) |
Emitted when the page visible in the view is changed. | |
void | statusMessage (const QString &message) |
Emitted when the view has a message for display in a parent window's status bar. | |
void | toolSet (QgsLayoutViewTool *tool) |
Emitted when the current tool is changed. | |
void | willBeDeleted () |
Emitted in the destructor when the view is about to be deleted, but is still in a perfectly valid state. | |
void | zoomLevelChanged () |
Emitted whenever the zoom level of the view is changed. | |
Public Member Functions | |
QgsLayoutView (QWidget *parent=nullptr) | |
Constructor for QgsLayoutView. | |
~QgsLayoutView () override | |
void | alignSelectedItems (QgsLayoutAligner::Alignment alignment) |
Aligns all selected items using the specified alignment. | |
void | copyItems (const QList< QgsLayoutItem * > &items, ClipboardOperation operation) |
Cuts or copies the a list of items, respecting the specified operation. | |
void | copySelectedItems (ClipboardOperation operation) |
Cuts or copies the selected items, respecting the specified operation. | |
QgsLayout * | currentLayout () |
Returns the current layout associated with the view. | |
const QgsLayout * | currentLayout () const |
Returns the current layout associated with the view. | |
int | currentPage () const |
Returns the page visible in the view. | |
QPointF | deltaForKeyEvent (QKeyEvent *event) |
Returns the delta (in layout coordinates) by which to move items for the given key event. | |
void | distributeSelectedItems (QgsLayoutAligner::Distribution distribution) |
Distributes all selected items using the specified distribution. | |
bool | hasItemsInClipboard () const |
Returns true if the current clipboard contains layout items. | |
QgsLayoutViewMenuProvider * | menuProvider () const |
Returns the provider for context menus. | |
QList< QgsLayoutItem * > | pasteItems (PasteMode mode) |
Pastes items from clipboard, using the specified mode. | |
QList< QgsLayoutItem * > | pasteItems (QPointF layoutPoint) |
Pastes items from clipboard, at the specified layoutPoint, in layout units. | |
QgsPreviewEffect::PreviewMode | previewMode () const |
Returns the preview mode which may be used to modify the view's appearance. | |
bool | previewModeEnabled () const |
Returns true if a preview effect is being used to alter the view's appearance. | |
void | resizeSelectedItems (QgsLayoutAligner::Resize resize) |
Resizes all selected items using the specified resize mode. | |
void | scaleSafe (double scale) |
Scales the view in a safe way, by limiting the acceptable range of the scale applied. | |
void | setCurrentLayout (QgsLayout *layout) |
Sets the current layout to edit in the view. | |
void | setHorizontalRuler (QgsLayoutRuler *ruler) |
Sets a horizontal ruler to synchronize with the view state. | |
void | setMenuProvider (QgsLayoutViewMenuProvider *provider) |
Sets a provider for context menus. | |
void | setPaintingEnabled (bool enabled) |
Sets whether widget repainting should be allowed for the view. | |
void | setPreviewMode (QgsPreviewEffect::PreviewMode mode) |
Sets the preview mode which should be used to modify the view's appearance. | |
void | setPreviewModeEnabled (bool enabled) |
Sets whether a preview effect should be used to alter the view's appearance. | |
void | setSectionLabel (const QString &label) |
Sets a section label, to display above the first page shown in the view. | |
void | setTool (QgsLayoutViewTool *tool) |
Sets the tool currently being used in the view. | |
void | setVerticalRuler (QgsLayoutRuler *ruler) |
Sets a vertical ruler to synchronize with the view state. | |
void | setZoomLevel (double level) |
Sets the zoom level for the view, where a zoom level of 1.0 corresponds to 100%. | |
QgsLayoutViewTool * | tool () |
Returns the currently active tool for the view. | |
void | unsetTool (QgsLayoutViewTool *tool) |
Unsets the current view tool, if it matches the specified tool. | |
QList< int > | visiblePageNumbers () const |
Returns a list of page numbers for pages which are currently visible in the view. | |
QList< QgsLayoutItemPage * > | visiblePages () const |
Returns a list of page items which are currently visible in the view. | |
Protected Member Functions | |
void | dragEnterEvent (QDragEnterEvent *e) override |
void | keyPressEvent (QKeyEvent *event) override |
void | keyReleaseEvent (QKeyEvent *event) override |
void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | paintEvent (QPaintEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
void | scrollContentsBy (int dx, int dy) override |
void | wheelEvent (QWheelEvent *event) override |
Properties | |
QgsLayout * | currentLayout |
QgsLayoutViewTool * | tool |
Friends | |
class | QgsLayoutMouseHandles |
class | TestQgsLayoutView |
A graphical widget to display and interact with QgsLayouts.
QgsLayoutView manages the layout interaction tools and mouse/key events.
Definition at line 49 of file qgslayoutview.h.
Clipboard operations.
Enumerator | |
---|---|
ClipboardCut | Cut items. |
ClipboardCopy | Copy items. |
Definition at line 69 of file qgslayoutview.h.
Paste modes.
Enumerator | |
---|---|
PasteModeCursor | Paste items at cursor position. |
PasteModeCenter | Paste items in center of view. |
PasteModeInPlace | Paste items in place. |
Definition at line 76 of file qgslayoutview.h.
QgsLayoutView::QgsLayoutView | ( | QWidget * | parent = nullptr | ) |
Constructor for QgsLayoutView.
Definition at line 47 of file qgslayoutview.cpp.
|
override |
Definition at line 72 of file qgslayoutview.cpp.
void QgsLayoutView::alignSelectedItems | ( | QgsLayoutAligner::Alignment | alignment | ) |
Aligns all selected items using the specified alignment.
Definition at line 281 of file qgslayoutview.cpp.
void QgsLayoutView::copyItems | ( | const QList< QgsLayoutItem * > & | items, |
QgsLayoutView::ClipboardOperation | operation | ||
) |
Cuts or copies the a list of items, respecting the specified operation.
Definition at line 313 of file qgslayoutview.cpp.
void QgsLayoutView::copySelectedItems | ( | QgsLayoutView::ClipboardOperation | operation | ) |
Cuts or copies the selected items, respecting the specified operation.
Definition at line 308 of file qgslayoutview.cpp.
QgsLayout * QgsLayoutView::currentLayout | ( | ) |
Returns the current layout associated with the view.
const QgsLayout * QgsLayoutView::currentLayout | ( | ) | const |
Returns the current layout associated with the view.
Definition at line 82 of file qgslayoutview.cpp.
|
inline |
Returns the page visible in the view.
This method considers the page at the center of the view as the current visible page.
Definition at line 203 of file qgslayoutview.h.
|
signal |
Emitted when the mouse cursor coordinates change within the view.
The layoutPoint argument indicates the cursor position within the layout coordinate system.
|
slot |
Delete the specified items.
Definition at line 854 of file qgslayoutview.cpp.
|
slot |
QPointF QgsLayoutView::deltaForKeyEvent | ( | QKeyEvent * | event | ) |
Returns the delta (in layout coordinates) by which to move items for the given key event.
Definition at line 470 of file qgslayoutview.cpp.
|
slot |
Deselects all items in the view.
Definition at line 621 of file qgslayoutview.cpp.
void QgsLayoutView::distributeSelectedItems | ( | QgsLayoutAligner::Distribution | distribution | ) |
Distributes all selected items using the specified distribution.
Definition at line 290 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1133 of file qgslayoutview.cpp.
|
slot |
Emits the zoomLevelChanged() signal.
This should be called after calling any of the QGraphicsView base class methods which alter the view's zoom level, i.e. QGraphicsView::fitInView().
Definition at line 584 of file qgslayoutview.cpp.
|
slot |
Groups all selected items.
Definition at line 872 of file qgslayoutview.cpp.
bool QgsLayoutView::hasItemsInClipboard | ( | ) | const |
Returns true
if the current clipboard contains layout items.
Definition at line 457 of file qgslayoutview.cpp.
|
slot |
Inverts the current selection, selecting deselected items and deselecting and selected items.
Definition at line 631 of file qgslayoutview.cpp.
|
signal |
Emitted when an item is "focused" in the view, i.e.
it becomes the active item and should have its properties displayed in any designer windows.
|
overrideprotected |
Definition at line 1057 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1106 of file qgslayoutview.cpp.
|
signal |
Emitted when a layout is set for the view.
|
slot |
Locks any selected items, preventing them from being interacted with by mouse interactions.
Definition at line 800 of file qgslayoutview.cpp.
|
slot |
Lowers the selected items down the z-order.
Definition at line 731 of file qgslayoutview.cpp.
QgsLayoutViewMenuProvider * QgsLayoutView::menuProvider | ( | ) | const |
Returns the provider for context menus.
Returned value may be nullptr
if no provider is set.
Definition at line 254 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1024 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 981 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 926 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 965 of file qgslayoutview.cpp.
|
slot |
Lowers the selected items to the bottom of the z-order.
Definition at line 777 of file qgslayoutview.cpp.
|
slot |
Raises the selected items to the top of the z-order.
Definition at line 754 of file qgslayoutview.cpp.
|
signal |
Emitted when the page visible in the view is changed.
This signal considers the page at the center of the view as the current visible page.
|
overrideprotected |
Definition at line 1141 of file qgslayoutview.cpp.
QList< QgsLayoutItem * > QgsLayoutView::pasteItems | ( | QgsLayoutView::PasteMode | mode | ) |
Pastes items from clipboard, using the specified mode.
A list of pasted items is returned.
Definition at line 393 of file qgslayoutview.cpp.
QList< QgsLayoutItem * > QgsLayoutView::pasteItems | ( | QPointF | layoutPoint | ) |
Pastes items from clipboard, at the specified layoutPoint, in layout units.
A list of pasted items is returned.
Definition at line 434 of file qgslayoutview.cpp.
QgsPreviewEffect::PreviewMode QgsLayoutView::previewMode | ( | ) | const |
Returns the preview mode which may be used to modify the view's appearance.
Preview modes are only used if previewModeEnabled() is true
.
Definition at line 184 of file qgslayoutview.cpp.
bool QgsLayoutView::previewModeEnabled | ( | ) | const |
Returns true
if a preview effect is being used to alter the view's appearance.
Definition at line 174 of file qgslayoutview.cpp.
|
slot |
Pushes a new status bar message to the view.
This causes statusMessage() to be emitted, which should cause the message to appear in the status bar for the parent window.
Definition at line 1196 of file qgslayoutview.cpp.
|
slot |
Raises the selected items up the z-order.
Definition at line 708 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1120 of file qgslayoutview.cpp.
void QgsLayoutView::resizeSelectedItems | ( | QgsLayoutAligner::Resize | resize | ) |
Resizes all selected items using the specified resize mode.
Definition at line 299 of file qgslayoutview.cpp.
void QgsLayoutView::scaleSafe | ( | double | scale | ) |
Scales the view in a safe way, by limiting the acceptable range of the scale applied.
The scale parameter specifies the zoom factor to scale the view by.
Definition at line 189 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1127 of file qgslayoutview.cpp.
|
slot |
Selects all items in the view.
Definition at line 589 of file qgslayoutview.cpp.
|
slot |
Selects the next item above the existing selection, by item z order.
Definition at line 698 of file qgslayoutview.cpp.
|
slot |
Selects the next item below the existing selection, by item z order.
Definition at line 703 of file qgslayoutview.cpp.
void QgsLayoutView::setCurrentLayout | ( | QgsLayout * | layout | ) |
Sets the current layout to edit in the view.
Definition at line 87 of file qgslayoutview.cpp.
void QgsLayoutView::setHorizontalRuler | ( | QgsLayoutRuler * | ruler | ) |
Sets a horizontal ruler to synchronize with the view state.
Definition at line 221 of file qgslayoutview.cpp.
void QgsLayoutView::setMenuProvider | ( | QgsLayoutViewMenuProvider * | provider | ) |
Sets a provider for context menus.
Ownership of the provider is transferred to the view.
Definition at line 249 of file qgslayoutview.cpp.
void QgsLayoutView::setPaintingEnabled | ( | bool | enabled | ) |
Sets whether widget repainting should be allowed for the view.
This is used to temporarily halt painting while exporting layouts.
Definition at line 512 of file qgslayoutview.cpp.
void QgsLayoutView::setPreviewMode | ( | QgsPreviewEffect::PreviewMode | mode | ) |
Sets the preview mode which should be used to modify the view's appearance.
Preview modes are only used if previewModeEnabled() is true
.
Definition at line 179 of file qgslayoutview.cpp.
void QgsLayoutView::setPreviewModeEnabled | ( | bool | enabled | ) |
Sets whether a preview effect should be used to alter the view's appearance.
enabled | Set to true to enable the preview effect on the view. |
Definition at line 169 of file qgslayoutview.cpp.
void QgsLayoutView::setSectionLabel | ( | const QString & | label | ) |
Sets a section label, to display above the first page shown in the view.
Definition at line 519 of file qgslayoutview.cpp.
void QgsLayoutView::setTool | ( | QgsLayoutViewTool * | tool | ) |
Sets the tool currently being used in the view.
Definition at line 133 of file qgslayoutview.cpp.
void QgsLayoutView::setVerticalRuler | ( | QgsLayoutRuler * | ruler | ) |
Sets a vertical ruler to synchronize with the view state.
Definition at line 235 of file qgslayoutview.cpp.
void QgsLayoutView::setZoomLevel | ( | double | level | ) |
Sets the zoom level for the view, where a zoom level of 1.0 corresponds to 100%.
Definition at line 199 of file qgslayoutview.cpp.
|
signal |
Emitted when the view has a message for display in a parent window's status bar.
QgsLayoutViewTool * QgsLayoutView::tool | ( | ) |
Returns the currently active tool for the view.
|
signal |
Emitted when the current tool is changed.
|
slot |
Ungroups all selected items.
Definition at line 897 of file qgslayoutview.cpp.
|
slot |
Unlocks all locked items in the layout.
Definition at line 816 of file qgslayoutview.cpp.
void QgsLayoutView::unsetTool | ( | QgsLayoutViewTool * | tool | ) |
Unsets the current view tool, if it matches the specified tool.
This is called from destructor of view tools to make sure that the tool won't be used any more. You don't have to call it manually, QgsLayoutViewTool takes care of it.
Definition at line 159 of file qgslayoutview.cpp.
|
slot |
Updates associated rulers and other widgets after view extent or zoom has changed.
This should be called after calling any of the QGraphicsView base class methods which alter the view's zoom level or extent, i.e. QGraphicsView::fitInView().
Definition at line 1169 of file qgslayoutview.cpp.
QList< int > QgsLayoutView::visiblePageNumbers | ( | ) | const |
Returns a list of page numbers for pages which are currently visible in the view.
Definition at line 270 of file qgslayoutview.cpp.
QList< QgsLayoutItemPage * > QgsLayoutView::visiblePages | ( | ) | const |
Returns a list of page items which are currently visible in the view.
Definition at line 259 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1040 of file qgslayoutview.cpp.
|
signal |
Emitted in the destructor when the view is about to be deleted, but is still in a perfectly valid state.
|
slot |
Zooms to the actual size of the layout.
Definition at line 579 of file qgslayoutview.cpp.
|
slot |
Zooms the view to the full extent of the layout.
Definition at line 534 of file qgslayoutview.cpp.
|
slot |
Zooms in to the view by a preset amount.
Definition at line 569 of file qgslayoutview.cpp.
|
signal |
Emitted whenever the zoom level of the view is changed.
|
slot |
Zooms out of the view by a preset amount.
Definition at line 574 of file qgslayoutview.cpp.
|
slot |
Zooms the view to the full width of the layout.
Definition at line 544 of file qgslayoutview.cpp.
|
friend |
Definition at line 584 of file qgslayoutview.h.
|
friend |
Definition at line 583 of file qgslayoutview.h.
|
readwrite |
Definition at line 63 of file qgslayoutview.h.
|
readwrite |
Definition at line 64 of file qgslayoutview.h.