Warning, /sdk/rust-qt-binding-generator/demo/qml/FileTreeViewKirigami.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright 2017 Jos van den Oever <jos@vandenoever.info>
0003 *
0004 * This program is free software; you can redistribute it and/or
0005 * modify it under the terms of the GNU General Public License as
0006 * published by the Free Software Foundation; either version 2 of
0007 * the License or (at your option) version 3 or any later version
0008 * accepted by the membership of KDE e.V. (or its successor approved
0009 * by the membership of KDE e.V.), which shall act as a proxy
0010 * defined in Section 14 of version 3 of the license.
0011 *
0012 * This program is distributed in the hope that it will be useful,
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0015 * GNU General Public License for more details.
0016 *
0017 * You should have received a copy of the GNU General Public License
0018 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0019 */
0020
0021 import QtQuick 2.6
0022 import QtQml.Models 2.2
0023 import QtQuick.Controls 2.2
0024 import QtQuick.Layouts 1.3
0025 import org.kde.kirigami 2.0 as Kirigami
0026
0027 ListView {
0028 id: view
0029 property string title
0030 header: Column {
0031 width: parent.width
0032 ToolBar {
0033 width: parent.width
0034 RowLayout {
0035 anchors.fill: parent
0036 ToolButton {
0037 text: qsTr("‹")
0038 enabled: dirModel.rootIndex.valid
0039 onClicked: {
0040 dirModel.rootIndex = dirModel.rootIndex.parent
0041 }
0042 }
0043 Kirigami.Heading {
0044 text: view.title
0045 elide: Label.ElideMiddle
0046 horizontalAlignment: Qt.AlignHCenter
0047 verticalAlignment: Qt.AlignVCenter
0048 Layout.fillWidth: true
0049 }
0050 }
0051 }
0052 Row {
0053 Text {
0054 width: 200
0055 text: qsTr("Name")
0056 }
0057 Text {
0058 text: qsTr("Size")
0059 }
0060 }
0061 }
0062 model: DelegateModel {
0063 id: dirModel
0064 model: sortedFileSystem
0065 onRootIndexChanged: {
0066 var index = sortedFileSystem.mapToSource(rootIndex);
0067 view.title = demo.fileSystemTree.filePath(index) || "";
0068 }
0069 delegate: Item {
0070 width: parent.width
0071 height: row.height
0072 Row {
0073 id: row
0074 Connections {
0075 target: sortedFileSystem
0076 onRowsInserted: {
0077 // enable the button if children were found when 'model'
0078 // was created or if they were just inserted
0079 button.enabled = model.hasModelChildren
0080 || dirModel.modelIndex(index) === parent
0081 }
0082 }
0083 Button {
0084 id: button
0085 width: 200
0086 text: fileName
0087 enabled: model.hasModelChildren
0088 onClicked: {
0089 view.model.rootIndex = view.model.modelIndex(index)
0090 }
0091 }
0092 Label {
0093 text: fileSize
0094 padding: button.padding
0095 }
0096 }
0097 }
0098 }
0099 }