-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
96 lines (79 loc) · 2.91 KB
/
main.qml
File metadata and controls
96 lines (79 loc) · 2.91 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
84
85
86
87
88
89
90
91
92
93
94
95
96
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ApplicationWindow {
id: root
height: minimumHeight
minimumHeight: 360
minimumWidth: 640
title: "Python - PySide6 - Qt"
visible: true
width: minimumWidth
TreeView {
id: treeView
anchors.fill: parent
anchors.margins: 10
clip: true
// The model needs to be a QAbstractItemModel.
model: file_system_model
delegate: Item {
required property int column
required property bool current
required property int depth
required property bool expanded
required property int hasChildren
readonly property real indentation: 20
// Rotate indicator when expanded by the user
// (requires TreeView to have a selectionModel).
property Animation indicatorAnimation: NumberAnimation {
duration: 100
easing.type: Easing.OutQuart
from: expanded ? 0 : 90
property: "rotation"
target: indicator
to: expanded ? 90 : 0
}
required property bool isTreeNode
readonly property real padding: 5
required property int row
// Assigned to by TreeView:
required property TreeView treeView
implicitHeight: label.implicitHeight * 1.5
implicitWidth: padding + label.x + label.implicitWidth + padding
TableView.onPooled: indicatorAnimation.complete()
TableView.onReused: if (current)
indicatorAnimation.start()
onExpandedChanged: indicator.rotation = expanded ? 90 : 0
Rectangle {
id: background
anchors.fill: parent
color: row === treeView.currentRow ? palette.highlight : "black"
opacity: (treeView.alternatingRows && row % 2 !== 0) ? 0.3 : 0.1
}
Label {
id: indicator
anchors.verticalCenter: parent.verticalCenter
text: "▶"
visible: isTreeNode && hasChildren
x: padding + (depth * indentation)
TapHandler {
onSingleTapped: {
let index = treeView.index(row, column);
treeView.selectionModel.setCurrentIndex(index, ItemSelectionModel.NoUpdate);
treeView.toggleExpanded(row);
}
}
}
Label {
id: label
anchors.verticalCenter: parent.verticalCenter
clip: true
text: model.display
width: parent.width - padding - x
x: padding + (isTreeNode ? (depth + 1) * indentation : 0)
}
}
selectionModel: ItemSelectionModel {
}
}
}