QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
Public Types | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsLayoutViewTool Class Reference

Abstract base class for all layout view tools. More...

#include <qgslayoutviewtool.h>

Inheritance diagram for QgsLayoutViewTool:
Inheritance graph
[legend]

Public Types

enum  Flag { FlagSnaps = 1 << 1 }
 Flags for controlling how a tool behaves. More...
 

Signals

void activated ()
 Emitted when the tool is activated. More...
 
void deactivated ()
 Emitted when the tool is deactivated. More...
 
void itemFocused (QgsLayoutItem *item)
 Emitted when an item is "focused" by the tool, i.e. More...
 

Public Member Functions

 ~QgsLayoutViewTool () override
 
QAction * action ()
 Returns the action associated with the tool or nullptr if no action is associated. More...
 
virtual void activate ()
 Called when tool is set as the currently active layout tool. More...
 
virtual void deactivate ()
 Called when tool is deactivated. More...
 
QgsLayoutViewTool::Flags flags () const
 Returns the current combination of flags set for the tool. More...
 
virtual QList< QgsLayoutItem * > ignoredSnapItems () const
 Returns a list of items which should be ignored while snapping events for this tool. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 Key press event for overriding. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Key release event for overriding. More...
 
QgsLayoutlayout () const
 Returns the layout associated with the tool. More...
 
virtual void layoutDoubleClickEvent (QgsLayoutViewMouseEvent *event)
 Mouse double-click event for overriding. More...
 
virtual void layoutMoveEvent (QgsLayoutViewMouseEvent *event)
 Mouse move event for overriding. More...
 
virtual void layoutPressEvent (QgsLayoutViewMouseEvent *event)
 Mouse press event for overriding. More...
 
virtual void layoutReleaseEvent (QgsLayoutViewMouseEvent *event)
 Mouse release event for overriding. More...
 
void setAction (QAction *action)
 Associates an action with this tool. More...
 
void setCursor (const QCursor &cursor)
 Sets a user defined cursor for use when the tool is active. More...
 
QString toolName () const
 Returns a user-visible, translated name for the tool. More...
 
QgsLayoutViewview () const
 Returns the view associated with the tool. More...
 
virtual void wheelEvent (QWheelEvent *event)
 Mouse wheel event for overriding. More...
 

Protected Member Functions

 QgsLayoutViewTool (QgsLayoutView *view, const QString &name)
 Constructor for QgsLayoutViewTool, taking a layout view and tool name as parameters. More...
 
bool isClickAndDrag (QPoint startViewPoint, QPoint endViewPoint) const
 Returns true if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a "click and drag". More...
 
void setFlags (QgsLayoutViewTool::Flags flags)
 Sets the combination of flags that will be used for the tool. More...
 

Friends

class TestQgsLayoutView
 

Detailed Description

Abstract base class for all layout view tools.

Layout view tools are user interactive tools for manipulating and adding items to QgsLayoutView widgets.

Since
QGIS 3.0

Definition at line 46 of file qgslayoutviewtool.h.

Member Enumeration Documentation

◆ Flag

Flags for controlling how a tool behaves.

Enumerator
FlagSnaps 

Tool utilizes snapped coordinates.

Definition at line 63 of file qgslayoutviewtool.h.

Constructor & Destructor Documentation

◆ ~QgsLayoutViewTool()

QgsLayoutViewTool::~QgsLayoutViewTool ( )
override

Definition at line 53 of file qgslayoutviewtool.cpp.

◆ QgsLayoutViewTool()

QgsLayoutViewTool::QgsLayoutViewTool ( QgsLayoutView view,
const QString &  name 
)
protected

Constructor for QgsLayoutViewTool, taking a layout view and tool name as parameters.

Definition at line 20 of file qgslayoutviewtool.cpp.

Member Function Documentation

◆ action()

QAction * QgsLayoutViewTool::action ( )

Returns the action associated with the tool or nullptr if no action is associated.

See also
setAction()

Definition at line 109 of file qgslayoutviewtool.cpp.

◆ activate()

void QgsLayoutViewTool::activate ( )
virtual

Called when tool is set as the currently active layout tool.

Overridden implementations must take care to call the base class implementation.

Reimplemented in QgsLayoutViewToolAddItem, QgsLayoutViewToolEditNodes, QgsLayoutViewToolTemporaryKeyPan, QgsLayoutViewToolTemporaryKeyZoom, and QgsLayoutViewToolTemporaryMousePan.

Definition at line 120 of file qgslayoutviewtool.cpp.

◆ activated

void QgsLayoutViewTool::activated ( )
signal

Emitted when the tool is activated.

◆ deactivate()

void QgsLayoutViewTool::deactivate ( )
virtual

Called when tool is deactivated.

Overridden implementations must take care to call the base class implementation.

Reimplemented in QgsLayoutViewToolAddItem, QgsLayoutViewToolAddNodeItem, QgsLayoutViewToolEditNodes, QgsLayoutViewToolPan, QgsLayoutViewToolSelect, and QgsLayoutViewToolZoom.

Definition at line 130 of file qgslayoutviewtool.cpp.

◆ deactivated

void QgsLayoutViewTool::deactivated ( )
signal

Emitted when the tool is deactivated.

◆ flags()

QgsLayoutViewTool::Flags QgsLayoutViewTool::flags ( ) const

Returns the current combination of flags set for the tool.

See also
setFlags()

Definition at line 59 of file qgslayoutviewtool.cpp.

◆ ignoredSnapItems()

