[vlc-commits] qml: fix playlist drag and drop with recent versions of Qt

Pierre Lamot git at videolan.org
Tue Nov 19 16:50:08 CET 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Nov  4 17:29:58 2019 +0100| [213d0a063da58b8cdca9f3b690a3b315f01e78a9] | committer: Jean-Baptiste Kempf

qml: fix playlist drag and drop with recent versions of Qt

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 cc3c657dd5..b0d7446265 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 {
             /*
@@ -135,7 +138,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)
                 }



More information about the vlc-commits mailing list