Settings dialog infrastructure
[quicknewsreader] / qml / QuickNewsReader / content / view / NewsDetail.qml
1 import QtQuick 1.0
2 //import QtWebKit 1.0
3
4 Item {
5     id: newsDetailRect
6     width: window.width; height: window.height
7
8     function getNewsModelItem(prop)
9     {
10         if( typeof currentSource.listModels[componentDepth-1] != "undefined" )
11             if( typeof currentSource.listModels[componentDepth-1][prop] != "undefined" )
12                 return currentSource.listModels[componentDepth-1][prop]
13
14         return ""
15     }
16
17     property string urllink: getNewsModelItem('urllink')
18     property string htmlcontent: getNewsModelItem('htmlcontent')
19     property string title: getNewsModelItem('title')
20     property string image: getNewsModelItem('image')
21
22     VisualItemModel {
23         id: itemModel
24
25         Item {
26             x: 0; y: 0
27             width: newsDetailRect.width
28             height: column.height
29
30             Column {
31                 id: column
32                 x: 0; y: 0
33                 width: parent.width - 20
34
35                 Row {
36                     spacing: 5
37
38                     Image {
39                         id: detailImage
40                         source: image
41                     }
42
43                     Text {
44                         anchors.verticalCenter: detailImage.verticalCenter
45                         text: title; width: column.width - detailImage.width - 10; wrapMode: Text.WordWrap
46                         font { bold: true; family: "Helvetica"; pointSize: 16 }
47                     }
48                 }
49
50                 Text {
51                     id: detailText
52                     text: htmlcontent; width: newsDetailRect.width - 20; wrapMode: Text.WordWrap
53                     font.family: "Helvetica"
54                 }
55             }
56
57             MouseArea {
58                 anchors.fill: column
59
60                 onClicked: {
61                     var currentSourceDepth = currentSource.listModels[componentDepth-1].sourceDepth
62
63                     // here we remove everything in viewsModel after index "currentSourceDepth"
64                     while(window.windowViewsModel.count>currentSourceDepth+1)
65                         window.windowViewsModel.remove(window.windowViewsModel.count-1)
66
67                     var path = listSourceModel[window.currentSourceIndex].currentPath
68                     path[currentSourceDepth] = index
69                     listSourceModel[window.currentSourceIndex].currentPath = path
70
71                     window.windowViewsModel.append({ component: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewComponent,
72                                                      componentId: listSourceModel[window.currentSourceIndex].listViews[currentSourceDepth].viewId,
73                                                      componentDepth: currentSourceDepth+1 })
74
75                     window.windowViewsList.currentIndex = currentSourceDepth+1;
76                 }
77             }
78         }
79     }
80     ListView {
81         id: itemListView
82         anchors.fill: newsDetailRect
83         model: itemModel
84     }
85     ScrollBar { scrollArea: itemListView; height: itemListView.height; width: 8; anchors.right: itemListView.right }
86 }