[vlc-devel] [PATCH 16/16] qml: add drag and drop support in MusicGenres
Prince Gupta
guptaprince8832 at gmail.com
Fri Dec 4 12:19:13 CET 2020
---
.../gui/qt/medialibrary/qml/MusicGenres.qml | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
index c44c5e8f40..17c240733d 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
@@ -103,6 +103,27 @@ Widgets.NavigableFocusScope {
model: genreModel
}
+ Widgets.DragItem {
+ id: genreDragItem
+
+ function updateComponents(maxCovers) {
+ var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
+ return genreModel.getDataAt(x.row)
+ })
+ var title = items.map(function (item){ return item.name}).join(", ")
+ var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtCover}})
+ return {
+ covers: covers,
+ title: title,
+ count: selectionModel.selectedIndexes.length
+ }
+ }
+
+ function insertIntoPlaylist(index) {
+ medialib.insertIntoPlaylist(index, genreModel.getIdsForIndexes(selectionModel.selectedIndexes))
+ }
+ }
+
/*
*define the intial position/selection
* This is done on activeFocus rather than Component.onCompleted because selectionModel.
@@ -145,6 +166,7 @@ Widgets.NavigableFocusScope {
pictureHeight: height
image: model.cover || VLCStyle.noArtAlbum
playCoverBorder.width: VLCStyle.dp(3, VLCStyle.scale)
+ dragItem: genreDragItem
onItemDoubleClicked: root.showAlbumView(model)
onItemClicked: gridView_id.leftClickOnItem(modifier, item.index)
@@ -239,6 +261,7 @@ Widgets.NavigableFocusScope {
focus: true
onActionForSelection: _actionAtIndex(selection)
navigationParent: root
+ dragItem: genreDragItem
sortModel: [
{ isPrimary: true, criteria: "cover", width: VLCStyle.listAlbumCover_width, headerDelegate: thumbnailHeader, colDelegate: thumbnailColumn },
--
2.25.1
More information about the vlc-devel
mailing list