[vlc-devel] [PATCH 4/9] qml: fix playlist drag and drop with recent versions of Qt

Pierre Lamot pierre at videolabs.io
Mon Nov 18 18:15:37 CET 2019


---
 modules/gui/qt/qml/playlist/PLItemFooter.qml     | 13 ++++++++++---
 modules/gui/qt/qml/playlist/PlaylistListView.qml | 11 +++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt/qml/playlist/PLItemFooter.qml b/modules/gui/qt/qml/playlist/PLItemFooter.qml
index 8ad6e19478..fdf78e8f71 100644
--- a/modules/gui/qt/qml/playlist/PLItemFooter.qml
+++ b/modules/gui/qt/qml/playlist/PLItemFooter.qml
@@ -21,6 +21,10 @@ import "qrc:///style/"
 
 Item {
     id: foot
+
+    signal dropURLAtEnd(var urlList)
+    signal moveAtEnd()
+
     property bool _dropVisible: false
 
     width: parent.width
@@ -44,10 +48,13 @@ Item {
         onExited: foot._dropVisible = false
         onDropped: {
             if (drop.hasUrls) {
-                console.log("add urls", drop.urls)
-                delegateModel.onDropUrlAtEnd(drop.urls)
+                //force conversion to an actual list
+                var urlList = []
+                for ( var url in drop.urls)
+                    urlList.push(drop.urls[url])
+                dropURLAtEnd(urlList)
             } else {
-                delegateModel.onDropMovedAtEnd()
+                moveAtEnd()
             }
             drop.accept()
             foot._dropVisible = false
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index bf1ecd160e..f4978a6a50 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -88,7 +88,10 @@ Utils.NavigableFocusScope {
             }
         }
 
-        footer: PLItemFooter {}
+        footer: PLItemFooter {
+            onDropURLAtEnd: mainPlaylistController.insert(root.plmodel.count, urlList)
+            onMoveAtEnd: root.plmodel.moveItemsPost(root.plmodel.getSelection(), root.plmodel.count - 1)
+        }
 
         delegate: PLItem {
             /*
@@ -133,7 +136,11 @@ Utils.NavigableFocusScope {
 
             onDropedMovedAt: {
                 if (drop.hasUrls) {
-                    mainPlaylistController.insert(target, drop.urls)
+                    //force conversion to an actual list
+                    var urlList = []
+                    for ( var url in drop.urls)
+                        urlList.push(drop.urls[url])
+                    mainPlaylistController.insert(target, urlList)
                 } else {
                     root.plmodel.moveItemsPre(root.plmodel.getSelection(), target)
                 }
-- 
2.17.1



More information about the vlc-devel mailing list