QGIS API Documentation
3.10.0-A Coruña (6c816b4204)
|
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. More... | |
void | deleteSelectedItems () |
Deletes all selected items. More... | |
void | deselectAll () |
Deselects all items in the view. More... | |
void | emitZoomLevelChanged () |
Emits the zoomLevelChanged() signal. More... | |
void | groupSelectedItems () |
Groups all selected items. More... | |
void | invertSelection () |
Inverts the current selection, selecting deselected items and deselecting and selected items. More... | |
void | lockSelectedItems () |
Locks any selected items, preventing them from being interacted with by mouse interactions. More... | |
void | lowerSelectedItems () |
Lowers the selected items down the z-order. More... | |
void | moveSelectedItemsToBottom () |
Lowers the selected items to the bottom of the z-order. More... | |
void | moveSelectedItemsToTop () |
Raises the selected items to the top of the z-order. More... | |
void | pushStatusMessage (const QString &message) |
Pushes a new status bar message to the view. More... | |
void | raiseSelectedItems () |
Raises the selected items up the z-order. More... | |
void | selectAll () |
Selects all items in the view. More... | |
void | selectNextItemAbove () |
Selects the next item above the existing selection, by item z order. More... | |
void | selectNextItemBelow () |
Selects the next item below the existing selection, by item z order. More... | |
void | ungroupSelectedItems () |
Ungroups all selected items. More... | |
void | unlockAllItems () |
Unlocks all locked items in the layout. More... | |
void | viewChanged () |
Updates associated rulers and other widgets after view extent or zoom has changed. More... | |
void | zoomActual () |
Zooms to the actual size of the layout. More... | |
void | zoomFull () |
Zooms the view to the full extent of the layout. More... | |
void | zoomIn () |
Zooms in to the view by a preset amount. More... | |
void | zoomOut () |
Zooms out of the view by a preset amount. More... | |
void | zoomWidth () |
Zooms the view to the full width of the layout. More... | |
Signals | |
void | cursorPosChanged (QPointF layoutPoint) |
Emitted when the mouse cursor coordinates change within the view. More... | |
void | itemFocused (QgsLayoutItem *item) |
Emitted when an item is "focused" in the view, i.e. More... | |
void | layoutSet (QgsLayout *layout) |
Emitted when a layout is set for the view. More... | |
void | pageChanged (int page) |
Emitted when the page visible in the view is changed. More... | |
void | statusMessage (const QString &message) |
Emitted when the view has a message for display in a parent window's status bar. More... | |
void | toolSet (QgsLayoutViewTool *tool) |
Emitted when the current tool is changed. More... | |
void | willBeDeleted () |
Emitted in the destructor when the view is about to be deleted, but is still in a perfectly valid state. More... | |
void | zoomLevelChanged () |
Emitted whenever the zoom level of the view is changed. More... | |
Public Member Functions | |
QgsLayoutView (QWidget *parent=nullptr) | |
Constructor for QgsLayoutView. More... | |
~QgsLayoutView () override | |
void | alignSelectedItems (QgsLayoutAligner::Alignment alignment) |
Aligns all selected items using the specified alignment. More... | |
void | copyItems (const QList< QgsLayoutItem * > &items, ClipboardOperation operation) |
Cuts or copies the a list of items, respecting the specified operation. More... | |
void | copySelectedItems (ClipboardOperation operation) |
Cuts or copies the selected items, respecting the specified operation. More... | |
QgsLayout * | currentLayout () |
Returns the current layout associated with the view. More... | |
const QgsLayout * | currentLayout () const |
Returns the current layout associated with the view. More... | |
int | currentPage () const |
Returns the page visible in the view. More... | |
QPointF | deltaForKeyEvent (QKeyEvent *event) |
Returns the delta (in layout coordinates) by which to move items for the given key event. More... | |
void | distributeSelectedItems (QgsLayoutAligner::Distribution distribution) |
Distributes all selected items using the specified distribution. More... | |
bool | hasItemsInClipboard () const |
Returns true if the current clipboard contains layout items. More... | |
QgsLayoutViewMenuProvider * | menuProvider () const |
Returns the provider for context menus. More... | |
QList< QgsLayoutItem *> | pasteItems (PasteMode mode) |
Pastes items from clipboard, using the specified mode. More... | |
QList< QgsLayoutItem *> | pasteItems (QPointF layoutPoint) |
Pastes items from clipboard, at the specified layoutPoint, in layout units. More... | |
QgsPreviewEffect::PreviewMode | previewMode () const |
Returns the preview mode which may be used to modify the view's appearance. More... | |
bool | previewModeEnabled () const |
Returns true if a preview effect is being used to alter the view's appearance. More... | |
void | resizeSelectedItems (QgsLayoutAligner::Resize resize) |
Resizes all selected items using the specified resize mode. More... | |
void | scaleSafe (double scale) |
Scales the view in a safe way, by limiting the acceptable range of the scale applied. More... | |
void | setCurrentLayout (QgsLayout *layout) |
Sets the current layout to edit in the view. More... | |
void | setHorizontalRuler (QgsLayoutRuler *ruler) |
Sets a horizontal ruler to synchronize with the view state. More... | |
void | setMenuProvider (QgsLayoutViewMenuProvider *provider) |
Sets a provider for context menus. More... | |
void | setPaintingEnabled (bool enabled) |
Sets whether widget repainting should be allowed for the view. More... | |
void | setPreviewMode (QgsPreviewEffect::PreviewMode mode) |
Sets the preview mode which should be used to modify the view's appearance. More... | |
void | setPreviewModeEnabled (bool enabled) |
Sets whether a preview effect should be used to alter the view's appearance. More... | |
void | setSectionLabel (const QString &label) |
Sets a section label, to display above the first page shown in the view. More... | |
void | setTool (QgsLayoutViewTool *tool) |
Sets the tool currently being used in the view. More... | |
void | setVerticalRuler (QgsLayoutRuler *ruler) |
Sets a vertical ruler to synchronize with the view state. More... | |
void | setZoomLevel (double level) |
Sets the zoom level for the view, where a zoom level of 1.0 corresponds to 100%. More... | |
QgsLayoutViewTool * | tool () |
Returns the currently active tool for the view. More... | |
void | unsetTool (QgsLayoutViewTool *tool) |
Unsets the current view tool, if it matches the specified tool. More... | |
QList< int > | visiblePageNumbers () const |
Returns a list of page numbers for pages which are currently visible in the view. More... | |
QList< QgsLayoutItemPage *> | visiblePages () const |
Returns a list of page items which are currently visible in the view. More... | |
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 48 of file qgslayoutview.cpp.
|
override |
Definition at line 71 of file qgslayoutview.cpp.
void QgsLayoutView::alignSelectedItems | ( | QgsLayoutAligner::Alignment | alignment | ) |
Aligns all selected items using the specified alignment.
Definition at line 283 of file qgslayoutview.cpp.
void QgsLayoutView::copyItems | ( | const QList< QgsLayoutItem * > & | items, |
ClipboardOperation | operation | ||
) |
Cuts or copies the a list of items, respecting the specified operation.
Definition at line 315 of file qgslayoutview.cpp.
void QgsLayoutView::copySelectedItems | ( | QgsLayoutView::ClipboardOperation | operation | ) |
Cuts or copies the selected items, respecting the specified operation.
Definition at line 310 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.
|
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 855 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 471 of file qgslayoutview.cpp.
|
slot |
Deselects all items in the view.
Definition at line 622 of file qgslayoutview.cpp.
void QgsLayoutView::distributeSelectedItems | ( | QgsLayoutAligner::Distribution | distribution | ) |
Distributes all selected items using the specified distribution.
Definition at line 292 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1134 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 585 of file qgslayoutview.cpp.
|
slot |
Groups all selected items.
Definition at line 873 of file qgslayoutview.cpp.
bool QgsLayoutView::hasItemsInClipboard | ( | ) | const |
Returns true
if the current clipboard contains layout items.
Definition at line 458 of file qgslayoutview.cpp.
|
slot |
Inverts the current selection, selecting deselected items and deselecting and selected items.
Definition at line 632 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 1058 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1107 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 801 of file qgslayoutview.cpp.
|
slot |
Lowers the selected items down the z-order.
Definition at line 732 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 256 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1025 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 982 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 927 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 966 of file qgslayoutview.cpp.
|
slot |
Lowers the selected items to the bottom of the z-order.
Definition at line 778 of file qgslayoutview.cpp.
|
slot |
Raises the selected items to the top of the z-order.
Definition at line 755 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 1142 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 394 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 435 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 183 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 173 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 1197 of file qgslayoutview.cpp.
|
slot |
Raises the selected items up the z-order.
Definition at line 709 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1121 of file qgslayoutview.cpp.
void QgsLayoutView::resizeSelectedItems | ( | QgsLayoutAligner::Resize | resize | ) |
Resizes all selected items using the specified resize mode.
Definition at line 301 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 188 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1128 of file qgslayoutview.cpp.
|
slot |
Selects all items in the view.
Definition at line 590 of file qgslayoutview.cpp.
|
slot |
Selects the next item above the existing selection, by item z order.
Definition at line 699 of file qgslayoutview.cpp.
|
slot |
Selects the next item below the existing selection, by item z order.
Definition at line 704 of file qgslayoutview.cpp.
void QgsLayoutView::setCurrentLayout | ( | QgsLayout * | layout | ) |
Sets the current layout to edit in the view.
Definition at line 86 of file qgslayoutview.cpp.
void QgsLayoutView::setHorizontalRuler | ( | QgsLayoutRuler * | ruler | ) |
Sets a horizontal ruler to synchronize with the view state.
Definition at line 223 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 251 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 513 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 178 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 168 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 520 of file qgslayoutview.cpp.
void QgsLayoutView::setTool | ( | QgsLayoutViewTool * | tool | ) |
Sets the tool currently being used in the view.
Definition at line 132 of file qgslayoutview.cpp.
void QgsLayoutView::setVerticalRuler | ( | QgsLayoutRuler * | ruler | ) |
Sets a vertical ruler to synchronize with the view state.
Definition at line 237 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 198 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 898 of file qgslayoutview.cpp.
|
slot |
Unlocks all locked items in the layout.
Definition at line 817 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 158 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 1170 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 272 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 261 of file qgslayoutview.cpp.
|
overrideprotected |
Definition at line 1041 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 580 of file qgslayoutview.cpp.
|
slot |
Zooms the view to the full extent of the layout.
Definition at line 535 of file qgslayoutview.cpp.
|
slot |
Zooms in to the view by a preset amount.
Definition at line 570 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 575 of file qgslayoutview.cpp.
|
slot |
Zooms the view to the full width of the layout.
Definition at line 545 of file qgslayoutview.cpp.
|
friend |
Definition at line 582 of file qgslayoutview.h.
|
friend |
Definition at line 581 of file qgslayoutview.h.
|
readwrite |
Definition at line 63 of file qgslayoutview.h.
|
readwrite |
Definition at line 64 of file qgslayoutview.h.