Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

SearchView.qml 1.79 KB
Newer Older
1 2 3 4 5
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../../view_models"
import "../../../db/Query.js" as Q
6
import org.kde.mauikit 1.0 as Maui
Camilo Higuita's avatar
Camilo Higuita committed
7 8


9

Camilo Higuita's avatar
Camilo Higuita committed
10

11
    PixGrid
12 13
    {
        id: searchResults
camilo higuita's avatar
fixes  
camilo higuita committed
14
        property string currentQuery : ""
Camilo Higuita's avatar
Camilo Higuita committed
15

Camilo higuita's avatar
Camilo higuita committed
16 17 18
        headBar.visible: true
        headBarExitIcon: "edit-clear"
        headBarTitle: searchResults.grid.count + qsTr(" results")
Camilo Higuita's avatar
Camilo Higuita committed
19 20 21 22 23
        holder.emoji: "qrc:/img/assets/BugSearch.png"
        holder.isMask: false
        holder.title : "No Results!"
        holder.body: "Try with another query"
        holder.emojiSize: iconSizes.huge
24

Camilo higuita's avatar
Camilo higuita committed
25

camilo higuita's avatar
fixes  
camilo higuita committed
26 27 28 29 30 31 32 33 34 35 36
    footBar.visible: true
        footBar.drawBorder: false
        footBar.middleContent: Maui.TextField
        {
            id: searchInput
            placeholderText: qsTr("Search...")
            width: footBar.middleLayout.width * 0.9
            Layout.margins: space.medium
            Layout.fillWidth: true
            onAccepted: runSearch(searchInput.text)
        }
37

camilo higuita's avatar
fixes  
camilo higuita committed
38 39 40 41
        function refreshPics()
        {
            searchResults.list.refresh()
        }
42

camilo higuita's avatar
fixes  
camilo higuita committed
43
        function runSearch(query)
44
        {
camilo higuita's avatar
fixes  
camilo higuita committed
45 46 47 48
            if(query)
            {
                currentQuery = query
                searchResults.list.query = Q.Query.searchFor_.arg(currentQuery)
49

camilo higuita's avatar
fixes  
camilo higuita committed
50 51 52 53 54 55 56 57 58
    //            var queries = query.split(",")
    //            for(var i in queries)
    //            {
    //                var res =[]
    //                res.push(pix.get(Q.Query.searchFor_.arg(queries[i])))
    //                res.push(tag.getUrls(query, true))
    //                populate(res)
    //            }
            }
59
        }
camilo higuita's avatar
fixes  
camilo higuita committed
60 61 62 63 64 65 66

    //    function populate(data)
    //    {
    //        if(data.length > 0)
    //            for(var i in data)
    //                searchResults.model.append(data[i])
    //    }
67 68
    }