-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlistviewarrows.cpp
More file actions
84 lines (56 loc) · 2.03 KB
/
listviewarrows.cpp
File metadata and controls
84 lines (56 loc) · 2.03 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
76
77
78
79
80
81
82
83
#include "listviewarrows.h"
#include <QDebug>
#include <QPainter>
ListViewArrows::ListViewArrows(QWidget* parent) : QListView(parent)
{
}
void ListViewArrows::paintEvent(QPaintEvent* event)
{
//call parent paint event
QListView::paintEvent(event);
qDebug() << "paintEvent called";
QPainter painter(this->viewport());
painter.setPen(QColor::fromRgb(255, 0, 0));
//painter.fillRect(0, 0, 10, 10, Qt::BrushStyle::);
int rowH = 20;
int firstRowH = 17;
int width = this->viewport()->size().width();
//try some "connections"
//first item -> first item
int startY = firstRowH;
int lineN = 1;
startY+= lineN * rowH/2;
painter.drawLine(0, startY, width, startY );
//first item-> second item
int endY = startY + rowH;
painter.drawLine(0, startY, width, endY );
//use path and cubicTo
QPainterPath *path = new QPainterPath();
// float xL = ui->links->viewport()->rect().left();
// float xR = ui->links->viewport()->rect().right();
//note: just drawing random stuff for testing lines..
// only "signal"->"signal" connections make sense
// so in actual device--->signal shouldn't exist
//TODO: scrolling is a bit of a pain. need to subclass
// the two end views, and then provide drawing offsets for
// the lines. mapping view shouldn't scroll
startY = firstRowH + 2.5 * rowH;
endY = firstRowH + 4.5* rowH;
path->moveTo(0, startY);
path->cubicTo(0+width/4, startY, width*0.75, endY, width, endY);
painter.drawPath(*path);
startY = firstRowH + 7.5 * rowH;
endY = firstRowH + 1.5* rowH;
path->moveTo(0, startY);
path->cubicTo(0+width/4, startY, width*0.75, endY, width, endY);
painter.drawPath(*path);
startY = firstRowH + 1.5 * rowH;
endY = firstRowH + 10.5* rowH;
path->moveTo(0, startY);
path->cubicTo(0+width/4, startY, width*0.75, endY, width, endY);
painter.drawPath(*path);
//painter.drawRect(0,0,this->viewport()->width(), 20);
}
void ListViewArrows::wheelEvent(QWheelEvent * e)
{
}