QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
26class QMouseEvent;
27class QWheelEvent;
28class QKeyEvent;
29class QgsModelGraphicsView;
31class QgsModelComponentGraphicItem;
32class QgsModelGraphicsScene;
33
34#define SIP_NO_FILE
35
44class GUI_EXPORT QgsModelViewTool : public QObject
45{
46 Q_OBJECT
47
48 public:
50 enum Flag
51 {
52 FlagSnaps = 1 << 1,
53 };
54 Q_DECLARE_FLAGS( Flags, Flag )
55
56 ~QgsModelViewTool() override;
57
63
67 virtual void modelMoveEvent( QgsModelViewMouseEvent *event );
68
72 virtual void modelDoubleClickEvent( QgsModelViewMouseEvent *event );
73
81 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
82
90 virtual void modelReleaseEvent( QgsModelViewMouseEvent *event );
91
95 virtual void wheelEvent( QWheelEvent *event );
96
100 virtual void keyPressEvent( QKeyEvent *event );
101
105 virtual void keyReleaseEvent( QKeyEvent *event );
106
110 virtual bool allowItemInteraction();
111
119 void setAction( QAction *action );
120
125 QAction *action();
126
130 void setCursor( const QCursor &cursor );
131
136 virtual void activate();
137
142 virtual void deactivate();
143
147 QString toolName() const { return mToolName; }
148
153 QgsModelGraphicsView *view() const;
154
159 QgsModelGraphicsScene *scene() const;
160
161 signals:
162
166 void activated();
167
172
177 void itemFocused( QgsModelComponentGraphicItem *item );
178
179 protected:
185
190 QgsModelViewTool( QgsModelGraphicsView *view SIP_TRANSFERTHIS, const QString &name );
191
198 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
199
200 private:
202 QgsModelGraphicsView *mView = nullptr;
203
205
207 QCursor mCursor = Qt::ArrowCursor;
208
210 QPointer<QAction> mAction;
211
213 QString mToolName;
214};
215
216#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:53