1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-07 03:56:28 +02:00

qml: implement drag support in MusicTrackListDisplay

replaces drag support from MusicTracksDisplay. This way it can be reused
in places where MusicTrackListDisplay is used like in expand delegates
This commit is contained in:
Prince Gupta 2021-07-22 21:13:34 +05:30 committed by Hugo Beauzée-Luyssen
parent b23f655d23
commit fe12285fa6
2 changed files with 22 additions and 22 deletions

View File

@ -71,6 +71,26 @@ Widgets.KeyNavigableTableView {
onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0)) onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0))
onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos) onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
dragItem: Widgets.DragItem {
function updateComponents(maxCovers) {
var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
return model.getDataAt(x.row)
})
var title = items.map(function (item){ return item.title}).join(", ")
var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtCover}})
return {
covers: covers,
title: title,
count: selectionModel.selectedIndexes.length
}
}
function getSelectedInputItem() {
return model.getItemsForIndexes(selectionModel.selectedIndexes);
}
}
Widgets.TableColumns { Widgets.TableColumns {
id: tableColumns id: tableColumns

View File

@ -26,38 +26,18 @@ import "qrc:///main/" as MainInterface
FocusScope { FocusScope {
id: root id: root
property alias sortModel: tracklistdisplay_id.sortModel property alias sortModel: tracklistdisplay_id.sortModel
property alias model: tracklistdisplay_id.model property alias model: tracklistdisplay_id.model
property alias selectionModel: tracklistdisplay_id.selectionDelegateModel property alias selectionModel: tracklistdisplay_id.selectionDelegateModel
readonly property bool isViewMultiView: false readonly property bool isViewMultiView: false
Widgets.DragItem {
id: trackDragItem
function updateComponents(maxCovers) {
var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
return model.getDataAt(x.row)
})
var title = items.map(function (item){ return item.title}).join(", ")
var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtCover}})
return {
covers: covers,
title: title,
count: selectionModel.selectedIndexes.length
}
}
function getSelectedInputItem() {
return model.getItemsForIndexes(selectionModel.selectedIndexes);
}
}
MusicTrackListDisplay { MusicTrackListDisplay {
id: tracklistdisplay_id id: tracklistdisplay_id
anchors.fill: parent anchors.fill: parent
visible: model.count > 0 visible: model.count > 0
focus: model.count > 0 focus: model.count > 0
dragItem: trackDragItem
headerTopPadding: VLCStyle.margin_normal headerTopPadding: VLCStyle.margin_normal
Navigation.parentItem: root Navigation.parentItem: root
Navigation.cancelAction: function() { Navigation.cancelAction: function() {