2 import Sailfish.Silica 1.0
3 import harbour.file.browser.SearchEngine 1.0
4 import "functions.js" as Functions
9 //allowedOrientations: Orientation.All
10 showNavigationIndicator: false // hide back indicator because it would be on top of search field
11 property string dir: "/"
12 property string currentDirectory: ""
15 if (status === PageStatus.Active) {
16 listModel.update("." + engine.extensionFilter);
17 //foundText.visible = true;
21 // this and its bg worker thread will be destroyed when page in popped from stack
26 onProgressChanged: page.currentDirectory = directory
27 onMatchFound: listModel.append({ fullname: fullname, filename: filename,
28 absoluteDir: absoluteDir,
29 fileIcon: fileIcon, fileKind: fileKind });
30 onWorkerDone: { /* Nothing to do */ }
31 onWorkerErrorOccurred: { notificationPanel.showText(message, filename); }
38 // prevent newly added list delegates from stealing focus away from the search field
44 function update(txt) {
46 searchEngine.cancel();
50 searchEngine.search(txt);
54 Component.onCompleted: update("")
57 VerticalScrollDecorator { flickable: fileList }
61 // text: qsTr("Settings")
62 // onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
72 anchors.left: parent.left
73 anchors.right: cancelSearchButton.left
74 placeholderText: qsTr("Search %1").arg(Functions.formatPathForSearch(page.dir))
75 inputMethodHints: Qt.ImhNoAutoUppercase
77 // get focus when page is shown for the first time
78 Component.onCompleted: forceActiveFocus()
80 // return key on virtual keyboard starts or restarts search
81 EnterKey.enabled: true
83 notificationPanel.hide();
84 listModel.update(searchField.text);
85 foundText.visible = true;
86 searchField.focus = false;
89 // our own "IconButton" to make the mouse area large and easier to tap
91 id: cancelSearchButton
92 anchors.right: parent.right
93 anchors.top: searchField.top
94 width: Theme.iconSizeMedium+Theme.paddingLarge
95 height: searchField.height
96 color: cancelSearchMouseArea.pressed ? Theme.secondaryHighlightColor : "transparent"
98 id: cancelSearchMouseArea
101 if (!searchEngine.running) {
102 listModel.update(searchField.text);
103 foundText.visible = true;
105 searchEngine.cancel()
110 id: cancelSearchButtonImage
111 anchors.verticalCenter: parent.verticalCenter
112 anchors.right: parent.right
113 anchors.rightMargin: Theme.paddingLarge
114 source: searchEngine.running ? "image://theme/icon-m-clear" :
115 "image://theme/icon-m-right"
119 anchors.centerIn: cancelSearchButtonImage
120 running: searchEngine.running
121 size: BusyIndicatorSize.Small
128 anchors.left: parent.left
129 anchors.leftMargin: searchField.textLeftMargin
130 anchors.top: searchField.bottom
131 anchors.topMargin: -26
132 text: qsTr("%1 hits").arg(listModel.count)
133 font.pixelSize: Theme.fontSizeTiny
134 color: Theme.secondaryColor
137 anchors.left: parent.left
138 anchors.leftMargin: 240
139 anchors.right: parent.right
140 anchors.rightMargin: Theme.paddingLarge
141 anchors.top: searchField.bottom
142 anchors.topMargin: -26
143 text: page.currentDirectory
144 font.pixelSize: Theme.fontSizeTiny
145 color: Theme.secondaryColor
146 elide: Text.ElideRight
153 width: ListView.view.width
154 contentHeight: listLabel.height+listAbsoluteDir.height + 13
158 anchors.left: parent.left
159 anchors.leftMargin: Theme.paddingLarge
160 anchors.top: parent.top
161 anchors.topMargin: 11
162 source: "../images/small-"+fileIcon+".png"
166 anchors.left: listIcon.right
167 anchors.leftMargin: 10
168 anchors.right: parent.right
169 anchors.rightMargin: Theme.paddingLarge
170 anchors.top: parent.top
173 elide: Text.ElideRight
177 anchors.left: listIcon.right
178 anchors.leftMargin: 10
179 anchors.right: parent.right
180 anchors.rightMargin: Theme.paddingLarge
181 anchors.top: listLabel.bottom
183 color: Theme.secondaryColor
184 font.pixelSize: Theme.fontSizeExtraSmall
185 elide: Text.ElideLeft
189 if (model.fileKind === "d")
190 pageStack.push(Qt.resolvedUrl("DirectoryPage.qml"),
191 { dir: model.fullname });
193 Functions.fileSelect(model.fullname)
194 // pageStack.push(Qt.resolvedUrl("FilePage.qml"),
195 // { file: model.fullname });
198 // delete file after remorse time
199 ListView.onRemove: animateRemoval(fileItem)
200 function deleteFile(deleteFilename) {
201 remorseAction(qsTr("Deleting"), function() {
202 progressPanel.showText(qsTr("Deleting"));
203 engine.deleteFiles([ deleteFilename ]);
207 // context menu is activated with long press, visible if search is not running
212 text: qsTr("Go to containing folder")
213 onClicked: Functions.goToFolder(model.absoluteDir)
216 text: qsTr("Properties")
218 pageStack.push(Qt.resolvedUrl("FilePage.qml"), { file: model.fullname });
223 // onClicked: engine.cutFiles([ model.fullname ]);
226 // text: qsTr("Copy")
227 // onClicked: engine.copyFiles([ model.fullname ]);
230 // text: qsTr("Delete")
231 // onClicked: deleteFile(model.fullname);
239 // connect signals from engine to panels
242 onProgressChanged: progressPanel.text = engine.progressFilename
243 onWorkerDone: progressPanel.hide()
244 onWorkerErrorOccurred: {
245 // the error signal goes to all pages in pagestack, show it only in the active one
246 if (progressPanel.open) {
247 progressPanel.hide();
248 notificationPanel.showText(message, filename);
252 // item got deleted by worker, so remove it from list
254 for (var i = 0; i < listModel.count; ++i) {
255 var item = listModel.get(i);
256 if (item.fullname === fullname) {
265 id: notificationPanel
272 onCancelled: engine.cancel()