/
SignalListView.qml
113 lines (83 loc) · 2.4 KB
/
SignalListView.qml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import QtQuick 2.0
import QtQuick.Controls 2
Rectangle {
id: signalListMain
signal closed
property alias model: listView.model
Rectangle {
id: header
width: parent.width
height: 50
color: "yellow"
Button {
id: btnclose
anchors.centerIn: parent
text: "close"
onClicked: {
closed();
}
}
}
Rectangle {
id: body
anchors {
top: header.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
color: "gray"
ListView {
id: listView
anchors.fill: parent
clip: true
delegate: Rectangle {
width: listView.width
height: 40
border.color: "gray"
color: listView.currentIndex === model.index ? "yellow" : "white"
TextInput {
anchors.fill: parent
anchors.margins: 5
text: model.name
verticalAlignment: Text.AlignVCenter
onTextChanged: {
listView.model.get(index).name = text;
}
onFocusChanged: {
if (focus) {
listView.currentIndex = model.index;
}
}
}
}
footer: Rectangle {
width: listView.width
height: 40
Button {
anchors {
top: parent.top
bottom: parent.bottom
}
width: parent.width / 2
text: "+"
onClicked: {
listView.model.append({name:"signal"});
}
}
Button {
anchors {
top: parent.top
bottom: parent.bottom
}
x: parent.width / 2
width: parent.width / 2
text: "-"
onClicked: {
listView.model.remove(listView.currentIndex);
}
}
}
}
}
}