Filter for directory listing
[owncloud:sebas-mirall.git] / src / plasma / settingsmodule / package / contents / ui / DirectoryPicker.qml
1 /***************************************************************************
2  *                                                                         *
3  *   Copyright 2012 Sebastian K├╝gler <sebas@kde.org>                       *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
19  ***************************************************************************/
20
21 import QtQuick 1.1
22 import org.kde.plasma.components 0.1 as PlasmaComponents
23 import org.kde.plasma.extras 0.1 as PlasmaExtras
24 import org.kde.plasma.owncloud 0.1
25 import org.kde.qtextracomponents 0.1 as QtExtras
26
27 Item {
28     property alias currentPath: lister.currentPath
29     signal directoryPicked(string folder)
30
31     DirectoryLister {
32         id: lister
33         filter: filterText.text
34     }
35     PlasmaExtras.Heading {
36         id: headingItem
37         level: 2
38         text: i18n("Choose a local folder...");
39         anchors { left: parent.left; right: parent.right; top: parent.top; }
40     }
41     PlasmaComponents.TextField {
42         id: filterText
43         anchors { left: parent.left; right: parent.right; top: headingItem.bottom; }
44         onTextChanged: {
45             lister.filter = text
46             forceActiveFocus();
47         }
48     }
49     ListView {
50         id: directoryPicker
51         //height: 300
52
53
54         anchors { left: parent.left; right: parent.right; top: filterText.bottom; bottom: parent.bottom;}
55         model: lister.directories
56
57
58         delegate: PlasmaComponents.ListItem {
59             enabled: true
60             QtExtras.QIconItem {
61                 id: iconItem
62                 anchors { left: parent.left; top: parent.top; bottom: parent.bottom; }
63                 width: parent.height
64             }
65             PlasmaComponents.Label {
66                 anchors { left: iconItem.right; top: parent.top; bottom: parent.bottom; leftMargin: parent.height / 4}
67                 text: {
68                     if (modelData == ".") {
69                         iconItem.icon = "dialog-ok-apply"
70                         return i18n("Pick " + currentPath);
71                     } else if (modelData == "..") {
72                             iconItem.icon = "go-up"
73                         return i18n("Up");
74                     } else {
75                         iconItem.icon = "folder"
76                         return modelData;
77                     }
78                 }
79             }
80             onClicked: {
81                 if (modelData != ".") {
82                     print("Enter ModelData: " + modelData);
83                     //currentPath = lister.currentPath;
84                     lister.enterDirectory(modelData);
85                 } else {
86                     directoryPicked(currentPath);
87                 }
88             }
89         }
90     }
91     onCurrentPathChanged: {
92         localFolderButton.text = currentPath
93         addSyncFolder.localFolder = currentPath;
94     }
95     onDirectoryPicked: {
96         addSyncFolder.state = "remoteFolder";
97     }
98     Rectangle { anchors.fill: parent; color: "blue"; opacity: 0.05 }
99
100     Component.onCompleted: lister.enterDirectory(currentPath)
101 }