QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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 Q_OBJECT
46
47 public:
49 enum Flag
50 {
51 FlagSnaps = 1 << 1,
52 };
53 Q_DECLARE_FLAGS( Flags, Flag )
54
55 ~QgsModelViewTool() override;
56
61 QgsModelViewTool::Flags flags() const;
62
66 virtual void modelMoveEvent( QgsModelViewMouseEvent *event );
67
71 virtual void modelDoubleClickEvent( QgsModelViewMouseEvent *event );
72
80 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
81
89 virtual void modelReleaseEvent( QgsModelViewMouseEvent *event );
90
94 virtual void wheelEvent( QWheelEvent *event );
95
99 virtual void keyPressEvent( QKeyEvent *event );
100
104 virtual void keyReleaseEvent( QKeyEvent *event );
105
109 virtual bool allowItemInteraction();
110
118 void setAction( QAction *action );
119
124 QAction *action();
125
129 void setCursor( const QCursor &cursor );
130
135 virtual void activate();
136
141 virtual void deactivate();
142
146 QString toolName() const { return mToolName; }
147
152 QgsModelGraphicsView *view() const;
153
158 QgsModelGraphicsScene *scene() const;
159
160 signals:
161
165 void activated();
166
171
176 void itemFocused( QgsModelComponentGraphicItem *item );
177
178 protected:
183 void setFlags( QgsModelViewTool::Flags flags );
184
189 QgsModelViewTool( QgsModelGraphicsView *view SIP_TRANSFERTHIS, const QString &name );
190
197 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
198
199 private:
201 QgsModelGraphicsView *mView = nullptr;
202
204
206 QCursor mCursor = Qt::ArrowCursor;
207
209 QPointer<QAction> mAction;
210
212 QString mToolName;
213};
214
215#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.
QFlags< Flag > Flags
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