-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainOwnDelegate.qml
executable file
·58 lines (49 loc) · 1.72 KB
/
mainOwnDelegate.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
import QtQuick
Window {
width: 600
height: 400
visible: true
TreeView {
anchors.fill: parent
id: _view
// The model needs to be a QAbstractItemModel
model: _model
delegate: Item {
id: treeDelegate
implicitWidth: padding + label.x + label.implicitWidth + padding
implicitHeight: label.implicitHeight * 1.5
readonly property real indent: 20
readonly property real padding: 5
// Assigned to by TreeView:
required property TreeView treeView
required property bool isTreeNode
required property bool expanded
required property int hasChildren
required property int depth
TapHandler {
onTapped: {
treeView.toggleExpanded(row)
var qi = _view.index(row, 0)
console.log(qi)
_view.model.showQModelIndex(qi)
}
}
Text {
id: indicator
visible: treeDelegate.isTreeNode && treeDelegate.hasChildren
x: padding + (treeDelegate.depth * treeDelegate.indent)
anchors.verticalCenter: label.verticalCenter
text: "▸"
rotation: treeDelegate.expanded ? 90 : 0
}
Text {
id: label
x: padding + (treeDelegate.isTreeNode ? (treeDelegate.depth + 1)
* treeDelegate.indent : 0)
width: treeDelegate.width - treeDelegate.padding - x
clip: true
text: model.display
}
}
}
}