-
Notifications
You must be signed in to change notification settings - Fork 1
/
customrect.h
83 lines (59 loc) · 2.02 KB
/
customrect.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
#ifndef CUSTOMRECT_H
#define CUSTOMRECT_H
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
#include <QWidget>
#include <QPainter>
#include <QObject>
//#include "qmapperdbscene.h"
#define MAPPER_SCENE_ITEM_H 35
#define MAPPER_SCENE_ITEM_W 120
#define MAPPER_SCENE_SPACER 15
class CustomRect : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
CustomRect(float x, float y, QString dev, QString sig);// QMapperDbScene* scene = 0);
void setTitles(QString dev, QString sig);
QRectF boundingRect() const;
QRectF boundingRectAbs() const;
void setHovered(bool hover) { hoverovered = hover; update();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setFillColor(QColor col) {colorFill = col;}
void setOutlineColDef(QColor col) {colorOutlineDef = col;}
void setOutlineColSel(QColor col) {colorOutlineSel = col;}
void setOutlineColDrop(QColor col) {colorOutlineDrop = col;}
void setTextColor(QColor col) { colorText = col;}
void setAlpha(int alpha);
Q_SIGNALS:
void mouseDragSig(QPointF pos);
void mouseDragSig(QPointF src_pos, QPointF drag_pos);
void mouseDropSig(QPointF pos);
void mouseDropSig(QPointF src_pos, QPointF drop_pos);
void rectMovedSig();
void mouseReleaseEvent(QPointF pos);
void mouseDoubleClickSig();
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e);
void mousePressEvent(QGraphicsSceneMouseEvent *e);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
bool lifted;
bool pressed;
bool hoverovered;
QString devname;
QString signame;
float originX;
float originY;
QColor colorFill;
QColor colorOutlineDef;
QColor colorOutlineSel;
QColor colorOutlineDrop;
QColor colorText;
//QMapperDbScene *parentScene;
};
#endif // CUSTOMRECT_H