Add a back button to qt quick controls 2 file tree

master
Jos van den Oever 2017-09-02 19:32:34 +02:00
parent c14049f001
commit c50816fd43
1 changed files with 41 additions and 17 deletions

View File

@ -9,6 +9,28 @@ Item {
ListView {
id: view
anchors.fill: parent
header: Column {
ToolBar {
RowLayout {
anchors.fill: parent
ToolButton {
text: qsTr("")
enabled: dirModel.rootIndex.valid
onClicked: {
dirModel.rootIndex = dirModel.rootIndex.parent
}
}
}
} Row {
Text {
width: 200
text: qsTr("Name")
}
Text {
text: qsTr("Size")
}
}
}
model: DelegateModel {
id: dirModel
model: sortedFileSystem
@ -17,30 +39,32 @@ Item {
height: row.height
Row {
id: row
Text {
Button {
id: button
width: 200
text: fileName
enabled: model.hasModelChildren
onClicked: {
if (model.hasModelChildren)
view.model.rootIndex = view.model.modelIndex(index)
}
Timer {
id: checkChildren
interval: 100
running: true
repeat: true
onTriggered: {
if (model.hasModelChildren) {
button.enabled = true
checkChildren.stop()
}
}
}
}
Text {
text: fileSize
}
}
MouseArea {
anchors.fill: parent
onClicked: {
if (model.hasModelChildren)
view.model.rootIndex = view.model.modelIndex(index)
}
}
}
}
header: Row {
Text {
width: 200
text: qsTr("Name")
}
Text {
text: qsTr("Size")
}
}
}