Refactoring and model improvements
[quicknewsreader] / qml / QuickNewsReader / content / view / NewsDelegate.qml
index 517e86f..a0db12d 100644 (file)
@@ -78,9 +78,23 @@ Item {
 
         onDoubleClicked: {
             if (typeof detailedContent != "undefined") {
+                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)
+
+                delegate.ListView.view.currentIndex = index
+                var path = listSourceModel[window.currentSourceIndex].currentPath
+                path[currentSourceDepth] = index
+                listSourceModel[window.currentSourceIndex].currentPath = path
+
+                window.windowViewsModel.append({ component: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewComponent,
+                                                 componentId: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewId,
+                                                 componentDepth: currentSourceDepth+1 })
+
                 //newsDetailRect.webViewAction.enabled = false
-                currentNewsIndex = index
-           ////     journalsRect.x -= window.width + newsRect.x
+           ////     sourcesRect.x -= window.width + newsRect.x
                 //newsDetailRect.webViewAction.enabled = true
                 //newsDetailRect.webViewAction.trigger()
             }