QGIS API Documentation 3.43.0-Master (ac9f54ad1f7)
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"
22#include <QGraphicsObject>
23#include <QPicture>
24
25class QgsModelGraphicsView;
27
29
30
37class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
38{
39 Q_OBJECT
40 public:
47 QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, const QPicture &picture, const QPointF &position, const QSizeF &size = QSizeF( 16, 16 ) );
48
49 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
50 QRectF boundingRect() const override;
51 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
52 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
53 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
54
55#ifndef SIP_RUN
56
60 virtual void modelHoverEnterEvent( QgsModelViewMouseEvent *event );
61
65 virtual void modelHoverLeaveEvent( QgsModelViewMouseEvent *event );
66
70 virtual void modelPressEvent( QgsModelViewMouseEvent *event );
71#endif
72
76 QPointF position() const { return mPosition; };
77
78
82 void setPosition( const QPointF &position );
83
87 QgsModelGraphicsView *view();
88
89 signals:
90
94 void clicked();
95
96 protected:
100 void setPicture( const QPicture &picture );
101 bool mHoverState = false;
102
103 private:
104 QPicture mPicture;
105 QPointF mPosition;
106 QSizeF mSize;
107};
108
109
116class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
117{
118 Q_OBJECT
119 public:
128 QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, bool folded, const QPointF &position, const QSizeF &size = QSizeF( 11, 11 ) );
129
130 void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
131#ifndef SIP_RUN
132 void modelPressEvent( QgsModelViewMouseEvent *event ) override;
133#endif
134
135 signals:
136
142 void folded( bool folded );
143
144 private:
145 QPicture mPlusPicture;
146 QPicture mMinusPicture;
147 bool mFolded = false;
148};
149
150
157class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlatButtonGraphicItem
158{
159 Q_OBJECT
160 public:
169 QgsModelDesignerSocketGraphicItem( QgsModelComponentGraphicItem *parent SIP_TRANSFERTHIS, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 ) );
170
171 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
176 int index() const { return mIndex; };
177
183 Qt::Edge edge() const { return mEdge; };
184
190 bool isInput() const { return mEdge == Qt::TopEdge; };
191
193 QgsProcessingModelComponent *component() { return mComponent; };
194
196 QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
197
198 signals:
199
200
201 private:
202 QgsModelComponentGraphicItem *mComponentItem = nullptr;
203 QgsProcessingModelComponent *mComponent = nullptr;
204 int mIndex = -1;
205 Qt::Edge mEdge = Qt::Edge::TopEdge;
206};
207
209
210#endif // QGSMODELGRAPHICITEM_H
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53