← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ahayzen/music-app/refactor-columnflow-fixes-and-preloading-support into lp:music-app/refactor

 

Andrew Hayzen has proposed merging lp:~ahayzen/music-app/refactor-columnflow-fixes-and-preloading-support into lp:music-app/refactor.

Commit message:
* Fixes and add preloading compatibility to ColumnFlow.qml.

Requested reviews:
  Music App Developers (music-app-dev)

For more details, see:
https://code.launchpad.net/~ahayzen/music-app/refactor-columnflow-fixes-and-preloading-support/+merge/258104

* Fixes and add preloading compatibility to ColumnFlow.qml.

The refactor compliment :)
-- 
Your team Music App Developers is requested to review the proposed merge of lp:~ahayzen/music-app/refactor-columnflow-fixes-and-preloading-support into lp:music-app/refactor.
=== modified file 'app/components/ColumnFlow.qml'
--- app/components/ColumnFlow.qml	2015-01-11 17:40:13 +0000
+++ app/components/ColumnFlow.qml	2015-05-02 20:03:03 +0000
@@ -40,6 +40,8 @@
     property bool removing: false
     property bool restoring: false  // is the view restoring?
     property var restoreItems: ({})  // when rebuilding items are stored here temporarily
+    // Disable preloading for now until async loading of pages is implemented
+    property bool preloading: true  // when visible has only been false allow loading (as no child objects [eg pages] can have been created on the fly)
 
     onColumnWidthChanged: {
         if (restoring) {
@@ -62,6 +64,10 @@
     }
 
     onVisibleChanged: {
+        if (visible) {
+            preloading = false;
+        }
+
         if (visible && delayRebuildIndex !== -1) {  // restore from count change
             if (delayRebuildIndex === 0) {
                 reset()
@@ -86,7 +92,7 @@
     Connections {
         target: model === undefined ? fakeModel : model
         onModelReset: {
-            if (!visible) {
+            if (!visible && lastIndex > 0 && !preloading) {
                 delayRebuildIndex = 0
             } else {
                 reset()
@@ -94,7 +100,7 @@
             }
         }
         onRowsInserted: {
-            if (!visible) {
+            if (!visible && lastIndex > 0 && !preloading) {
                 setDelayRebuildIndex(first)
             } else {
                 if (first <= lastIndex) {
@@ -161,7 +167,8 @@
             // and
             // allow if the y position is within the viewport
             // or if loadBefore is true then allow if the y position is before the viewport
-            if (((count > 0 && lastIndex < count && insertMax === undefined) || (insertMax !== undefined && lastIndex <= insertMax)) && (inViewport(y, 0) || (loadBefore === true && beforeViewport(y)))) {
+            if (((count > 0 && lastIndex < count && insertMax === undefined) || (insertMax !== undefined && lastIndex <= insertMax))
+                    && (inViewport(y, 0) || (loadBefore === true && beforeViewport(y)))) {
                 incubateObject(lastIndex++, columnsByHeight[i], getMaxInColumn(columnsByHeight[i]), append);
                 workDone = true
             } else {
@@ -489,4 +496,15 @@
             delayRebuildIndex = index
         }
     }
+
+    Component.onCompleted: {
+        // Ensure that initial column vars are set
+        for (var j=0; j < columns; j++) {
+            columnHeights.push({})
+        }
+
+        cacheColumnHeights()
+
+        append(true)
+    }
 }


Follow ups