psa: scrolling only right
[feedingit] / psa_harmattan / feedingit / qml / Articles.qml
1 import Qt 4.7
2 import com.nokia.meego 1.0
3
4 Item {
5     id: articlePage
6     property string mainArticleId: parent.mainArticleId;
7     property string feedid: parent.feedid
8     property bool zoomEnabled: false
9     property bool vertPanningEnabled: true
10     width: parent.width; height: parent.height;
11
12     ListView {
13         id: articleView;
14         model: articlesModel;
15         delegate: viewer;
16         property int webviewFontSize: settings.webviewFontSize
17         orientation: ListView.Horizontal
18         width: parent.width;
19         height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height;
20         //onCurrentIndexChanged: articleView.positionViewAtIndex(currentIndex, ListView.Contain)
21         highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
22         cacheBuffer: width;
23         onMovementStarted: articlePage.vertPanningEnabled=false;
24         onMovementEnded: articlePage.vertPanningEnabled=true;
25         highlightMoveDuration: 300;
26         clip: true
27         boundsBehavior: Flickable.DragOverBounds
28
29         onCurrentIndexChanged: {
30             if (currentIndex >= count-1) {
31                 articlesModel.append({articleid: controller.getNextId(feedid, articlesModel.get(currentIndex).articleid)})
32             }
33         }
34
35 //        onCountChanged: {
36 //            if (count == 3) {
37 //                articleView.currentIndex = 1
38 //            }
39 //        }
40     }
41
42     ProgressBar {
43         id: updateBarArticles
44         minimumValue: 0
45         maximumValue: 100
46         value: window.updateProgressValue
47         visible: window.isUpdateInProgress
48         width: parent.width
49         anchors.bottom: parent.bottom
50     }
51
52     ListModel {
53         id: articlesModel
54
55
56
57     }
58
59     Component {
60         id: viewer
61         Item {
62             id: flipItem;
63             width: articleDisplay.width;
64             height: articleView.height;
65
66             //property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: "";
67             property string html: controller.getArticle(articlePage.feedid, articleid)
68             ArticleDisplay {
69                 id: articleDisplay
70                 zoomEnabled: articlePage.zoomEnabled;
71                 property bool vertPanningEnabled: articlePage.vertPanningEnabled;
72
73                 states: [ State {
74                         name: 'articleIsRead';
75                     when: articleView.currentIndex == index;
76                     StateChangeScript {
77                         name: "myScript"
78                         script: {
79                             //flipItem.url=path;
80                             controller.setEntryRead(articlePage.feedid, articleid)
81 //                            if (articlesModel.count==1) {
82 //                                timer.start()
83 //                            }
84                         }
85                     }
86                     }
87                 ]
88             }
89         }
90     }
91
92     Component.onCompleted: {
93         articlesModel.append({articleid: mainArticleId})
94         //articlesModel.append({articleid: controller.getPreviousId(feedid, mainArticleId)})
95
96         //articleView.currentIndex = 1
97     }
98
99 //    Timer {
100 //        id: timer
101 //        interval: 500; running: false; repeat: false
102 //        onTriggered: {
103 //            articlesModel.insert(0,{articleid: controller.getNextId(feedid, mainArticleId)})
104 //            articlesModel.append({articleid: controller.getPreviousId(feedid, mainArticleId)})
105 //        }
106 //    }
107
108 }