Major changes
[quicknewsreader] / qml / QuickNewsReader / content / view / NewsDetail.qml
index 211b395..295b440 100644 (file)
@@ -5,46 +5,76 @@ Item {
     id: newsDetailRect
     width: window.width; height: window.height
 
-    function getNewsModelItem(newsIndex, prop)
+    function getNewsModelItem(prop)
     {
-        if( typeof currentJournal.newsModel.get(newsIndex) != "undefined" )
-            if( typeof currentJournal.newsModel.get(newsIndex)[prop] != "undefined" )
-                return currentJournal.newsModel.get(newsIndex)[prop]
+        if( typeof currentSource.listModels[componentDepth-1] != "undefined" )
+            if( typeof currentSource.listModels[componentDepth-1][prop] != "undefined" )
+                return currentSource.listModels[componentDepth-1][prop]
 
         return ""
     }
 
-    property string urllink: getNewsModelItem(currentNewsIndex, 'link')
-    property string htmlcontent: getNewsModelItem(currentNewsIndex, 'detailedContent')
-    property string title: getNewsModelItem(currentNewsIndex, 'title')
-    property string image: getNewsModelItem(currentNewsIndex, 'image')
+    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 + 10
 
-            Row {
-                spacing: 5
+            Column {
+                id: column
+                x: 10; y: 10
+                width: parent.width - 20
 
-                Image {
-                    id: detailImage
-                    source: image
+                Row {
+                    spacing: 5
+
+                    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
+                    horizontalAlignment: Text.AlignJustify;
+                    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
+
+                    if (listSourceModel[window.currentSourceIndex].listViews.length >= currentSourceDepth+1)
+                    {
+                        // 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.slice(0,currentSourceDepth+1)
+
+                        window.windowViewsModel.append({ component: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewComponent,
+                                                         componentDepth: currentSourceDepth+1 })
+                    }
+                }
             }
         }
     }
@@ -54,14 +84,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
-    }
-*/
 }