[vlc-commits] qml: dynamically define properties in ExpandGridView delegates when possible

Pierre Lamot git at videolan.org
Fri Jan 10 15:06:15 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Nov 29 17:36:44 2019 +0100| [540fca7fa29ddb9ed523974943e12ae32150113d] | committer: Jean-Baptiste Kempf

qml: dynamically define properties in ExpandGridView delegates when possible

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt/widgets/qml/ExpandGridView.qml | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/ExpandGridView.qml b/modules/gui/qt/widgets/qml/ExpandGridView.qml
index 6d4c24dcda..41e52f4633 100644
--- a/modules/gui/qt/widgets/qml/ExpandGridView.qml
+++ b/modules/gui/qt/widgets/qml/ExpandGridView.qml
@@ -104,6 +104,16 @@ NavigableFocusScope {
     }
 
 
+    function _defineObjProperty( obj, prop, value )
+    {
+        Object.defineProperty(obj, prop, {
+            "enumerable": true,
+            "configurable": false,
+            "value": value,
+            "writable": true,
+        })
+    }
+
     //Gridview visible above the expanded item
     Flickable {
         id: flickable
@@ -236,9 +246,11 @@ NavigableFocusScope {
             for (i = firstId; i < topGridEndId; ++i) {
                 var pos = root.getItemPos(i)
                 var item = getChild(i, _unusedItemList)
-                item.model = model.items.get(i).model
-                item.index = i
+                _defineObjProperty(item, "index", i)
+                //theses needs an actual binding
                 item.selected = model.items.get(i).inSelected
+                item.model = model.items.get(i).model
+                //theses properties are always defined in Item
                 item.focus = false
                 item.x = pos[0]
                 item.y = pos[1]
@@ -252,10 +264,12 @@ NavigableFocusScope {
             for (i = topGridEndId; i < lastId; ++i) {
                 pos = root.getItemPos(i)
                 item = getChild(i, _unusedItemList)
+                _defineObjProperty(item, "index", i)
+                //theses needs an actual binding
+                item.selected = model.items.get(i).inSelected
                 item.model = model.items.get(i).model
+                //theses properties are always defined in Item
                 item.focus = false
-                item.index = i
-                item.selected = model.items.get(i).inSelected
                 item.x = pos[0]
                 item.y = pos[1] + expandItem.height
                 item.visible = true



More information about the vlc-commits mailing list