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

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


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

diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index 48ff1b7a03..1e5d3797cd 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -107,6 +107,27 @@ Widgets.PageLoader {
                 model: artistModel
             }
 
+            Widgets.DragItem {
+                id: artistsDragItem
+
+                function updateComponents(maxCovers) {
+                  var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
+                    return artistModel.getDataAt(x.row)
+                  })
+                  var title = items.map(function (item){ return item.name}).join(", ")
+                  var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtArtistSmall}})
+                  return {
+                    covers: covers,
+                    title: title,
+                    count: selectionModel.selectedIndexes.length
+                  }
+                }
+
+                function insertIntoPlaylist(index) {
+                    medialib.insertIntoPlaylist(index, artistModel.getIdsForIndexes(selectionModel.selectedIndexes))
+                }
+            }
+
             ArtistContextMenu {
                 id: contextMenu
                 model: artistModel
@@ -152,6 +173,7 @@ Widgets.PageLoader {
                         playIconSize: VLCStyle.play_cover_small
                         textHorizontalAlignment: Text.AlignHCenter
                         width: VLCStyle.colWidth(1)
+                        dragItem: artistsDragItem
 
                         onItemClicked: artistGrid.leftClickOnItem(modifier, index)
 
@@ -181,6 +203,7 @@ Widgets.PageLoader {
                     focus: true
                     headerColor: VLCStyle.colors.bg
                     navigationParent: root
+                    dragItem: artistsDragItem
 
                     onActionForSelection: {
                         if (selection.length > 1) {
-- 
2.25.1



More information about the vlc-devel mailing list