Major changes
[quicknewsreader] / qml / QuickNewsReader / content / view / CategoryDelegate.qml
index 617846d..13afcba 100644 (file)
@@ -77,20 +77,20 @@ Item {
         onClicked: {
             var currentSourceDepth = delegate.ListView.view.model.sourceDepth
 
-            // here we remove everything in viewsModel after index "nextSourceDepth"
-            while(window.windowViewsModel.count>currentSourceDepth+1)
-                window.windowViewsModel.remove(window.windowViewsModel.count-1)
+            if (listSourceModel[window.currentSourceIndex].listViews.length >= currentSourceDepth+1)
+            {
+                // here we remove everything in viewsModel after index "nextSourceDepth"
+                while(window.windowViewsModel.count>currentSourceDepth+1)
+                    window.windowViewsModel.remove(window.windowViewsModel.count-1)
 
-            delegate.ListView.view.currentIndex = index
-            var path = listSourceModel[window.currentSourceIndex].currentPath
-            path[currentSourceDepth] = index
-            listSourceModel[window.currentSourceIndex].currentPath = path
+                delegate.ListView.view.currentIndex = index
+                var path = listSourceModel[window.currentSourceIndex].currentPath
+                path[currentSourceDepth] = index
+                listSourceModel[window.currentSourceIndex].currentPath = path.slice(0,currentSourceDepth+1)
 
-            window.windowViewsModel.append({ component: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewComponent,
-                                             componentId: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewId,
-                                             componentDepth: currentSourceDepth+1 })
-
-            window.windowViewsList.currentIndex = currentSourceDepth+1;
+                window.windowViewsModel.append({ component: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewComponent,
+                                                 componentDepth: currentSourceDepth+1 })
+            }
         }
     }
 }