-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentry.h
More file actions
75 lines (60 loc) · 1.91 KB
/
entry.h
File metadata and controls
75 lines (60 loc) · 1.91 KB
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
#ifndef ENTRY_H
#define ENTRY_H
#include <QtGui>
#include <maxmodel/model.h>
class Entry
{
public:
enum Type { Unknown, Input, Output };
Entry(const model_linkable_t *linkable, const Type &type, const QString &name, char sig) :
linkable(linkable), type(type), name(name), sig(sig)
{
}
const model_linkable_t *getLinkable() const { return linkable; }
Type getType() const { return type; }
QString getName() const { return name; }
char getSig() const { return sig; }
class Handle : public QGraphicsItem
{
public:
Handle(Entry *entry) :
QGraphicsItem(), entry(entry)
{
}
Entry *getEntry() const { return entry; }
QRectF boundingRect() const { return QRectF(-10, -10, 20, 20); }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPainterPath bg;
bg.addRect(boundingRect());
painter->save();
{
painter->setRenderHints(QPainter::Antialiasing);
painter->fillPath(bg, QBrush(QColor(0x8370FA)));
painter->setPen(QPen(Qt::black));
painter->setFont(QFont("sans-serif", 10, QFont::Normal));
painter->drawText(boundingRect(), Qt::AlignCenter, QString(entry->getSig()));
}
painter->restore();
}
private:
Entry *entry;
};
Handle *makeHandle() { return new Handle(this); }
bool operator ==(const Entry &other) const
{
return getLinkable() == other.getLinkable() && getName() == other.getName() && getType() == other.getType();
}
bool operator !=(const Entry &other) const
{
return !(*this == other);
}
private:
const model_linkable_t *linkable;
Type type;
QString name;
char sig;
};
#endif // ENTRY_H