QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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_sip.h"
20#include "qgis_gui.h"
21#include <QCursor>
22#include <QAction>
23#include <QPointer>
24
25class QMouseEvent;
26class QWheelEvent;
27class QKeyEvent;
28class QgsLayoutView;
30class QgsLayout;
31class QgsLayoutItem;
32
33#ifdef SIP_RUN
34% ModuleHeaderCode
36% End
37#endif
38
45class GUI_EXPORT QgsLayoutViewTool : public QObject
46{
47
48#ifdef SIP_RUN
50 if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
51 sipType = sipType_QgsLayoutViewToolAddItem;
52 else
53 sipType = NULL;
55#endif
56
57 Q_OBJECT
58
59 public:
60
62 enum Flag SIP_ENUM_BASETYPE( IntFlag )
63 {
64 FlagSnaps = 1 << 1,
65 };
66 Q_DECLARE_FLAGS( Flags, Flag )
67
68 ~QgsLayoutViewTool() override;
69
74 QgsLayoutViewTool::Flags flags() const;
75
79 virtual void layoutMoveEvent( QgsLayoutViewMouseEvent *event );
80
84 virtual void layoutDoubleClickEvent( QgsLayoutViewMouseEvent *event );
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:
193
198 void setFlags( QgsLayoutViewTool::Flags flags );
199
204 QgsLayoutViewTool( QgsLayoutView *view SIP_TRANSFERTHIS, const QString &name );
205
212 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
213
214 private:
215
217 QgsLayoutView *mView = nullptr;
218
220
222 QCursor mCursor = Qt::ArrowCursor;
223
225 QPointer< QAction > mAction;
226
228 QString mToolName;
229
230 friend class TestQgsLayoutView;
231
232};
233
234#endif // QGSLAYOUTVIEWTOOL_H
Base class for graphical items within a QgsLayout.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.
Layout view tool for adding items to a layout.
Abstract base class for all layout view tools.
Flag
Flags for controlling how a tool behaves.
QString toolName() const
Returns a user-visible, translated name for the tool.
void activated()
Emitted when the tool is activated.
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:49
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_END
Definition qgis_sip.h:208