QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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...
 
typedef QFlags< FlagFlags
 

Signals

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

Public Member Functions

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

Protected Member Functions

 QgsLayoutViewTool (QgsLayoutView *view, const QString &name)
 Constructor for QgsLayoutViewTool, taking a layout view and tool name as parameters.
 
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".
 
void setFlags (QgsLayoutViewTool::Flags flags)
 Sets the combination of flags that will be used for the tool.
 

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.

Definition at line 45 of file qgslayoutviewtool.h.

Member Typedef Documentation

◆ Flags

typedef QFlags< Flag > QgsLayoutViewTool::Flags

Definition at line 64 of file qgslayoutviewtool.h.

Member Enumeration Documentation

◆ Flag

Flags for controlling how a tool behaves.

Enumerator
FlagSnaps 

Tool utilizes snapped coordinates.

Definition at line 60 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 21 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 119 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 129 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 114 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 152 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 Symbol Documentation

◆ TestQgsLayoutView

friend class TestQgsLayoutView
friend

Definition at line 226 of file qgslayoutviewtool.h.


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