-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodeitem.h
85 lines (65 loc) · 2.08 KB
/
nodeitem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef NODEITEM_H
#define NODEITEM_H
#include <QGraphicsItem>
#include <QFont>
#include <QBrush>
#include <QUuid>
#include "portitem.h"
class NodeItem : public QGraphicsObject
{
Q_OBJECT
public:
explicit NodeItem(QWidget *widget, QGraphicsItem *parent = Q_NULLPTR);
private:
QWidget *m_widget;
QUuid m_uuid;
QSizeF m_size;
QSizeF m_indentSize;
QSizeF m_titleSize;
QFont m_font;
QColor m_fontColor;
QColor m_titleColor;
QColor m_backgroundColor;
QBrush m_backgroundBrush;
bool m_isUserBrush;
bool m_isSelected;
QList<PortItem*> m_portList;
QString m_title;
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
signals:
void selected(bool state);
void positionChanged();
public slots:
bool isHovered(const QPointF &point);
PortItem *isHoveredPort(const QPointF &point);
void updateSize();
QWidget *widget(){return m_widget;}
void addPortIn(PortItem *port);
PortItem *createPortIn(int posY, QColor color);
PortItem *createPortIn(int posY, QColor color, uint num);
void addPortOut(PortItem *port);
PortItem *createPortOut(int posY, QColor color);
PortItem *createPortOut(int posY, QColor color, uint num);
QList<PortItem*> portList(){return m_portList;}
PortItem* portAt(uint num);
void removePortAt(uint num);
void removePort(PortItem *port);
QUuid uuid(){return m_uuid;}
void setUuid(const QUuid &uuid){m_uuid = uuid;}
QString title(){return m_title;}
void setTitle(const QString &title);
void clearTitle();
qreal width(){return m_size.width();}
qreal height(){return m_size.height();}
QSizeF size(){return m_size;}
void setFont(const QFont &font);
void setFontColor(const QColor &color);
void setTitleColor(const QColor &color);
void setBackgroundColor(const QColor &color);
void setBackgroundBrush(const QBrush &brush);
};
#endif // NODEITEM_H