[vlc-commits] qml: ExpandGridView bind model directly to delegate instances

Pierre Lamot git at videolan.org
Fri Sep 6 18:02:03 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Sep  5 17:01:41 2019 +0200| [70373cbbfa9e7fbabbe7d95c82b54c14dc9b7e69] | committer: Jean-Baptiste Kempf

qml: ExpandGridView bind model directly to delegate instances

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

 modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml      | 6 +++---
 modules/gui/qt/qml/mediacenter/NetworkDriveDisplayGrid.qml | 1 -
 modules/gui/qt/qml/utils/ExpandGridView.qml                | 8 ++++++--
 modules/gui/qt/qml/utils/GridItem.qml                      | 3 ++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml b/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
index 0db49f0e31..74a4268a57 100644
--- a/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
@@ -118,7 +118,7 @@ Utils.NavigableFocusScope {
                 id: gridItem
 
                 image: VLCStyle.noArtAlbum
-                title: modelData.name || "Unknown genre"
+                title: model.name || "Unknown genre"
                 subtitle: ""
                 //selected: element.DelegateModel.inSelected
 
@@ -129,7 +129,7 @@ Utils.NavigableFocusScope {
                 }
 
                 onItemDoubleClicked: {
-                    history.push(["mc", "music", "albums", { parentId: modelData.id } ], History.Go)
+                    history.push(["mc", "music", "albums", { parentId: model.id } ], History.Go)
                 }
 
                 //replace image with a mutlicovers preview
@@ -141,7 +141,7 @@ Utils.NavigableFocusScope {
 
                     albums: MLAlbumModel {
                         ml: medialib
-                        parentId: modelData.id
+                        parentId: model.id
                     }
                 }
 
diff --git a/modules/gui/qt/qml/mediacenter/NetworkDriveDisplayGrid.qml b/modules/gui/qt/qml/mediacenter/NetworkDriveDisplayGrid.qml
index 7a0f64b4b1..7c557367a7 100644
--- a/modules/gui/qt/qml/mediacenter/NetworkDriveDisplayGrid.qml
+++ b/modules/gui/qt/qml/mediacenter/NetworkDriveDisplayGrid.qml
@@ -49,7 +49,6 @@ Utils.GridItem {
     subtitle: model.mrl
     title: model.name || qsTr("Unknown share")
     focus: true
-    selected: parent.activeFocus && element.DelegateModel.inSelected
     onItemClicked : {
         if (key == Qt.RightButton){
             contextMenu.model = model
diff --git a/modules/gui/qt/qml/utils/ExpandGridView.qml b/modules/gui/qt/qml/utils/ExpandGridView.qml
index 6de157c294..a7eda583ad 100644
--- a/modules/gui/qt/qml/utils/ExpandGridView.qml
+++ b/modules/gui/qt/qml/utils/ExpandGridView.qml
@@ -236,7 +236,9 @@ NavigableFocusScope {
             for (i = firstId; i < topGridEndId; ++i) {
                 var pos = getItemPos(i)
                 var item = getChild(i, _unusedItemList)
-                item.delegateModelItem = model.items.get(i)
+                item.model = model.items.get(i).model
+                item.index = i
+                item.selected = model.items.get(i).inSelected
                 item.x = pos[0]
                 item.y = pos[1]
                 item.visible = true
@@ -249,7 +251,9 @@ NavigableFocusScope {
             for (i = topGridEndId; i < lastId; ++i) {
                 pos = getItemPos(i)
                 item = getChild(i, _unusedItemList)
-                item.delegateModelItem = model.items.get(i)
+                item.model = model.items.get(i).model
+                item.index = i
+                item.selected = model.items.get(i).inSelected
                 item.x = pos[0]
                 item.y = pos[1] + expandItem.height
                 item.visible = true
diff --git a/modules/gui/qt/qml/utils/GridItem.qml b/modules/gui/qt/qml/utils/GridItem.qml
index 631eec08fe..7d831cde4c 100644
--- a/modules/gui/qt/qml/utils/GridItem.qml
+++ b/modules/gui/qt/qml/utils/GridItem.qml
@@ -55,7 +55,8 @@ Rectangle {
     signal itemDoubleClicked(Item menuParent, int keys, int modifier)
     signal contextMenuButtonClicked(Item menuParent)
 
-    
+    property int index: 0
+
     Rectangle {
         id: gridItem
         width: childrenRect.width



More information about the vlc-commits mailing list