Bugfixes on Maemo5 platform
[quicknewsreader] / qml / QuickNewsReader / main.qml
1 import QtQuick 1.0
2 import "content/view"
3 import "content/modelimpl"
4 import "content/modelitf"
5
6 Rectangle {
7     id: window
8     //anchors.fill: parent // use this little trick to always adapt itself to the screen
9     width: 800; height: 480
10
11     property int currentSourceIndex: 0
12
13     property list<SourceModel> listSourceModel: [
14         LeMondeSourceModel{},
15         GoogleReaderSourceModel{},
16         FavoriteFeedsSourceModel{},
17         YahooSourceModel{}
18     ]
19
20     property variant currentSource: listSourceModel[currentSourceIndex]
21     property bool loading: currentSource.loading
22     property alias windowViewsModel: viewsModel
23     property alias windowViewsList: viewsList
24     property alias currentContentX: viewsList.contentX
25
26     ListModel {
27         id: viewsModel
28
29         ListElement { component: "content/view/Sources.qml"; componentDepth: 0 }
30     }
31
32
33     ListView {
34         id: viewsList
35
36         anchors.fill: window
37         orientation: ListView.Horizontal
38         snapMode: ListView.SnapOneItem
39         flickDeceleration: 500
40         cacheBuffer: 1600 // so that the next delegate gets actually loaded...
41         preferredHighlightBegin: window.x
42         preferredHighlightEnd: window.width
43         highlightRangeMode: ListView.StrictlyEnforceRange
44         boundsBehavior: Flickable.StopAtBounds
45
46         Behavior on contentX {
47             NumberAnimation { duration: 500; easing.type: Easing.InOutCubic }
48         }
49
50         model: viewsModel
51         delegate: Loader {
52             id: modelLoader
53             source: component
54
55             ListView.onAdd: {
56                 viewsList.contentX = componentDepth*window.width
57                 //viewsList.currentIndex = componentDepth  // doesn't work well with Qt 4.7.3 on Maemo...
58             }
59         }
60     }
61
62     function showConfigDialog(index) {
63         configDialog.configModel = listSourceModel[index]
64         configDialog.state = "showSourceConfig"
65     }
66
67     SourceConfigDialog {
68         id:configDialog
69     }
70
71 /*
72 */
73
74     Component {
75         id: quitButtonDelegate
76         Item {
77             width: parent.width; height: 60
78             Text {
79                 text: "Quit"
80                 font { family: "Helvetica"; pixelSize: 16; bold: true }
81                 anchors {
82                     left: parent.left; leftMargin: 15
83                     verticalCenter: parent.verticalCenter
84                 }
85             }
86             MouseArea {
87                 anchors.fill: parent
88                 onClicked: Qt.quit()
89             }
90         }
91     }
92 }