[vlc-devel] [PATCH 25/28] qml: restrict item drag&drop on itself in playlist listview
Fatih Uzunoglu
fuzun54 at outlook.com
Tue Jul 21 19:28:55 CEST 2020
---
modules/gui/qt/playlist/qml/PLItem.qml | 17 +++++++++++++++--
modules/gui/qt/playlist/qml/PLItemFooter.qml | 16 ++++++++++++++--
.../gui/qt/playlist/qml/PlaylistListView.qml | 1 +
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/playlist/qml/PLItem.qml b/modules/gui/qt/playlist/qml/PLItem.qml
index eab3698e0b..d4e4ac0ad2 100644
--- a/modules/gui/qt/playlist/qml/PLItem.qml
+++ b/modules/gui/qt/playlist/qml/PLItem.qml
@@ -201,11 +201,24 @@ Rectangle {
DropArea {
anchors { fill: parent }
onEntered: {
+ var delta = drag.source.model.index - model.index
+ if(delta === 0 || delta === -1)
+ return
+
dropVisible = true
- return true
}
- onExited: dropVisible = false
+ 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
+ if(delta === 0 || delta === -1)
+ return
+
root.dropedMovedAt(model.index, drop)
dropVisible = false
}
diff --git a/modules/gui/qt/playlist/qml/PLItemFooter.qml b/modules/gui/qt/playlist/qml/PLItemFooter.qml
index fdf78e8f71..958dc79e77 100644
--- a/modules/gui/qt/playlist/qml/PLItemFooter.qml
+++ b/modules/gui/qt/playlist/qml/PLItemFooter.qml
@@ -22,6 +22,8 @@ import "qrc:///style/"
Item {
id: foot
+ property int listCount
+
signal dropURLAtEnd(var urlList)
signal moveAtEnd()
@@ -42,11 +44,21 @@ Item {
DropArea {
anchors { fill: parent }
onEntered: {
+ if(drag.source.model.index === foot.listCount - 1)
+ return
+
foot._dropVisible = true
- return true
}
- onExited: foot._dropVisible = false
+ onExited: {
+ if(drag.source.model.index === foot.listCount - 1)
+ return
+
+ foot._dropVisible = false
+ }
onDropped: {
+ if(drag.source.model.index === foot.listCount - 1)
+ return
+
if (drop.hasUrls) {
//force conversion to an actual list
var urlList = []
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 2e0474561f..25627a7c15 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -287,6 +287,7 @@ Widgets.NavigableFocusScope {
z: 2
onDropURLAtEnd: mainPlaylistController.insert(root.plmodel.count, urlList)
onMoveAtEnd: root.plmodel.moveItemsPost(root.plmodel.getSelection(), root.plmodel.count - 1)
+ listCount: view.modelCount
}
delegate: Column {
--
2.25.1
More information about the vlc-devel
mailing list