1 /***************************************************************************
2                              qgslayoutviewtoolselect.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 QGSLAYOUTVIEWTOOLSELECT_H
17 #define QGSLAYOUTVIEWTOOLSELECT_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_gui.h"
21 #include "qgslayoutviewtool.h"
22 #include "qgslayoutviewrubberband.h"
23 #include <memory>
24 
25 class QgsLayoutMouseHandles;
26 
27 /**
28  * \ingroup gui
29  * \brief Layout view tool for selecting items in the layout.
30  * \since QGIS 3.0
31  */
32 class GUI_EXPORT QgsLayoutViewToolSelect : public QgsLayoutViewTool
33 {
34 
35     Q_OBJECT
36 
37   public:
38 
39     /**
40      * Constructor for QgsLayoutViewToolSelect.
41      */
42     QgsLayoutViewToolSelect( QgsLayoutView *view SIP_TRANSFERTHIS );
43     ~QgsLayoutViewToolSelect() override;
44 
45     void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override;
46     void layoutMoveEvent( QgsLayoutViewMouseEvent *event ) override;
47     void layoutReleaseEvent( QgsLayoutViewMouseEvent *event ) override;
48     void wheelEvent( QWheelEvent *event ) override;
49     void keyPressEvent( QKeyEvent *event ) override;
50     void deactivate() override;
51 
52     ///@cond PRIVATE
53 
54     /**
55      * Returns the view's mouse handles.
56      * \note Not available in Python bindings.
57      */
58     SIP_SKIP QgsLayoutMouseHandles *mouseHandles();
59     ///@endcond
60 
61     //! Sets the a \a layout.
62     void setLayout( QgsLayout *layout );
63 
64   private:
65 
66     bool mIsSelecting = false;
67 
68     //! Rubber band item
69     std::unique_ptr< QgsLayoutViewRubberBand > mRubberBand;
70 
71     //! Start position for mouse press
72     QPoint mMousePressStartPos;
73 
74     //! Start of rubber band creation
75     QPointF mRubberBandStartPos;
76 
77     QPointer< QgsLayoutMouseHandles > mMouseHandles; //owned by scene
78 };
79 
80 #endif // QGSLAYOUTVIEWTOOLSELECT_H
81