FoldersView.qml 2.47 KB
Newer Older
1 2
import QtQuick 2.0
import QtQuick.Controls 2.2
3
import org.kde.kirigami 2.2 as Kirigami
4
import org.kde.mauikit 1.0 as Maui
5

Camilo higuita's avatar
Camilo higuita committed
6 7 8
import "../../../view_models"
import "../../../db/Query.js" as Q

Camilo higuita's avatar
Camilo higuita committed
9 10 11 12

import FolderModel 1.0
import FoldersList 1.0

Camilo higuita's avatar
Camilo higuita committed
13
StackView
14
{
Camilo higuita's avatar
Camilo higuita committed
15 16 17 18 19 20
    id: _stackView
//    separatorVisible: foldersPageRoot.wideMode
//    initialPage: [foldersPage, picsView]
//    defaultColumnWidth: width

//    interactive: foldersPageRoot.currentIndex  === 1
21 22
    clip: true

23 24 25
    property string currentFolder : ""
    property alias picsView : picsView

Camilo higuita's avatar
Camilo higuita committed
26
    initialItem: Maui.Page
27
    {
28
        id: foldersPage
29
        headBar.visible: false
Camilo higuita's avatar
Camilo higuita committed
30 31
        footBar.drawBorder: false
        footBar.middleContent:  Maui.TextField
Camilo higuita's avatar
Camilo higuita committed
32
        {
Camilo higuita's avatar
Camilo higuita committed
33 34
            placeholderText: qsTr("Filter...")
            width: foldersPage.footBar.middleLayout.width * 0.9
Camilo higuita's avatar
Camilo higuita committed
35 36
            onAccepted: filter(text)
            onCleared: populate()
Camilo higuita's avatar
Camilo higuita committed
37 38
        }

39 40 41
        Maui.Holder
        {
            id: holder
42
            emoji: "qrc:/img/assets/RedPlanet.png"
43 44 45 46
            isMask: false
            title : "No Folders!"
            body: "Add new image sources"
            emojiSize: iconSizes.huge
Camilo higuita's avatar
Camilo higuita committed
47
            visible: false
48
        }
49

Camilo higuita's avatar
Camilo higuita committed
50 51 52 53 54 55 56 57 58 59 60 61
        FolderModel
        {
            id: folderModel
            list: foldersList
        }

        FoldersList
        {
            id: foldersList
            query: "select * from sources"
        }

62
        Maui.GridBrowser
63
        {
64
            id: folderGrid
Camilo higuita's avatar
Camilo higuita committed
65
            anchors.fill: parent
66
            showEmblem: false
Camilo higuita's avatar
Camilo higuita committed
67
            model: folderModel
Camilo higuita's avatar
Camilo higuita committed
68

69

70
            onItemClicked:
71
            {
Camilo higuita's avatar
Camilo higuita committed
72 73 74 75
                var folder = foldersList.get(index)
                picsView.headBarTitle = folder.label
                currentFolder = folder.path
                picsView.list.query = Q.Query.picLikeUrl_.arg(currentFolder)
Camilo higuita's avatar
Camilo higuita committed
76
                _stackView.push(picsView)
77
            }
78
        }
79
    }
80

Camilo higuita's avatar
Camilo higuita committed
81
    PixGrid
82 83 84
    {
        id: picsView

85
        headBar.visible: true
Camilo higuita's avatar
Camilo higuita committed
86
        headBarExit: _stackView.currentItem === picsView
Camilo Higuita's avatar
Camilo Higuita committed
87
        headBarExitIcon: "go-previous"
Camilo higuita's avatar
Camilo higuita committed
88
        onExit: _stackView.pop()
89 90 91 92 93 94

        holder.emoji: "qrc:/img/assets/Electricity.png"
        holder.isMask: false
        holder.title : "Folder is empty!"
        holder.body: "There's not images on this folder"
        holder.emojiSize: iconSizes.huge
95
    }
96

Camilo higuita's avatar
Camilo higuita committed
97 98 99
    function refresh()
    {
        foldersList.refresh()
Camilo higuita's avatar
Camilo higuita committed
100 101 102 103 104
    }

    function filter(hint)
    {
        var query = Q.Query.folders_.arg(hint)
Camilo higuita's avatar
Camilo higuita committed
105
        foldersList.query = query
106 107
    }
}