<commit_before>import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.file.browser.SearchEngine 1.0
import "functions.js" as Functions

Page {
    id: page
    allowedOrientations: Orientation.All
    showNavigationIndicator: false // hide back indicator because it would be on top of search field
    property string dir: "/"
    property string currentDirectory: ""

    // this and its bg worker thread will be destroyed when page in popped from stack
    SearchEngine {
        id: searchEngine
        dir: page.dir

        onProgressChanged: page.currentDirectory = directory
        onMatchFound: listModel.append({ fullname: fullname, filename: filename,
                                           absoluteDir: absoluteDir,
                                           fileIcon: fileIcon, fileKind: fileKind });
        onWorkerDone: { clearCover(); }
        onWorkerErrorOccurred: { clearCover(); notificationPanel.showWithText(message, filename); }
    }

    SilicaListView {
        id: fileList
        anchors.fill: parent

        // prevent newly added list delegates from stealing focus away from the search field
        currentIndex: -1

        model: ListModel {
            id: listModel

            function update(txt) {
                if (txt === "")
                    searchEngine.cancel();

                clear();
                if (txt !== "") {
                    searchEngine.search(txt);
                    coverPlaceholder.text = "Searching\n"+txt;
                }
            }

            Component.onCompleted: update("")
        }

        VerticalScrollDecorator { flickable: fileList }

        PullDownMenu {
            MenuItem {
                text: "About"
                onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
            }
            MenuItem {
                text: "Go to SD Card"
                onClicked: {
                    var sdcard = Functions.sdcardPath();
                    if (engine.exists(sdcard)) {
                        Functions.goToFolder(sdcard);
                    } else {
                        notificationPanel.showWithText("SD Card not found", sdcard);
                    }
                }
            }
            MenuItem {
                text: "Go to Home"
                onClicked: Functions.goToHome(StandardPaths.documents)
            }
        }

        header: Item {
            width: parent.width
            height: 120

            SearchField {
                id: searchField
                anchors.left: parent.left
                anchors.right: cancelSearchButton.left
                placeholderText: "Search "+Functions.formatPathForSearch(page.dir)
                inputMethodHints: Qt.ImhNoAutoUppercase

                // get focus when page is shown for the first time
                Component.onCompleted: forceActiveFocus()

                // return key on virtual keyboard starts or restarts search
                Keys.onPressed: {
                    notificationPanel.hide();
                    if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
                        listModel.update(searchField.text);
                        foundText.visible = true;
                        searchField.focus = false;
                    }
                }
            }<commit_msg>Adjust search page header height<commit_after>import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.file.browser.SearchEngine 1.0
import "functions.js" as Functions

Page {
    id: page
    allowedOrientations: Orientation.All
    showNavigationIndicator: false // hide back indicator because it would be on top of search field
    property string dir: "/"
    property string currentDirectory: ""

    // this and its bg worker thread will be destroyed when page in popped from stack
    SearchEngine {
        id: searchEngine
        dir: page.dir

        onProgressChanged: page.currentDirectory = directory
        onMatchFound: listModel.append({ fullname: fullname, filename: filename,
                                           absoluteDir: absoluteDir,
                                           fileIcon: fileIcon, fileKind: fileKind });
        onWorkerDone: { clearCover(); }
        onWorkerErrorOccurred: { clearCover(); notificationPanel.showWithText(message, filename); }
    }

    SilicaListView {
        id: fileList
        anchors.fill: parent

        // prevent newly added list delegates from stealing focus away from the search field
        currentIndex: -1

        model: ListModel {
            id: listModel

            function update(txt) {
                if (txt === "")
                    searchEngine.cancel();

                clear();
                if (txt !== "") {
                    searchEngine.search(txt);
                    coverPlaceholder.text = "Searching\n"+txt;
                }
            }

            Component.onCompleted: update("")
        }

        VerticalScrollDecorator { flickable: fileList }

        PullDownMenu {
            MenuItem {
                text: "About"
                onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
            }
            MenuItem {
                text: "Go to SD Card"
                onClicked: {
                    var sdcard = Functions.sdcardPath();
                    if (engine.exists(sdcard)) {
                        Functions.goToFolder(sdcard);
                    } else {
                        notificationPanel.showWithText("SD Card not found", sdcard);
                    }
                }
            }
            MenuItem {
                text: "Go to Home"
                onClicked: Functions.goToHome(StandardPaths.documents)
            }
        }

        header: Item {
            width: parent.width
            height: 110

            SearchField {
                id: searchField
                anchors.left: parent.left
                anchors.right: cancelSearchButton.left
                placeholderText: "Search "+Functions.formatPathForSearch(page.dir)
                inputMethodHints: Qt.ImhNoAutoUppercase

                // get focus when page is shown for the first time
                Component.onCompleted: forceActiveFocus()

                // return key on virtual keyboard starts or restarts search
                Keys.onPressed: {
                    notificationPanel.hide();
                    if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
                        listModel.update(searchField.text);
                        foundText.visible = true;
                        searchField.focus = false;
                    }
                }
            }
{'fraction_non_alphanumeric': 0.07624720774385704, 'fraction_numerical': 0.0029784065524944155, 'mean_word_length': 1.3840965566205183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4485157', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1497, 'n_words': 408}