QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Types | Signals | Public Member Functions | Protected Member Functions | List of all members
QgsModelViewTool Class Reference

Abstract base class for all model designer view tools. More...

#include <qgsmodelviewtool.h>

Inheritance diagram for QgsModelViewTool:
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 (QgsModelComponentGraphicItem *item)
 Emitted when an item is "focused" by the tool, i.e. More...
 

Public Member Functions

 ~QgsModelViewTool () 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 model tool. More...
 
virtual bool allowItemInteraction ()
 Returns true if the tool allows interaction with component graphic items. More...
 
virtual void deactivate ()
 Called when tool is deactivated. More...
 
QgsModelViewTool::Flags flags () const
 Returns the current combination of flags set for the tool. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 Key press event for overriding. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Key release event for overriding. More...
 
virtual void modelDoubleClickEvent (QgsModelViewMouseEvent *event)
 Mouse double-click event for overriding. More...
 
virtual void modelMoveEvent (QgsModelViewMouseEvent *event)
 Mouse move event for overriding. More...
 
virtual void modelPressEvent (QgsModelViewMouseEvent *event)
 Mouse press event for overriding. More...
 
virtual void modelReleaseEvent (QgsModelViewMouseEvent *event)
 Mouse release event for overriding. More...
 
QgsModelGraphicsScene * scene () const
 Returns the scene associated with the tool. 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...
 
QgsModelGraphicsView * view () const
 Returns the view associated with the tool. More...
 
virtual void wheelEvent (QWheelEvent *event)
 Mouse wheel event for overriding. More...
 

Protected Member Functions

 QgsModelViewTool (QgsModelGraphicsView *view, const QString &name)
 Constructor for QgsModelViewTool, taking a model 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 (QgsModelViewTool::Flags flags)
 Sets the combination of flags that will be used for the tool. More...
 

Detailed Description

Abstract base class for all model designer view tools.

Model designer view tools are user interactive tools for manipulating and adding items within the model designer.

Since
QGIS 3.14

Definition at line 43 of file qgsmodelviewtool.h.

Member Enumeration Documentation

◆ Flag

Flags for controlling how a tool behaves.

Enumerator
FlagSnaps 

Tool utilizes snapped coordinates.

Definition at line 51 of file qgsmodelviewtool.h.

Constructor & Destructor Documentation

◆ ~QgsModelViewTool()

QgsModelViewTool::~QgsModelViewTool ( )
override

Definition at line 49 of file qgsmodelviewtool.cpp.

◆ QgsModelViewTool()

QgsModelViewTool::QgsModelViewTool ( QgsModelGraphicsView *  view,
const QString &  name 
)
protected

Constructor for QgsModelViewTool, taking a model view and tool name as parameters.

Definition at line 21 of file qgsmodelviewtool.cpp.

Member Function Documentation

◆ action()

QAction * QgsModelViewTool::action ( )

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

See also
setAction()

Definition at line 110 of file qgsmodelviewtool.cpp.

◆ activate()

void QgsModelViewTool::activate ( )
virtual

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

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

Reimplemented in QgsModelViewToolTemporaryKeyPan, QgsModelViewToolTemporaryKeyZoom, and QgsModelViewToolTemporaryMousePan.

Definition at line 120 of file qgsmodelviewtool.cpp.

◆ activated

void QgsModelViewTool::activated ( )
signal

Emitted when the tool is activated.

◆ allowItemInteraction()

bool QgsModelViewTool::allowItemInteraction ( )
virtual

Returns true if the tool allows interaction with component graphic items.

Reimplemented in QgsModelViewToolSelect.

Definition at line 100 of file qgsmodelviewtool.cpp.

◆ deactivate()

void QgsModelViewTool::deactivate ( )
virtual

Called when tool is deactivated.

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

Reimplemented in QgsModelViewToolPan, QgsModelViewToolSelect, and QgsModelViewToolZoom.

Definition at line 130 of file qgsmodelviewtool.cpp.

◆ deactivated

void QgsModelViewTool::deactivated ( )
signal

Emitted when the tool is deactivated.

◆ flags()

QgsModelViewTool::Flags QgsModelViewTool::flags ( ) const

