Warning, /maui/vvave/src/widgets/BabeTable/BabeTable.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 import org.mauikit.filebrowsing 1.3 as FB 0007 0008 import org.maui.vvave 1.0 0009 0010 import "../../utils/Player.js" as Player 0011 0012 import "../../widgets" 0013 0014 Maui.Page 0015 { 0016 id: control 0017 0018 readonly property alias listBrowser : _listBrowser 0019 readonly property alias listView : _listBrowser.flickable 0020 0021 readonly property alias listModel : _listModel 0022 readonly property alias list : _tracksList 0023 0024 property alias delegate : _listBrowser.delegate 0025 0026 readonly property alias count : _listBrowser.count 0027 property alias currentIndex : _listBrowser.currentIndex 0028 readonly property alias currentItem : _listBrowser.currentItem 0029 0030 readonly property alias holder : _listBrowser.holder 0031 readonly property alias section : _listBrowser.section 0032 0033 property bool trackNumberVisible : false 0034 property bool coverArtVisible : false 0035 property bool allowMenu: true 0036 property bool showQuickActions : true 0037 property bool group : false 0038 0039 readonly property alias contextMenu : contextMenu 0040 property alias contextMenuItems : contextMenu.contentData 0041 0042 signal rowClicked(int index) 0043 signal rowDoubleClicked(int index) 0044 signal rowPressed(int index) 0045 signal queueTrack(int index) 0046 signal appendTrack(int index) 0047 0048 signal playAll() 0049 signal appendAll() 0050 signal shuffleAll() 0051 0052 Maui.Theme.colorSet: Maui.Theme.View 0053 Maui.Theme.inherit: false 0054 0055 flickable: _listBrowser.flickable 0056 0057 headBar.visible: control.list.count > 0 0058 headBar.forceCenterMiddleContent: isWide 0059 headBar.rightContent: Loader 0060 { 0061 asynchronous: true 0062 active: headBar.visible 0063 visible: active 0064 0065 sourceComponent: Maui.ToolButtonMenu 0066 { 0067 icon.name: "media-playback-start" 0068 0069 MenuItem 0070 { 0071 icon.name : "media-playlist-shuffle" 0072 text: i18n("Shuffle Play") 0073 onTriggered: shuffleAll() 0074 } 0075 0076 MenuItem 0077 { 0078 icon.name : "media-playback-start" 0079 text: i18n("Play All") 0080 onTriggered: playAll() 0081 } 0082 0083 MenuItem 0084 { 0085 icon.name : "media-playlist-append" 0086 text: i18n("Append All") 0087 onTriggered: appendAll() 0088 } 0089 } 0090 } 0091 0092 headBar.middleContent: Loader 0093 { 0094 id: _filterLoader 0095 asynchronous: true 0096 active: listModel.list.count > 1 0097 visible: active 0098 0099 Layout.fillWidth: true 0100 Layout.minimumWidth: 100 0101 Layout.maximumWidth: 500 0102 Layout.alignment: Qt.AlignCenter 0103 0104 sourceComponent: Maui.SearchField 0105 { 0106 placeholderText: i18np("Filter", "Filter %1 songs", listModel.list.count) 0107 0108 KeyNavigation.up: _listBrowser 0109 KeyNavigation.down: _listBrowser 0110 0111 onAccepted: 0112 { 0113 if(text.includes(",")) 0114 { 0115 listModel.filters = text.split(",") 0116 }else 0117 { 0118 listModel.filter = text 0119 } 0120 } 0121 0122 onCleared: listModel.clearFilters() 0123 } 0124 } 0125 0126 Component 0127 { 0128 id: _metadataDialogComponent 0129 0130 MetadataDialog 0131 { 0132 model: listModel 0133 0134 onEdited: (data, index) => 0135 { 0136 control.list.updateMetadata(data, model.mappedToSource(index)) 0137 } 0138 } 0139 } 0140 0141 Component 0142 { 0143 id: _removeDialogComponent 0144 0145 Maui.FileListingDialog 0146 { 0147 title: i18n("Remove track") 0148 message: i18n("Are you sure you want to delete the file from your computer? This action can not be undone.") 0149 0150 actions: [ 0151 Action 0152 { 0153 text: i18n("Remove") 0154 onTriggered: 0155 { 0156 if(FB.FM.removeFiles(urls)) 0157 { 0158 listModel.list.erase(listModel.mappedToSource(control.currentIndex)) 0159 } 0160 close() 0161 } 0162 }, 0163 0164 Action 0165 { 0166 text: i18n("Cancel") 0167 onTriggered: close() 0168 }] 0169 } 0170 } 0171 0172 TableMenu 0173 { 0174 id: contextMenu 0175 0176 MenuSeparator {} 0177 0178 MenuItem 0179 { 0180 text: i18n("Go to Artist") 0181 icon.name: "view-media-artist" 0182 onTriggered: goToArtist(listModel.get(control.currentIndex).artist) 0183 } 0184 0185 MenuItem 0186 { 0187 text: i18n("Go to Album") 0188 icon.name: "view-media-album-cover" 0189 onTriggered: 0190 { 0191 let item = listModel.get(control.currentIndex) 0192 goToAlbum(item.artist, item.album) 0193 } 0194 } 0195 0196 onFavClicked: 0197 { 0198 listModel.list.fav(listModel.mappedToSource(contextMenu.index), !FB.Tagging.isFav(listModel.get(contextMenu.index).url)) 0199 } 0200 0201 onQueueClicked: Player.queueTracks([listModel.get(contextMenu.index)]) 0202 0203 onSaveToClicked: 0204 { 0205 _dialogLoader.sourceComponent = _playlistDialogComponent 0206 dialog.composerList.urls = filterSelection(listModel.get(contextMenu.index).url) 0207 dialog.open() 0208 } 0209 0210 onOpenWithClicked: FB.FM.openLocation(filterSelection(listModel.get(contextMenu.index).url)) 0211 0212 onDeleteClicked: 0213 { 0214 _dialogLoader.sourceComponent = _removeDialogComponent 0215 dialog.urls = filterSelection(listModel.get(contextMenu.index).url) 0216 dialog.open() 0217 } 0218 0219 onInfoClicked: 0220 { 0221 // infoView.show(listModel.get(control.currentIndex)) 0222 } 0223 0224 onEditClicked: 0225 { 0226 _dialogLoader.sourceComponent = _metadataDialogComponent 0227 dialog.index = contextMenu.index 0228 dialog.open() 0229 } 0230 0231 onCopyToClicked: 0232 { 0233 cloudView.list.upload(contextMenu.index) 0234 } 0235 0236 onShareClicked: 0237 { 0238 const url = listModel.get(contextMenu.index).url 0239 Maui.Platform.shareFiles([url]) 0240 } 0241 } 0242 0243 Maui.ListBrowser 0244 { 0245 id: _listBrowser 0246 anchors.fill: parent 0247 holder.visible: control.listModel.list.count === 0 0248 enableLassoSelection: true 0249 selectionMode: root.selectionMode 0250 currentIndex: -1 0251 0252 onItemsSelected: (indexes) => 0253 { 0254 for(var i in indexes) 0255 { 0256 selectionBar.addToSelection(listModel.get(indexes[i])) 0257 } 0258 } 0259 0260 onKeyPress: (event) => 0261 { 0262 if(event.key === Qt.Key_Return) 0263 { 0264 control.rowClicked(_listBrowser.currentIndex) 0265 } 0266 } 0267 0268 section.property: control.group ? control.listModel.sort : "" 0269 section.criteria: control.listModel.sort === "title" ? ViewSection.FirstCharacter : ViewSection.FullString 0270 section.delegate: Maui.LabelDelegate 0271 { 0272 isSection: true 0273 width: ListView.view.width 0274 // iconSource: "view-media-artist" 0275 label: control.listModel.sort === "adddate" || control.listModel.sort === "releasedate" ? Maui.Handy.formatDate(Date(section), "MM/dd/yyyy") : String(section) 0276 0277 } 0278 0279 model: Maui.BaseModel 0280 { 0281 id: _listModel 0282 list: Tracks 0283 { 0284 id: _tracksList 0285 } 0286 recursiveFilteringEnabled: true 0287 sortCaseSensitivity: Qt.CaseInsensitive 0288 filterCaseSensitivity: Qt.CaseInsensitive 0289 } 0290 0291 delegate: TableDelegate 0292 { 0293 id: delegate 0294 width: ListView.view.width 0295 height: Math.max(implicitHeight, Maui.Style.rowHeight) 0296 number: trackNumberVisible 0297 coverArt: coverArtVisible ? (control.width > 200) : coverArtVisible 0298 appendButton: control.showQuickActions && (Maui.Handy.isTouch ? true : delegate.hovered) 0299 0300 onPressAndHold: 0301 { 0302 if(Maui.Handy.isTouch) 0303 tryOpenContextMenu() 0304 } 0305 0306 onRightClicked: tryOpenContextMenu() 0307 0308 function tryOpenContextMenu() : undefined 0309 { 0310 if (allowMenu) openItemMenu(index) 0311 } 0312 0313 onToggled: (state) => selectionBar.addToSelection(control.listModel.get(index)) 0314 0315 checked: selectionBar.contains(model.url) 0316 checkable: selectionMode 0317 0318 Drag.keys: ["text/uri-list"] 0319 Drag.mimeData: Drag.active ? 0320 { 0321 "text/uri-list": control.filterSelectedItems(model.url) 0322 } : {} 0323 0324 sameAlbum: 0325 { 0326 const item = listModel.get(index-1) 0327 return coverArt && item && item.album === album && item.artist === artist 0328 } 0329 0330 0331 onAppendClicked:{ 0332 currentIndex = index 0333 appendTrack(index) 0334 } 0335 0336 onClicked: 0337 { 0338 _listBrowser.forceActiveFocus() 0339 currentIndex = index 0340 0341 if(selectionMode) 0342 { 0343 selectionBar.addToSelection(model) 0344 return 0345 } 0346 0347 if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ControlModifier)) 0348 _listBrowser.itemsSelected([index]) 0349 0350 if(Maui.Handy.isTouch) 0351 rowClicked(index) 0352 } 0353 0354 onDoubleClicked: 0355 { 0356 currentIndex = index 0357 0358 if(!Maui.Handy.isTouch) 0359 rowClicked(index) 0360 } 0361 0362 Connections 0363 { 0364 target: selectionBar 0365 ignoreUnknownSignals: true 0366 0367 function onUriRemoved(uri) 0368 { 0369 if(uri === model.url) 0370 delegate.checked = false 0371 } 0372 0373 function onUriAdded(uri) 0374 { 0375 if(uri === model.url) 0376 delegate.checked = true 0377 } 0378 0379 function onCleared() 0380 { 0381 delegate.checked = false 0382 } 0383 } 0384 } 0385 0386 Connections 0387 { 0388 target: root 0389 0390 function onContextualPlayNext(event) { 0391 if (_listBrowser.activeFocus) 0392 Player.queueTracks([listModel.get(_listBrowser.currentIndex)]) 0393 } 0394 } 0395 } 0396 0397 function openItemMenu(index) 0398 { 0399 currentIndex = index 0400 contextMenu.index = index 0401 contextMenu.fav = FB.Tagging.isFav(listModel.get(contextMenu.index).url) 0402 contextMenu.titleInfo = listModel.get(contextMenu.index) 0403 contextMenu.show() 0404 rowPressed(index) 0405 } 0406 0407 function filterSelectedItems(path) 0408 { 0409 if(selectionBar && selectionBar.count > 0 && selectionBar.contains(path)) 0410 { 0411 const uris = selectionBar.uris 0412 return uris.join("\n") 0413 } 0414 0415 return path 0416 } 0417 0418 function filterSelection(url) 0419 { 0420 if(selectionBar.contains(url)) 0421 { 0422 return selectionBar.uris 0423 }else 0424 { 0425 return [url] 0426 } 0427 } 0428 0429 function forceActiveFocus() 0430 { 0431 _listBrowser.forceActiveFocus() 0432 } 0433 0434 function getFilterField() : Item 0435 { 0436 return _filterLoader.item 0437 } 0438 }