QList< QgsLayoutItem * > QgsLayoutViewTool::ignoredSnapItems ( ) const
virtual

Returns a list of items which should be ignored while snapping events for this tool.

Reimplemented in QgsLayoutViewToolEditNodes.

Definition at line 48 of file qgslayoutviewtool.cpp.

◆ isClickAndDrag()

bool QgsLayoutViewTool::isClickAndDrag ( QPoint  startViewPoint,
QPoint  endViewPoint 
) const
protected

Returns true if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a "click and drag".

If false is returned, the operation should be instead treated as just a click on startViewPoint.

Definition at line 31 of file qgslayoutviewtool.cpp.

◆ itemFocused

void QgsLayoutViewTool::itemFocused ( QgsLayoutItem item)
signal

Emitted when an item is "focused" by the tool, i.e.

it should become the active item and should have its properties displayed in any designer windows.

◆ keyPressEvent()

void QgsLayoutViewTool::keyPressEvent ( QKeyEvent *  event)
virtual

Key press event for overriding.

Default implementation does nothing.

Reimplemented in QgsLayoutViewToolAddNodeItem, QgsLayoutViewToolEditNodes, QgsLayoutViewToolSelect, QgsLayoutViewToolTemporaryKeyZoom, and QgsLayoutViewToolZoom.

Definition at line 94 of file qgslayoutviewtool.cpp.

◆ keyReleaseEvent()

void QgsLayoutViewTool::keyReleaseEvent ( QKeyEvent *  event)
virtual

Key release event for overriding.

Default implementation does nothing.

Reimplemented in QgsLayoutViewToolTemporaryKeyPan, QgsLayoutViewToolTemporaryKeyZoom, and QgsLayoutViewToolZoom.

Definition at line 99 of file qgslayoutviewtool.cpp.

◆ layout()

QgsLayout * QgsLayoutViewTool::layout ( ) const

Returns the layout associated with the tool.

See also
view()

Definition at line 43 of file qgslayoutviewtool.cpp.

◆ layoutDoubleClickEvent()

void QgsLayoutViewTool::layoutDoubleClickEvent ( QgsLayoutViewMouseEvent event)
virtual

Mouse double-click event for overriding.

Default implementation does nothing.

Reimplemented in QgsLayoutViewToolEditNodes.

Definition at line 74 of file qgslayoutviewtool.cpp.

◆ layoutMoveEvent()

void QgsLayoutViewTool::layoutMoveEvent ( QgsLayoutViewMouseEvent event)
virtual

◆ layoutPressEvent()

void QgsLayoutViewTool::layoutPressEvent ( QgsLayoutViewMouseEvent event)
virtual

Mouse press event for overriding.

Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

Reimplemented in QgsLayoutViewToolAddItem, QgsLayoutViewToolAddNodeItem, QgsLayoutViewToolEditNodes, QgsLayoutViewToolMoveItemContent, QgsLayoutViewToolPan, QgsLayoutViewToolSelect, and QgsLayoutViewToolZoom.

Definition at line 79 of file qgslayoutviewtool.cpp.

◆ layoutReleaseEvent()

void QgsLayoutViewTool::layoutReleaseEvent ( QgsLayoutViewMouseEvent event)
virtual

Mouse release event for overriding.

Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

Reimplemented in QgsLayoutViewToolAddItem, QgsLayoutViewToolAddNodeItem, QgsLayoutViewToolEditNodes, QgsLayoutViewToolMoveItemContent, QgsLayoutViewToolPan, QgsLayoutViewToolSelect, QgsLayoutViewToolTemporaryKeyZoom, QgsLayoutViewToolTemporaryMousePan, and QgsLayoutViewToolZoom.

Definition at line 84 of file qgslayoutviewtool.cpp.

◆ setAction()

void QgsLayoutViewTool::setAction ( QAction *  action)

Associates an action with this tool.

When the setLayoutTool method of QgsLayoutView is called the action's state will be set to on. Usually this will cause a toolbutton to appear pressed in and the previously used toolbutton to pop out.

See also
action()

Definition at line 104 of file qgslayoutviewtool.cpp.

◆ setCursor()

void QgsLayoutViewTool::setCursor ( const QCursor &  cursor)

Sets a user defined cursor for use when the tool is active.

Definition at line 115 of file qgslayoutviewtool.cpp.

◆ setFlags()

void QgsLayoutViewTool::setFlags ( QgsLayoutViewTool::Flags  flags)
protected

Sets the combination of flags that will be used for the tool.

See also
flags()

Definition at line 64 of file qgslayoutviewtool.cpp.

◆ toolName()

QString QgsLayoutViewTool::toolName ( ) const
inline

Returns a user-visible, translated name for the tool.

Definition at line 155 of file qgslayoutviewtool.h.

◆ view()

QgsLayoutView * QgsLayoutViewTool::view ( ) const

Returns the view associated with the tool.

See also
layout()

Definition at line 38 of file qgslayoutviewtool.cpp.

◆ wheelEvent()

void QgsLayoutViewTool::wheelEvent ( QWheelEvent *  event)
virtual

Mouse wheel event for overriding.

Default implementation does nothing.

Reimplemented in QgsLayoutViewToolMoveItemContent, and QgsLayoutViewToolSelect.

Definition at line 89 of file qgslayoutviewtool.cpp.

Friends And Related Function Documentation

◆ TestQgsLayoutView

friend class TestQgsLayoutView
friend

Definition at line 231 of file qgslayoutviewtool.h.


The documentation for this class was generated from the following files: