c2876fe53559298ed4f56c40d4425a9a2ad9d9eb
[quicknewsreader] / qml / QuickNewsReader / content / view / NewsComments.qml
1 import QtQuick 1.0
2 import QtWebKit 1.0
3
4 Item {
5     id: newsCommentsRect
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 commentURL: getNewsModelItem('commentURL')
18     property string title: getNewsModelItem('title')
19     property string image: getNewsModelItem('image')
20
21     VisualItemModel {
22         id: itemModel
23
24         Column {
25             id: column
26             x: 10; y: 10
27             width: newsCommentsRect.width - 20
28 //            height: newsCommentsRect.height
29
30             Row {
31                 id: titleRow
32                 spacing: 5
33
34                 Image {
35                     id: detailImage
36                     source: image
37                 }
38
39                 Text {
40                     anchors.verticalCenter: titleRow.verticalCenter
41                     text: title; width: column.width - detailImage.width - 10; wrapMode: Text.WordWrap
42                     font { bold: true; family: "Helvetica"; pointSize: 16 }
43                 }
44             }
45
46             WebView {
47                 width: column.width
48                 id: newsCommentsWebView
49                 url: commentURL
50                 preferredWidth: column.width
51
52                 // on the maemo platform, the background is dark gray by default, so change it to white
53                 onLoadFinished: {
54                     newsCommentsWebView.evaluateJavaScript("document.bgColor = '#FFFFFF';")
55                 }
56             }
57         }
58     }
59     ListView {
60         id: itemListView
61         anchors.fill: newsCommentsRect
62         model: itemModel
63     }
64     ScrollBar { scrollArea: itemListView; height: itemListView.height; width: 8; anchors.right: itemListView.right }
65 }