QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgslayoutmousehandles.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutmousehandles.h
3  -----------------------
4  begin : September 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : [email protected]
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSLAYOUTMOUSEHANDLES_H
18 #define QGSLAYOUTMOUSEHANDLES_H
19 
20 // We don't want to expose this in the public API
21 #define SIP_NO_FILE
22 
24 #include <QPointer>
25 #include <memory>
26 
27 #include "qgis_gui.h"
28 
29 class QgsLayout;
30 class QGraphicsView;
31 class QgsLayoutView;
32 class QgsLayoutItem;
33 class QInputEvent;
35 
37 
48 class GUI_EXPORT QgsLayoutMouseHandles: public QgsGraphicsViewMouseHandles
49 {
50  Q_OBJECT
51  public:
52 
53  QgsLayoutMouseHandles( QgsLayout *layout, QgsLayoutView *view );
54 
59  void setLayout( QgsLayout *layout ) { mLayout = layout; }
60 
65  QgsLayout *layout() { return mLayout; }
66 
67  void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
68 
69  protected:
70 
71  void setViewportCursor( Qt::CursorShape cursor ) override;
72  QList<QGraphicsItem *> sceneItemsAtPoint( QPointF scenePoint ) override;
73  QList<QGraphicsItem *> selectedSceneItems( bool includeLockedItems = true ) const override;
74  bool itemIsLocked( QGraphicsItem *item ) override;
75  bool itemIsGroupMember( QGraphicsItem *item ) override;
76  QRectF itemRect( QGraphicsItem *item ) const override;
77  void expandItemList( const QList< QGraphicsItem * > &items, QList< QGraphicsItem * > &collected ) const override;
78  void moveItem( QGraphicsItem *item, double deltaX, double deltaY ) override;
79  void setItemRect( QGraphicsItem *item, QRectF rect ) override;
80  void showStatusMessage( const QString &message ) override;
81  void hideAlignItems() override;
82  QPointF snapPoint( QPointF originalPoint, SnapGuideMode mode, bool snapHorizontal = true, bool snapVertical = true ) override;
83  void createItemCommand( QGraphicsItem *item ) override;
84  void endItemCommand( QGraphicsItem *item ) override;
85  void startMacroCommand( const QString &text ) override;
86  void endMacroCommand() override;
87  public slots:
88 
90  void selectionChanged();
91 
92  private:
93 
94  QgsLayout *mLayout = nullptr;
95  QPointer< QgsLayoutView > mView;
96 
98  QGraphicsLineItem *mHorizontalSnapLine = nullptr;
99  QGraphicsLineItem *mVerticalSnapLine = nullptr;
100 
101  std::unique_ptr< QgsAbstractLayoutUndoCommand > mItemCommand;
102 };
103 
105 
106 #endif // QGSLAYOUTMOUSEHANDLES_H
Base class for commands to undo/redo layout and layout object changes.
Base class for graphical items within a QgsLayout.
A graphical widget to display and interact with QgsLayouts.
Definition: qgslayoutview.h:50
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:51