QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgsmodelviewtool.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelviewtool.h
3 -------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMODELVIEWTOOL_H
17#define QGSMODELVIEWTOOL_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QAction>
23#include <QCursor>
24#include <QPointer>
25
26#define SIP_NO_FILE
27
28class QMouseEvent;
29class QWheelEvent;
30class QKeyEvent;
31class QgsModelGraphicsView;
33class QgsModelComponentGraphicItem;
34class QgsModelGraphicsScene;
35
36
45class GUI_EXPORT QgsModelViewTool : public QObject
46{
47 Q_OBJECT
48
49 public:
51 enum Flag
52 {
53 FlagSnaps = 1 << 1,
54 };
55 Q_DECLARE_FLAGS( Flags, Flag )
56
57 ~QgsModelViewTool() override;
58
64
68 virtual void modelMoveEvent( QgsModelViewMouseEvent *event );
69
73 virtual void modelDoubleClickEvent( QgsModelViewMouseEvent *event );
74
82 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
83
91 virtual void modelReleaseEvent( QgsModelViewMouseEvent *event );
92
96 virtual void wheelEvent( QWheelEvent *event );
97
101 virtual void keyPressEvent( QKeyEvent *event );
102
106 virtual void keyReleaseEvent( QKeyEvent *event );
107
111 virtual bool allowItemInteraction();
112
120 void setAction( QAction *action );
121
126 QAction *action();
127
131 void setCursor( const QCursor &cursor );
132
137 virtual void activate();
138
143 virtual void deactivate();
144
148 QString toolName() const { return mToolName; }
149
154 QgsModelGraphicsView *view() const;
155
160 QgsModelGraphicsScene *scene() const;
161
162 signals:
163
167 void activated();
168
173
178 void itemFocused( QgsModelComponentGraphicItem *item );
179
180 protected:
186
191 QgsModelViewTool( QgsModelGraphicsView *view SIP_TRANSFERTHIS, const QString &name );
192
199 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
200
201 private:
203 QgsModelGraphicsView *mView = nullptr;
204
206
208 QCursor mCursor = Qt::ArrowCursor;
209
211 QPointer<QAction> mAction;
212
214 QString mToolName;
215};
216
217#endif // QGSMODELVIEWTOOL_H
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
QFlags< Flag > Flags
Flag
Flags for controlling how a tool behaves.
@ FlagSnaps
Tool utilizes snapped coordinates.
virtual void keyReleaseEvent(QKeyEvent *event)
Key release event for overriding.
QgsModelGraphicsView * view() const
Returns the view associated with the tool.
virtual void modelDoubleClickEvent(QgsModelViewMouseEvent *event)
Mouse double-click event for overriding.
void itemFocused(QgsModelComponentGraphicItem *item)
Emitted when an item is "focused" by the tool, i.e.
void setAction(QAction *action)
Associates an action with this tool.
QAction * action()
Returns the action associated with the tool or nullptr if no action is associated.
virtual void wheelEvent(QWheelEvent *event)
Mouse wheel event for overriding.
bool isClickAndDrag(QPoint startViewPoint, QPoint endViewPoint) const
Returns true if a mouse press/release operation which started at startViewPoint and ended at endViewP...
QgsModelViewTool::Flags flags() const
Returns the current combination of flags set for the tool.
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
virtual void modelMoveEvent(QgsModelViewMouseEvent *event)
Mouse move event for overriding.
void activated()
Emitted when the tool is activated.
virtual bool allowItemInteraction()
Returns true if the tool allows interaction with component graphic items.
virtual void deactivate()
Called when tool is deactivated.
QgsModelViewTool(QgsModelGraphicsView *view, const QString &name)
Constructor for QgsModelViewTool, taking a model view and tool name as parameters.
virtual void activate()
Called when tool is set as the currently active model tool.
void deactivated()
Emitted when the tool is deactivated.
virtual void modelPressEvent(QgsModelViewMouseEvent *event)
Mouse press event for overriding.
void setFlags(QgsModelViewTool::Flags flags)
Sets the combination of flags that will be used for the tool.
virtual void keyPressEvent(QKeyEvent *event)
Key press event for overriding.
virtual void modelReleaseEvent(QgsModelViewMouseEvent *event)
Mouse release event for overriding.
QString toolName() const
Returns a user-visible, translated name for the tool.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52