Warning, /maui/vvave/src/widgets/FoldersView/FoldersView.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.14
0002 import QtQuick.Controls 2.14
0003 import QtQuick.Layouts 1.3
0004 
0005 import org.mauikit.controls 1.3 as Maui
0006 
0007 import "../BabeTable"
0008 import "../../db/Queries.js" as Q
0009 import "../../utils/Player.js" as Player
0010 
0011 import org.maui.vvave 1.0
0012 
0013 StackView
0014 {
0015     id: control
0016 
0017     property string currentFolder : ""
0018     readonly property Flickable flickable: currentItem.flickable
0019 
0020     initialItem: Maui.Page
0021     {
0022         Maui.Theme.colorSet: Maui.Theme.View
0023         Maui.Theme.inherit: false
0024 
0025         headBar.middleContent: Maui.SearchField
0026         {
0027             id: _filterField
0028             Layout.fillWidth: true
0029             Layout.maximumWidth: 500
0030             Layout.alignment: Qt.AlignCenter
0031 
0032             placeholderText: i18np("Filter %1 folder", "Filter %1 folders", _foldersList.count)
0033 
0034             KeyNavigation.up: browser
0035             KeyNavigation.down: browser
0036 
0037             onAccepted: browser.model.filter = text
0038             onCleared:  browser.model.filter = text
0039         }
0040 
0041         Maui.Holder
0042         {
0043             anchors.fill: parent
0044             visible: _foldersList.count === 0
0045             emoji: "qrc:/assets/dialog-information.svg"
0046             title : i18n("No Folders!")
0047             body: i18n("Add new music to your sources to browse by folders")
0048             Action
0049             {
0050                 text: i18n("Add sources")
0051                 onTriggered: openSettingsDialog()
0052             }
0053         }
0054 
0055         Maui.ListBrowser
0056         {
0057             id: browser
0058 
0059             anchors.fill: parent
0060 
0061             model: Maui.BaseModel
0062             {
0063                 sort: "label"
0064                 sortOrder: Qt.AscendingOrder
0065                 recursiveFilteringEnabled: true
0066                 sortCaseSensitivity: Qt.CaseInsensitive
0067                 filterCaseSensitivity: Qt.CaseInsensitive
0068 
0069                 list: Folders
0070                 {
0071                     id: _foldersList
0072                     folders: Vvave.folders
0073                 }
0074             }
0075 
0076             section.property: browser.model.sort
0077             section.criteria: ViewSection.FirstCharacter
0078             section.delegate: Maui.LabelDelegate
0079             {
0080                 isSection: true
0081                 width: ListView.view.width
0082                 label: String(section)
0083             }
0084 
0085             delegate: Maui.ListBrowserDelegate
0086             {
0087                 width: ListView.view.width
0088                 template.headerSizeHint: Maui.Style.rowHeight
0089                 isCurrentItem: ListView.isCurrentItem
0090                 iconSizeHint: Maui.Style.iconSizes.medium
0091                 label1.text: model.label
0092                 label2.text: model.path.replace("file://", "")
0093                 label2.wrapMode: Text.Wrap
0094                 iconSource: model.icon
0095                 template.isMask: true
0096 
0097                 onClicked:
0098                 {
0099                     browser.currentIndex = index
0100                     if(Maui.Handy.singleClick)
0101                     {
0102                         filter(model.path)
0103                     }
0104                 }
0105 
0106                 onDoubleClicked:
0107                 {
0108                     browser.currentIndex = index
0109                     if(!Maui.Handy.singleClick)
0110                     {
0111                         filter(model.path)
0112                     }
0113                 }
0114             }
0115         }
0116         function getFilterField() : Item
0117         {
0118             return _filterField
0119         }
0120     }
0121 
0122     Component
0123     {
0124         id: _filterListComponent
0125 
0126         BabeTable
0127         {
0128             list.query : Q.GET.tracksWhere_.arg("source = \""+control.currentFolder+"\"")
0129 
0130             coverArtVisible: true
0131 
0132             holder.emoji: "qrc:/assets/dialog-information.svg"
0133             holder.isMask: true
0134             holder.title : i18n("No Tracks!")
0135             holder.body: i18n("This source folder seems to be empty!")
0136 
0137             headBar.visible: true
0138             headBar.farLeftContent: ToolButton
0139             {
0140                 icon.name: "go-previous"
0141                 onClicked: control.pop()
0142             }
0143 
0144             onRowClicked: (index) => Player.quickPlay(listModel.get(index))
0145             onAppendTrack: (index) => Player.addTrack(listModel.get(index))
0146             onQueueTrack: (index) => Player.queueTracks([listModel.get(index)], index)
0147 
0148             onPlayAll: Player.playAllModel(listModel.list)
0149             onAppendAll: Player.appendAllModel(listModel.list)
0150             onShuffleAll: Player.shuffleAllModel(listModel.list)
0151         }
0152     }
0153 
0154     function filter(folder)
0155     {
0156         currentFolder = folder
0157         control.push(_filterListComponent)
0158     }
0159 
0160     function getFilterField() : Item
0161     {
0162         return control.currentItem.getFilterField()
0163     }
0164 
0165     function getGoBackFunc() : Function
0166     {
0167         if (control.depth > 1)
0168             return () => { control.pop() }
0169         else
0170             return null
0171     }
0172 }