[vlc-devel] [PATCH 15/16] qml: add drag and drop support in MusicTracksDisplay

Prince Gupta guptaprince8832 at gmail.com
Fri Dec 4 12:19:12 CET 2020


---
 .../medialibrary/qml/MusicTracksDisplay.qml   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
index 6a96b364ab..60eea56383 100644
--- a/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
@@ -26,12 +26,35 @@ Widgets.NavigableFocusScope {
     id: root
     property alias sortModel: tracklistdisplay_id.sortModel
     property alias model: tracklistdisplay_id.model
+    property alias selectionModel: tracklistdisplay_id.selectionDelegateModel
+
+    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 insertIntoPlaylist(index) {
+            medialib.insertIntoPlaylist(index, model.getIdsForIndexes(selectionModel.selectedIndexes))
+        }
+    }
 
     MusicTrackListDisplay {
         id: tracklistdisplay_id
         anchors.fill: parent
         visible: model.count > 0
         focus: visible
+        dragItem: trackDragItem
         navigationParent: root
         navigationCancel: function() {
             if (tracklistdisplay_id.currentIndex <= 0)
-- 
2.25.1



More information about the vlc-devel mailing list