FoldersView.qml 1.94 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
camilo higuita's avatar
camilo higuita committed
17
        anchors.margins: Maui.Style.space.big
18 19
        anchors.fill: parent
        showEmblem: false
camilo higuita's avatar
camilo higuita committed
20
        model: ListModel {}
21 22 23
        onItemClicked:
        {
            var item = browser.model.get(index)
camilo higuita's avatar
camilo higuita committed
24
            _filterList.title= item.label
25 26 27 28
            currentFolder = item.path
            filter()
            _listDialog.open()
        }
camilo higuita's avatar
camilo higuita committed
29
    }
30 31


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

    Maui.Dialog
    {
        id: _listDialog
        parent: parent
        maxHeight: maxWidth
        maxWidth: Maui.Style.unit * 600
        defaultButtons: false
        page.padding: 0
        BabeTable
52
        {
camilo higuita's avatar
camilo higuita committed
53 54 55 56 57 58 59 60
            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: Maui.Style.iconSizes.huge
Camilo higuita's avatar
Camilo higuita committed
61
        }
62
    }
Camilo higuita's avatar
Camilo higuita committed
63

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

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

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

    }
}