QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
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_sip.h"
20#include "qgis_gui.h"
21#include <QCursor>
22#include <QAction>
23#include <QPointer>
24
25class QMouseEvent;
26class QWheelEvent;
27class QKeyEvent;
28class QgsModelGraphicsView;
30class QgsModelComponentGraphicItem;
31class QgsModelGraphicsScene;
32
33#define SIP_NO_FILE
34
43class GUI_EXPORT QgsModelViewTool : public QObject
44{
45
46 Q_OBJECT
47
48 public:
49
51 enum Flag
52 {
53 FlagSnaps = 1 << 1,
54 };
55 Q_DECLARE_FLAGS( Flags, Flag )
56
57 ~QgsModelViewTool() override;
58
63 QgsModelViewTool::Flags flags() const;
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:
181
186 void setFlags( QgsModelViewTool::Flags flags );
187
192 QgsModelViewTool( QgsModelGraphicsView *view SIP_TRANSFERTHIS, const QString &name );
193
200 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
201
202 private:
203
205 QgsModelGraphicsView *mView = nullptr;
206
207 QgsModelViewTool::Flags mFlags = QgsModelViewTool::Flags();
208
210 QCursor mCursor = Qt::ArrowCursor;
211
213 QPointer< QAction > mAction;
214
216 QString mToolName;
217
218
219};
220
221#endif // QGSMODELVIEWTOOL_H
A QgsModelViewMouseEvent is the result of a user interaction with the mouse on a QgsModelGraphicsView...
Abstract base class for all model designer view tools.
Flag
Flags for controlling how a tool behaves.
void itemFocused(QgsModelComponentGraphicItem *item)
Emitted when an item is "focused" by the tool, i.e.
void activated()
Emitted when the tool is activated.
void deactivated()
Emitted when the tool is deactivated.
QString toolName() const
Returns a user-visible, translated name for the tool.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53