FoldersView.qml 2.04 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
        onItemClicked:
        {
            var item = browser.model.get(index)
camilo higuita's avatar
camilo higuita committed
25
            _filterList.title= item.label
26
27
28
29
30
31
            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
            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
camilo higuita's avatar
camilo higuita committed
49
            page.padding: 0
50
            BabeTable
Camilo higuita's avatar
Camilo higuita committed
51
            {
52
53
54
55
56
57
58
59
                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
60
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
77
78
    function filter()
    {
        var where = "source = \""+currentFolder+"\""
        _filterList.list.query = (Q.GET.tracksWhere_.arg(where))
Camilo higuita's avatar
Camilo higuita committed
79
80
81

    }
}