QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsmodelgraphicitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelgraphicitem.h
3 ----------------------------------
4 Date : February 2020
5 Copyright : (C) 2020 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 QGSMODELGRAPHICITEM_H
17#define QGSMODELGRAPHICITEM_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include <QGraphicsObject>
22#include <QPicture>
23
24class QgsModelGraphicsView;
26
28
29
36class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
37{
38 Q_OBJECT
39 public:
40
47 QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, const QPicture &picture, const QPointF &position,
48 const QSizeF &size = QSizeF( 16, 16 ) );
49
50 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
51 QRectF boundingRect() const override;
52 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
53 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
54 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
55
56#ifndef SIP_RUN
57
61 virtual void modelHoverEnterEvent( QgsModelViewMouseEvent *event );
62
66 virtual void modelHoverLeaveEvent( QgsModelViewMouseEvent *event );
67
71 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
72#endif
73
77 void setPosition( const QPointF &position );
78
82 QgsModelGraphicsView *view();
83
84 signals:
85
89 void clicked();
90
91 protected:
92
96 void setPicture( const QPicture &picture );
97
98 private:
99 QPicture mPicture;
100 QPointF mPosition;
101 QSizeF mSize;
102 bool mHoverState = false;
103};
104
105
112class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
113{
114
115 Q_OBJECT
116 public:
117
126 QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, bool folded, const QPointF &position,
127 const QSizeF &size = QSizeF( 11, 11 ) );
128
129 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
130#ifndef SIP_RUN
131 void modelPressEvent( QgsModelViewMouseEvent *event ) override;
132#endif
133
134 signals:
135
141 void folded( bool folded );
142
143 private:
144
145 QPicture mPlusPicture;
146 QPicture mMinusPicture;
147 bool mFolded = false;
148};
149
151
152#endif // QGSMODELGRAPHICITEM_H
A QgsModelViewMouseEvent is the result of a user interaction with the mouse on a QgsModelGraphicsView...
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53