QGIS API Documentation 3.43.0-Master (c67cf405802)
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
46class GUI_EXPORT QgsLayoutViewTool : public QObject
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:
61 enum Flag SIP_ENUM_BASETYPE( IntFlag )
62 {
63 FlagSnaps = 1 << 1,
64 };
65 Q_DECLARE_FLAGS( Flags, Flag )
66
67 ~QgsLayoutViewTool() override;
68
73 QgsLayoutViewTool::Flags flags() const;
74
78 virtual void layoutMoveEvent( QgsLayoutViewMouseEvent *event );
79
83 virtual void layoutDoubleClickEvent( QgsLayoutViewMouseEvent *event );
84
92 virtual void layoutPressEvent( QgsLayoutViewMouseEvent *event );
93
101 virtual void layoutReleaseEvent( QgsLayoutViewMouseEvent *event );
102
106 virtual void wheelEvent( QWheelEvent *event );
107
111 virtual void keyPressEvent( QKeyEvent *event );
112
116 virtual void keyReleaseEvent( QKeyEvent *event );
117
125 void setAction( QAction *action );
126
131 QAction *action();
132
136 void setCursor( const QCursor &cursor );
137
142 virtual void activate();
143
148 virtual void deactivate();
149
153 QString toolName() const { return mToolName; }
154
159 QgsLayoutView *view() const;
160
165 QgsLayout *layout() const;
166
171 virtual QList<QgsLayoutItem *> ignoredSnapItems() const;
172
173 signals:
174
178 void activated();
179
184
190
191 protected:
196 void setFlags( QgsLayoutViewTool::Flags flags );
197
202 QgsLayoutViewTool( QgsLayoutView *view SIP_TRANSFERTHIS, const QString &name );
203
210 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
211
212 private:
214 QgsLayoutView *mView = nullptr;
215
217
219 QCursor mCursor = Qt::ArrowCursor;
220
222 QPointer<QAction> mAction;
223
225 QString mToolName;
226
227 friend class TestQgsLayoutView;
228};
229
230#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.
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