[vlc-commits] qt: playlist: update drag&drop count on drag
Romain Vimont
git at videolan.org
Tue Jul 16 14:09:14 CEST 2019
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Jul 9 18:30:29 2019 +0200| [5b52a59e5ceffa391e8e6afe93c34654221f15e7] | committer: Jean-Baptiste Kempf
qt: playlist: update drag&drop count on drag
To display the number of items selected during a drag&drop, the text
property was bound to "delegateModel.selectedGroup.count".
We will remove the delegate model to manage the selection in the
QAbstractListModel. Since there is no need to expose the selection count
as a bindable property, just update it on drag start.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5b52a59e5ceffa391e8e6afe93c34654221f15e7
---
modules/gui/qt/qml/playlist/PLItem.qml | 6 +++++-
modules/gui/qt/qml/playlist/PlaylistListView.qml | 1 -
modules/gui/qt/qml/utils/DNDLabel.qml | 4 +++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt/qml/playlist/PLItem.qml b/modules/gui/qt/qml/playlist/PLItem.qml
index 4a62c6f269..fa75adbea2 100644
--- a/modules/gui/qt/qml/playlist/PLItem.qml
+++ b/modules/gui/qt/qml/playlist/PLItem.qml
@@ -28,6 +28,8 @@ import "qrc:///style/"
Rectangle {
id: root
+ property var plmodel
+
signal itemClicked(int keys, int modifier)
signal itemDoubleClicked(int keys, int modifier)
property alias hovered: mouse.containsMouse
@@ -71,8 +73,10 @@ Rectangle {
property bool hold: false
onPositionChanged: {
- if (hold)
+ if (hold && !dragItem.visible) {
+ dragItem.count = plmodel.getSelection().length
dragItem.visible = true
+ }
}
onPressed: {
hold = true
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index bd69a060ea..8d4dd506d6 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -34,7 +34,6 @@ Utils.NavigableFocusScope {
//label for DnD
Utils.DNDLabel {
id: dragItem
- text: qsTr("%1 tracks selected").arg(delegateModel.selectedGroup.count)
}
diff --git a/modules/gui/qt/qml/utils/DNDLabel.qml b/modules/gui/qt/qml/utils/DNDLabel.qml
index a59b37d4e5..d8f78c72d6 100644
--- a/modules/gui/qt/qml/utils/DNDLabel.qml
+++ b/modules/gui/qt/qml/utils/DNDLabel.qml
@@ -30,6 +30,8 @@ Rectangle {
Drag.active: visible
+ property var count: 0
+
function updatePos(x, y) {
var pos = root.mapFromGlobal(x, y)
dragItem.x = pos.x + 10
@@ -40,6 +42,6 @@ Rectangle {
id: label
font.pixelSize: VLCStyle.fontSize_normal
color: VLCStyle.colors.text
- text: qsTr("%1 tracks selected").arg(delegateModel.selectedGroup.count)
+ text: qsTr("%1 tracks selected").arg(count)
}
}
More information about the vlc-commits
mailing list