QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutviewtool.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutviewtool.h
3 -------------------
4 Date : July 2017
5 Copyright : (C) 2017 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 QGSLAYOUTVIEWTOOL_H
17#define QGSLAYOUTVIEWTOOL_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 QgsLayoutView;
31class QgsLayout;
32class QgsLayoutItem;
33
34#ifdef SIP_RUN
35//%ModuleHeaderCode
37//%End
38#endif
39
47class GUI_EXPORT QgsLayoutViewTool : public QObject
48{
49#ifdef SIP_RUN
51 if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
52 sipType = sipType_QgsLayoutViewToolAddItem;
53 else
54 sipType = NULL;
56#endif
57
58 Q_OBJECT
59
60 public:
62 enum Flag SIP_ENUM_BASETYPE( IntFlag )
63 {
64 FlagSnaps = 1 << 1,
65 };
66 Q_DECLARE_FLAGS( Flags, Flag )
67
68 ~QgsLayoutViewTool() override;
69
75
79 virtual void layoutMoveEvent( QgsLayoutViewMouseEvent *event );
80
85
93 virtual void layoutPressEvent( QgsLayoutViewMouseEvent *event );
94
102 virtual void layoutReleaseEvent( QgsLayoutViewMouseEvent *event );
103
107 virtual void wheelEvent( QWheelEvent *event );
108
112 virtual void keyPressEvent( QKeyEvent *event );
113
117 virtual void keyReleaseEvent( QKeyEvent *event );
118
126 void setAction( QAction *action );
127
132 QAction *action();
133
137 void setCursor( const QCursor &cursor );
138
143 virtual void activate();
144
149 virtual void deactivate();
150
154 QString toolName() const { return mToolName; }
155
160 QgsLayoutView *view() const;
161
166 QgsLayout *layout() const;
167
172 virtual QList<QgsLayoutItem *> ignoredSnapItems() const;
173
174 signals:
175
179 void activated();
180
185
191
192 protected:
198
203 QgsLayoutViewTool( QgsLayoutView *view SIP_TRANSFERTHIS, const QString &name );
204
211 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
212
213 private:
215 QgsLayoutView *mView = nullptr;
216
218
220 QCursor mCursor = Qt::ArrowCursor;
221
223 QPointer<QAction> mAction;
224
226 QString mToolName;
227
228 friend class TestQgsLayoutView;
229};
230
231#endif // QGSLAYOUTVIEWTOOL_H
Base class for graphical items within a QgsLayout.
A mouse event which is the result of a user interaction with a QgsLayoutView.
Layout view tool for adding items to a layout.
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
QgsLayoutView * view() const
Returns the view associated with the tool.
virtual void deactivate()
Called when tool is deactivated.
virtual void layoutDoubleClickEvent(QgsLayoutViewMouseEvent *event)
Mouse double-click event for overriding.
QgsLayoutViewTool::Flags flags() const
Returns the current combination of flags set for the tool.
virtual void wheelEvent(QWheelEvent *event)
Mouse wheel event for overriding.
QAction * action()
Returns the action associated with the tool or nullptr if no action is associated.
virtual void keyReleaseEvent(QKeyEvent *event)
Key release 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...
void setFlags(QgsLayoutViewTool::Flags flags)
Sets the combination of flags that will be used for the tool.
void setAction(QAction *action)
Associates an action with this tool.
Flag
Flags for controlling how a tool behaves.
@ FlagSnaps
Tool utilizes snapped coordinates.
friend class TestQgsLayoutView
virtual void activate()
Called when tool is set as the currently active layout tool.
QString toolName() const
Returns a user-visible, translated name for the tool.
virtual void layoutMoveEvent(QgsLayoutViewMouseEvent *event)
Mouse move event for overriding.
void activated()
Emitted when the tool is activated.
virtual void layoutPressEvent(QgsLayoutViewMouseEvent *event)
Mouse press event for overriding.
QgsLayoutViewTool(QgsLayoutView *view, const QString &name)
Constructor for QgsLayoutViewTool, taking a layout view and tool name as parameters.
virtual void layoutReleaseEvent(QgsLayoutViewMouseEvent *event)
Mouse release event for overriding.
virtual void keyPressEvent(QKeyEvent *event)
Key press event for overriding.
QFlags< Flag > Flags
void itemFocused(QgsLayoutItem *item)
Emitted when an item is "focused" by the tool, i.e.
void deactivated()
Emitted when the tool is deactivated.
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275
#define SIP_END
Definition qgis_sip.h:216