vlc | branch: master | Prince Gupta <guptaprince8...@gmail.com> | Fri Nov 13 
15:51:12 2020 +0530| [19cb9b2abd72f61aef1373ec24a361c64c40b5d3] | committer: 
Pierre Lamot

qml: add drag and drop support in MusicGenres

Signed-off-by: Pierre Lamot <pie...@videolabs.io>

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

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

diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml 
b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
index c44c5e8f40..17c240733d 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
@@ -103,6 +103,27 @@ Widgets.NavigableFocusScope {
         model: genreModel
     }
 
+    Widgets.DragItem {
+        id: genreDragItem
+
+        function updateComponents(maxCovers) {
+          var items = selectionModel.selectedIndexes.slice(0, 
maxCovers).map(function (x){
+            return genreModel.getDataAt(x.row)
+          })
+          var title = items.map(function (item){ return item.name}).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, 
genreModel.getIdsForIndexes(selectionModel.selectedIndexes))
+        }
+    }
+
     /*
      *define the intial position/selection
      * This is done on activeFocus rather than Component.onCompleted because 
selectionModel.
@@ -145,6 +166,7 @@ Widgets.NavigableFocusScope {
                 pictureHeight: height
                 image: model.cover || VLCStyle.noArtAlbum
                 playCoverBorder.width: VLCStyle.dp(3, VLCStyle.scale)
+                dragItem: genreDragItem
 
                 onItemDoubleClicked: root.showAlbumView(model)
                 onItemClicked: gridView_id.leftClickOnItem(modifier, 
item.index)
@@ -239,6 +261,7 @@ Widgets.NavigableFocusScope {
             focus: true
             onActionForSelection: _actionAtIndex(selection)
             navigationParent: root
+            dragItem: genreDragItem
 
             sortModel:  [
                 { isPrimary: true, criteria: "cover", width: 
VLCStyle.listAlbumCover_width, headerDelegate: thumbnailHeader, colDelegate: 
thumbnailColumn },

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to