Warning, /graphics/peruse/src/app/qml/FileFinder.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2016 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library 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 GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 import QtQuick 2.2
0023 import QtQuick.Controls 2.12 as QtControls
0024 import Qt.labs.folderlistmodel 2.1
0025 
0026 import org.kde.kirigami 2.7 as Kirigami
0027 
0028 import "listcomponents" as ListComponents
0029 
0030 Item {
0031     id: root;
0032     signal accepted();
0033     signal aborted();
0034     function selectedItem() {
0035         var theItem = folderModel.folder;
0036         if(folderView.currentIndex > -1)
0037         {
0038             theItem = theItem + "/" + folderModel.get(folderView.currentIndex, "fileName");
0039         }
0040         return theItem;
0041     }
0042     property alias folder: folderModel.folder;
0043     property alias showDirs: folderModel.showDirs;
0044     property alias showFiles: folderModel.showFiles;
0045     property alias nameFilters: folderModel.nameFilters;
0046 
0047     FolderListModel {
0048         id: folderModel
0049     }
0050 
0051     ListComponents.ListPageHeader {
0052         id: titleContainer;
0053         text: folderModel.folder;
0054         anchors {
0055             top: parent.top;
0056             left: parent.left;
0057             right: parent.right;
0058         }
0059         clip: true;
0060         height: Kirigami.Units.gridUnit * 2;
0061     }
0062     QtControls.ToolButton {
0063         anchors {
0064             top: parent.top;
0065             right: parent.right;
0066             margins: Kirigami.Units.smallSpacing;
0067         }
0068         icon.name: "dialog-ok-apply";
0069         display: AbstractButton.TextBesideIcon;
0070         onClicked: root.accepted();
0071     }
0072 
0073     ListView {
0074         id: folderView;
0075         anchors {
0076             top: titleContainer.bottom;
0077             topMargin: Kirigami.Units.largeSpacing;
0078             left: parent.left;
0079             right: parent.right;
0080             bottom: parent.bottom;
0081         }
0082         clip: true;
0083         model: folderModel;
0084         Component.onCompleted: folderView.currentIndex = -1;
0085         header: Kirigami.BasicListItem {
0086             enabled: true;
0087             supportsMouseEvents: enabled;
0088             clip: true;
0089             width: folderView.width;
0090             onClicked: folderModel.folder = folderModel.parentFolder;
0091             label: i18nc("A fake folder item which if activated will cause the folder list to navigate up through the folder structure by one step", "(go up one level)");
0092             icon: "go-up";
0093         }
0094         delegate: Kirigami.BasicListItem {
0095             enabled: true;
0096             supportsMouseEvents: enabled;
0097             width: folderView.width;
0098             label: fileName;
0099             icon: fileIsDir ? "folder" : "";
0100             onClicked: {
0101                 if(fileIsDir) {
0102                     folderView.currentIndex = -1;
0103                     folderModel.folder = fileURL;
0104                 }
0105                 else {
0106                     folderView.currentIndex = index;
0107                 }
0108             }
0109             checked: folderView.currentIndex === index;
0110         }
0111     }
0112 }