-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTreeView.qml
111 lines (96 loc) · 3.66 KB
/
TreeView.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
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
Item {
id: root
width: 600 // change to parent.width
height: 500// change to parent.height
ListView {
id: rootView
anchors.fill: parent
delegate: groupsDelegate
model: listModel
highlight: Rectangle {color: "lightsteelblue"; radius: 6}
// focus: true
Component {
id: groupsDelegate
Item {
id: container
width: 200
height: childrenRect.height
Column {
x: 14
id: mainColumn
Row {
id: mainRow
spacing: 3
property bool expanded: false
Image {
id: expander
source: "expander.png"
rotation: mainRow.expanded ? 90 : 0
opacity: elements.count === 0 ? 0 : 1
Behavior on rotation {
NumberAnimation {duration: 110}
}
MouseArea {
visible: expander.opacity === 1 ? true : false
id: expanderMouseArea
anchors.fill: parent
onClicked: {
mainRow.expanded = !mainRow.expanded
console.log(container.height)
}
}
}
Text {
id: name
text: group
}
}
Item {
width: 200
height: childView.contentHeight
visible: mainRow.expanded
ListView {
id: childView
anchors.fill: parent
// visible: mainRow.expanded
model: elements
delegate: groupsDelegate
highlight: Rectangle {color: "lightsteelblue"; radius: 5}
focus: true
}
}
}
// ListView {
// anchors.right: parent.right
// visible: mainRow.expanded
// model: elements
// delegate: groupsDelegate
// }
}
}
ListModel {
id:listModel
ListElement {group: "first"; elements: []}
ListElement {
group: "second"
elements: [
ListElement {
group: "second2"
elements: [
ListElement {
group: "second2.2"
elements: []
}
]
},
ListElement {group: "second3"; elements: []},
ListElement {group: "second4"; elements: []}
]
}
ListElement {group: "third"; elements: []}
}
}
}