FoldersView.qml 2.02 KB
Newer Older
Camilo higuita's avatar
Camilo higuita committed
1 2
import QtQuick 2.0
import QtQuick.Controls 2.2
Camilo Higuita's avatar
Camilo Higuita committed
3
import org.kde.mauikit 1.0 as Maui
Camilo higuita's avatar
Camilo higuita committed
4 5 6
import "../view_models/BabeTable"
import "../db/Queries.js" as Q

7
Item
Camilo higuita's avatar
Camilo higuita committed
8
{
9 10 11 12 13
    id: control
    property alias list : _filterList
    property var tracks : []
    property string currentFolder : ""

14
    Maui.GridBrowser
Camilo higuita's avatar
Camilo higuita committed
15
    {
16
        id: browser
17
        //        headBarTitle: qsTr("Source folders")
18 19 20
        anchors.margins: space.big
        anchors.fill: parent
        showEmblem: false
Camilo higuita's avatar
Camilo higuita committed
21

22 23 24 25 26 27 28 29 30 31
        onItemClicked:
        {
            var item = browser.model.get(index)
            _filterList.headBarTitle= item.label
            currentFolder = item.path
            filter()
            _listDialog.open()
        }

        Maui.Holder
Camilo higuita's avatar
Camilo higuita committed
32 33
        {
            anchors.fill: parent
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
            visible: !browser.count
            emoji: "qrc:/assets/MusicCloud.png"
            isMask: false
            title : "No Folders!"
            body: "Add new music to your sources to browse by folders"
            emojiSize: iconSizes.huge
        }

        Maui.Dialog
        {
            id: _listDialog
            parent: parent
            maxHeight: maxWidth
            maxWidth: unit * 600
            defaultButtons: false
            BabeTable
Camilo higuita's avatar
Camilo higuita committed
50
            {
51 52 53 54 55 56 57 58
                id: _filterList
                anchors.fill: parent
                coverArtVisible: true
                holder.emoji: "qrc:/assets/MusicCloud.png"
                holder.isMask: false
                holder.title : "No Tracks!"
                holder.body: "This source folder seems to be empty!"
                holder.emojiSize: iconSizes.huge
Camilo higuita's avatar
Camilo higuita committed
59 60
            }
        }
61
    }
Camilo higuita's avatar
Camilo higuita committed
62

63
    Component.onCompleted: populate()
Camilo higuita's avatar
Camilo higuita committed
64

65 66 67 68 69 70 71 72
    function populate()
    {
        browser.model.clear()
        var folders = vvave.sourceFolders();
        if(folders.length > 0)
            for(var i in folders)
                browser.model.append(folders[i])
    }
73

74 75 76 77
    function filter()
    {
        var where = "source = \""+currentFolder+"\""
        _filterList.list.query = (Q.GET.tracksWhere_.arg(where))
Camilo higuita's avatar
Camilo higuita committed
78 79 80

    }
}