[vlc-devel] [PATCH 07/27] qml: fix playlist external drag & drop

Fatih Uzunoglu fuzun54 at outlook.com
Fri Oct 9 18:56:28 CEST 2020


---
 modules/gui/qt/playlist/qml/PLItem.qml        | 33 +++++++++++--------
 .../gui/qt/playlist/qml/PlaylistListView.qml  |  7 ++--
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PLItem.qml b/modules/gui/qt/playlist/qml/PLItem.qml
index 9476e061cc..48cdca3e75 100644
--- a/modules/gui/qt/playlist/qml/PLItem.qml
+++ b/modules/gui/qt/playlist/qml/PLItem.qml
@@ -310,21 +310,25 @@ Rectangle {
                 Layout.preferredHeight: parent.height / 2
 
                 onEntered: {
-                    var delta = drag.source.model.index - model.index
+                    var delta = 1
+
+                    if(!drag.hasUrls)
+                        delta = drag.source.model.index - model.index
+
                     if(delta === 0 || delta === -1)
                         return
 
                     dropVisible = true
                 }
                 onExited: {
-                    var delta = drag.source.model.index - model.index
-                    if(delta === 0 || delta === -1)
-                        return
-
                     dropVisible = false
                 }
                 onDropped: {
-                    var delta = drag.source.model.index - model.index
+                    var delta = 1
+
+                    if(!drop.hasUrls)
+                        delta = drag.source.model.index - model.index
+
                     if(delta === 0 || delta === -1)
                         return
 
@@ -341,7 +345,11 @@ Rectangle {
                 property bool _isLastItem : model.index === plitem.plmodel.count - 1
 
                 onEntered: {
-                    var delta = drag.source.model.index - model.index
+                    var delta = -1
+
+                    if(!drag.hasUrls)
+                        delta = drag.source.model.index - model.index
+
                     if(delta === 0 || delta === 1)
                         return
 
@@ -355,10 +363,6 @@ Rectangle {
                     }
                 }
                 onExited: {
-                    var delta = drag.source.model.index - model.index
-                    if(delta === 0 || delta === 1)
-                        return
-
                     if (_isLastItem)
                     {
                         root.setItemDropIndicatorVisible(model.index, false, false);
@@ -369,7 +373,11 @@ Rectangle {
                     }
                 }
                 onDropped: {
-                    var delta = drag.source.model.index - model.index
+                    var delta = -1
+
+                    if(!drop.hasUrls)
+                        delta = drag.source.model.index - model.index
+
                     if(delta === 0 || delta === 1)
                         return
 
@@ -394,7 +402,6 @@ Rectangle {
                     }
                 }
             }
-
         }
     }
 }
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 37079a4077..5d9fc8000b 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -301,19 +301,18 @@ Widgets.NavigableFocusScope {
                     DropArea {
                         anchors.fill: parent
                         onEntered: {
-                            if(drag.source.model.index === root.plmodel.count - 1)
+                            if(!drag.hasUrls && drag.source.model.index === root.plmodel.count - 1)
                                 return
 
                             root.setItemDropIndicatorVisible(view.modelCount - 1, true, false);
                         }
                         onExited: {
-                            if(drag.source.model.index === root.plmodel.count - 1)
-                                return
+
 
                             root.setItemDropIndicatorVisible(view.modelCount - 1, false, false);
                         }
                         onDropped: {
-                            if(drag.source.model.index === root.plmodel.count - 1)
+                            if(!drop.hasUrls && drop.source.model.index === root.plmodel.count - 1)
                                 return
 
                             if (drop.hasUrls) {
-- 
2.25.1



More information about the vlc-devel mailing list