Add title to QQC2 file system tree

master
Jos van den Oever 2017-09-02 21:40:43 +02:00
parent e6a27c3fe3
commit 95c24e35ff
1 changed files with 17 additions and 2 deletions

View File

@ -8,9 +8,12 @@ Item {
ListView { ListView {
id: view id: view
property string title
anchors.fill: parent anchors.fill: parent
header: Column { header: Column {
width: parent.width
ToolBar { ToolBar {
width: parent.width
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
ToolButton { ToolButton {
@ -20,6 +23,13 @@ Item {
dirModel.rootIndex = dirModel.rootIndex.parent dirModel.rootIndex = dirModel.rootIndex.parent
} }
} }
Label {
text: view.title
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
} }
} Row { } Row {
Text { Text {
@ -34,6 +44,9 @@ Item {
model: DelegateModel { model: DelegateModel {
id: dirModel id: dirModel
model: sortedFileSystem model: sortedFileSystem
onRootIndexChanged: {
view.title = model.data(rootIndex)
}
delegate: Item { delegate: Item {
width: parent.width width: parent.width
height: row.height height: row.height
@ -45,8 +58,9 @@ Item {
text: fileName text: fileName
enabled: model.hasModelChildren enabled: model.hasModelChildren
onClicked: { onClicked: {
if (model.hasModelChildren) if (model.hasModelChildren) {
view.model.rootIndex = view.model.modelIndex(index) view.model.rootIndex = view.model.modelIndex(index)
}
} }
Timer { Timer {
id: checkChildren id: checkChildren
@ -61,8 +75,9 @@ Item {
} }
} }
} }
Text { Label {
text: fileSize text: fileSize
padding: button.padding
} }
} }
} }