Jelajahi Sumber

Reel: Allow constraint on item count

Donald Carr 8 tahun lalu
induk
melakukan
db126042fd
1 mengubah file dengan 10 tambahan dan 3 penghapusan
  1. 10 3
      qml/reel/Reel.qml

+ 10 - 3
qml/reel/Reel.qml

@@ -20,6 +20,7 @@ View {
 
     QtObject {
         id: d
+        property int itemLimit: -1
         property real t: 0
         property var priorImage
         property real velocity: 0
@@ -68,6 +69,12 @@ View {
                 return !d.initialized || imageQueue.length < d.imageBuffer
             }
 
+            function addNewImage() {
+                globalUtil.itemCount++
+                addImage(pictureDelegate.createObject())
+                imageArray.push(imageQueue.pop())
+            }
+
             function addImage(image) {
                 image.parent = column
                 image.y = - image.height
@@ -79,9 +86,9 @@ View {
                     if (imageQueue.length) {
                         imageArray.push(imageQueue.pop())
                     } else if (columnIndex === 0) {
-                        globalUtil.itemCount++
-                        addImage(pictureDelegate.createObject())
-                        imageArray.push(imageQueue.pop())
+                        if (!(d.itemLimit > 0 && d.itemLimit <= globalUtil.itemCount)) {
+                            addNewImage()
+                        }
                     }
                 }