SearchView.qml 1.63 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


Maui.Page
10
{
11 12
    property string currentQuery : ""

Camilo higuita's avatar
Camilo higuita committed
13 14
    margins: 0
    headBar.visible: false
Camilo Higuita's avatar
Camilo Higuita committed
15

16
    PixGrid
17 18
    {
        id: searchResults
Camilo Higuita's avatar
Camilo Higuita committed
19

Camilo higuita's avatar
Camilo higuita committed
20 21 22 23
        anchors.fill: parent
        headBar.visible: true
        headBarExitIcon: "edit-clear"
        headBarTitle: searchResults.grid.count + qsTr(" results")
Camilo Higuita's avatar
Camilo Higuita committed
24 25 26 27 28
        holder.emoji: "qrc:/img/assets/BugSearch.png"
        holder.isMask: false
        holder.title : "No Results!"
        holder.body: "Try with another query"
        holder.emojiSize: iconSizes.huge
29 30
    }

Camilo higuita's avatar
Camilo higuita committed
31
    footBar.drawBorder: false
32
    footBar.middleContent: Maui.TextField
Camilo Higuita's avatar
Camilo Higuita committed
33 34 35
    {
        id: searchInput
        placeholderText: qsTr("Search...")
Camilo higuita's avatar
Camilo higuita committed
36 37
        width: footBar.middleLayout.width * 0.9

Camilo Higuita's avatar
Camilo Higuita committed
38 39
        onAccepted: runSearch(searchInput.text)
    }
40

41 42 43 44 45
    function refreshPics()
    {
        searchResults.list.refresh()
    }

46 47 48 49
    function runSearch(query)
    {
        if(query)
        {
50
            currentQuery = query
Camilo higuita's avatar
Camilo higuita committed
51
            searchResults.list.query = Q.Query.searchFor_.arg(currentQuery)
52

53 54 55 56 57 58 59 60
//            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)
//            }
61 62 63
        }
    }

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