Settings dialog infrastructure
[quicknewsreader] / qml / QuickNewsReader / content / view / NewsDetail.qml
index 22f60a1..da55341 100644 (file)
@@ -7,47 +7,73 @@ Item {
 
     function getNewsModelItem(prop)
     {
-        var newsIndex = listSourceModel[window.currentSourceIndex].currentPath[componentDepth-1]
-
         if( typeof currentSource.listModels[componentDepth-1] != "undefined" )
-            if( typeof currentSource.listModels[componentDepth-1].get(newsIndex) != "undefined" )
-                if( typeof currentSource.listModels[componentDepth-1].get(newsIndex)[prop] != "undefined" )
-                    return currentSource.listModels[componentDepth-1].get(newsIndex)[prop]
+            if( typeof currentSource.listModels[componentDepth-1][prop] != "undefined" )
+                return currentSource.listModels[componentDepth-1][prop]
 
         return ""
     }
 
-    property string urllink: getNewsModelItem('link')
-    property string htmlcontent: getNewsModelItem('detailedContent')
+    property string urllink: getNewsModelItem('urllink')
+    property string htmlcontent: getNewsModelItem('htmlcontent')
     property string title: getNewsModelItem('title')
     property string image: getNewsModelItem('image')
 
     VisualItemModel {
         id: itemModel
 
-        Column {
-            id: column
-            x: 10; y: 10
-            width: newsDetailRect.width - 20
+        Item {
+            x: 0; y: 0
+            width: newsDetailRect.width
+            height: column.height
+
+            Column {
+                id: column
+                x: 0; y: 0
+                width: parent.width - 20
+
+                Row {
+                    spacing: 5
 
-            Row {
-                spacing: 5
+                    Image {
+                        id: detailImage
+                        source: image
+                    }
 
-                Image {
-                    id: detailImage
-                    source: image
+                    Text {
+                        anchors.verticalCenter: detailImage.verticalCenter
+                        text: title; width: column.width - detailImage.width - 10; wrapMode: Text.WordWrap
+                        font { bold: true; family: "Helvetica"; pointSize: 16 }
+                    }
                 }
 
                 Text {
-                    text: title; width: column.width - detailImage.width - 10; wrapMode: Text.WordWrap
-                    font { bold: true; family: "Helvetica"; pointSize: 16 }
+                    id: detailText
+                    text: htmlcontent; width: newsDetailRect.width - 20; wrapMode: Text.WordWrap
+                    font.family: "Helvetica"
                 }
             }
 
-            Text {
-                id: detailText
-                text: htmlcontent; width: newsDetailRect.width - 20; wrapMode: Text.WordWrap
-                font.family: "Helvetica"
+            MouseArea {
+                anchors.fill: column
+
+                onClicked: {
+                    var currentSourceDepth = currentSource.listModels[componentDepth-1].sourceDepth
+
+                    // here we remove everything in viewsModel after index "currentSourceDepth"
+                    while(window.windowViewsModel.count>currentSourceDepth+1)
+                        window.windowViewsModel.remove(window.windowViewsModel.count-1)
+
+                    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 })
+
+                    window.windowViewsList.currentIndex = currentSourceDepth+1;
+                }
             }
         }
     }
@@ -57,14 +83,4 @@ Item {
         model: itemModel
     }
     ScrollBar { scrollArea: itemListView; height: itemListView.height; width: 8; anchors.right: itemListView.right }
-/*
-    WebView {
-        id: newsDetailWebView
-        anchors.fill: parent
-        html: htmlcontent
-        url: urllink
-        preferredWidth: window.width
-        preferredHeight: window.height
-    }
-*/
 }