[vlc-commits] qml: add drag and drop support in MusicAlbums

Prince Gupta git at videolan.org
Thu Dec 10 09:34:57 UTC 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Fri Nov 13 15:10:19 2020 +0530| [f9871c9c098c8d8748cc172f37eb67e30cf4c966] | committer: Pierre Lamot

qml: add drag and drop support in MusicAlbums

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f9871c9c098c8d8748cc172f37eb67e30cf4c966
---

 modules/gui/qt/medialibrary/qml/MusicAlbums.qml | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 4a39f8ed2a..256be1a6fb 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -97,6 +97,27 @@ Widgets.NavigableFocusScope {
         model: albumModelId
     }
 
+    Widgets.DragItem {
+        id: albumDragItem
+
+        function updateComponents(maxCovers) {
+          var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
+            return albumModelId.getDataAt(x.row)
+          })
+          var title = items.map(function (item){ return item.title}).join(", ")
+          var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtAlbum}})
+          return {
+            covers: covers,
+            title: title,
+            count: selectionModel.selectedIndexes.length
+          }
+        }
+
+        function insertIntoPlaylist(index) {
+            medialib.insertIntoPlaylist(index, albumModelId.getIdsForIndexes(selectionModel.selectedIndexes))
+        }
+    }
+
     AlbumContextMenu {
         id: contextMenu
         model: albumModelId
@@ -122,6 +143,7 @@ Widgets.NavigableFocusScope {
                 id: audioGridItem
 
                 opacity: gridView_id.expandIndex !== -1 && gridView_id.expandIndex !== audioGridItem.index ? .7 : 1
+                dragItem: albumDragItem
 
                 onItemClicked : gridView_id.leftClickOnItem(modifier, index)
 
@@ -187,6 +209,7 @@ Widgets.NavigableFocusScope {
             navigationParent: root
             section.property: "title_first_symbol"
             header: root.header
+            dragItem: albumDragItem
 
             sortModel:  [
                 { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(2), text: i18n.qtr("Title"), headerDelegate: tableColumns.titleHeaderDelegate, colDelegate: tableColumns.titleDelegate },



More information about the vlc-commits mailing list