Returns the current combination of flags set for the tool.

See also
setFlags()

Definition at line 55 of file qgsmodelviewtool.cpp.

◆ isClickAndDrag()

bool QgsModelViewTool::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 32 of file qgsmodelviewtool.cpp.

◆ itemFocused

void QgsModelViewTool::itemFocused ( QgsModelComponentGraphicItem *  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 QgsModelViewTool::keyPressEvent ( QKeyEvent *  event)
virtual

Key press event for overriding.

Default implementation does nothing.

Reimplemented in QgsModelViewToolSelect, QgsModelViewToolTemporaryKeyZoom, and QgsModelViewToolZoom.

Definition at line 90 of file qgsmodelviewtool.cpp.

◆ keyReleaseEvent()

void QgsModelViewTool::keyReleaseEvent ( QKeyEvent *  event)
virtual

Key release event for overriding.

Default implementation does nothing.

Reimplemented in QgsModelViewToolTemporaryKeyPan, QgsModelViewToolTemporaryKeyZoom, and QgsModelViewToolZoom.

Definition at line 95 of file qgsmodelviewtool.cpp.

◆ modelDoubleClickEvent()

void QgsModelViewTool::modelDoubleClickEvent ( QgsModelViewMouseEvent event)
virtual

Mouse double-click event for overriding.

Default implementation does nothing.

Reimplemented in QgsModelViewToolSelect.

Definition at line 70 of file qgsmodelviewtool.cpp.

◆ modelMoveEvent()

void QgsModelViewTool::modelMoveEvent ( QgsModelViewMouseEvent event)
virtual

Mouse move event for overriding.

Default implementation does nothing.

Reimplemented in QgsModelViewToolPan, QgsModelViewToolSelect, QgsModelViewToolTemporaryKeyPan, QgsModelViewToolTemporaryMousePan, and QgsModelViewToolZoom.

Definition at line 65 of file qgsmodelviewtool.cpp.

◆ modelPressEvent()

void QgsModelViewTool::modelPressEvent ( QgsModelViewMouseEvent event)
virtual

Mouse press event for overriding.

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

Reimplemented in QgsModelViewToolPan, QgsModelViewToolSelect, and QgsModelViewToolZoom.

Definition at line 75 of file qgsmodelviewtool.cpp.

◆ modelReleaseEvent()

void QgsModelViewTool::modelReleaseEvent ( QgsModelViewMouseEvent event)
virtual

Mouse release event for overriding.

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

Reimplemented in QgsModelViewToolPan, QgsModelViewToolSelect, QgsModelViewToolTemporaryKeyZoom, QgsModelViewToolTemporaryMousePan, and QgsModelViewToolZoom.

Definition at line 80 of file qgsmodelviewtool.cpp.

◆ scene()

QgsModelGraphicsScene * QgsModelViewTool::scene ( ) const

Returns the scene associated with the tool.

See also
view()

Definition at line 44 of file qgsmodelviewtool.cpp.

◆ setAction()

void QgsModelViewTool::setAction ( QAction *  action)

Associates an action with this tool.

When the setModelTool method of QgsModelGraphicsView 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 105 of file qgsmodelviewtool.cpp.

◆ setCursor()

void QgsModelViewTool::setCursor ( const QCursor &  cursor)

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

Definition at line 115 of file qgsmodelviewtool.cpp.

◆ setFlags()

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

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

See also
flags()

Definition at line 60 of file qgsmodelviewtool.cpp.

◆ toolName()

QString QgsModelViewTool::toolName ( ) const
inline

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

Definition at line 148 of file qgsmodelviewtool.h.

◆ view()

QgsModelGraphicsView * QgsModelViewTool::view ( ) const

Returns the view associated with the tool.

See also
scene()

Definition at line 39 of file qgsmodelviewtool.cpp.

◆ wheelEvent()

void QgsModelViewTool::wheelEvent ( QWheelEvent *  event)
virtual

Mouse wheel event for overriding.

Default implementation does nothing.

Reimplemented in QgsModelViewToolSelect.

Definition at line 85 of file qgsmodelviewtool.cpp.


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