QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#ifdef SIP_RUN
49 if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
50 sipType = sipType_QgsLayoutViewToolAddItem;
51 else
52 sipType = NULL;
54#endif
55
56 Q_OBJECT
57
58 public:
60 enum Flag SIP_ENUM_BASETYPE( IntFlag )
61 {
62 FlagSnaps = 1 << 1,
63 };
64 Q_DECLARE_FLAGS( Flags, Flag )
65
66 ~QgsLayoutViewTool() override;
67
72 QgsLayoutViewTool::Flags flags() const;
73
77 virtual void layoutMoveEvent( QgsLayoutViewMouseEvent *event );
78
82 virtual void layoutDoubleClickEvent( QgsLayoutViewMouseEvent *event );
83
91 virtual void layoutPressEvent( QgsLayoutViewMouseEvent *event );
92
100 virtual void layoutReleaseEvent( QgsLayoutViewMouseEvent *event );
101
105 virtual void wheelEvent( QWheelEvent *event );
106
110 virtual void keyPressEvent( QKeyEvent *event );
111
115 virtual void keyReleaseEvent( QKeyEvent *event );
116
124 void setAction( QAction *action );
125
130 QAction *action();
131
135 void setCursor( const QCursor &cursor );
136
141 virtual void activate();
142
147 virtual void deactivate();
148
152 QString toolName() const { return mToolName; }
153
158 QgsLayoutView *view() const;
159
164 QgsLayout *layout() const;
165
170 virtual QList<QgsLayoutItem *> ignoredSnapItems() const;
171
172 signals:
173
177 void activated();
178
183
189
190 protected:
195 void setFlags( QgsLayoutViewTool::Flags flags );
196
201 QgsLayoutViewTool( QgsLayoutView *view SIP_TRANSFERTHIS, const QString &name );
202
209 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
210
211 private:
213 QgsLayoutView *mView = nullptr;
214
216
218 QCursor mCursor = Qt::ArrowCursor;
219
221 QPointer<QAction> mAction;
222
224 QString mToolName;
225
226 friend class TestQgsLayoutView;
227};
228
229#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