b5c3eaf570d657a5bef94da2465d79df7e530ab1
[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 ListModel windowViewsModel: viewsModel
23     property ListView windowViewsList: viewsList
24
25     ListModel {
26         id: viewsModel
27
28         ListElement { component: "content/view/Sources.qml"; componentDepth: 0 }
29     }
30
31
32     ListView {
33         id: viewsList
34
35         anchors.fill: window
36         orientation: ListView.Horizontal
37         snapMode: ListView.SnapOneItem
38         flickDeceleration: 500
39         cacheBuffer: 1600 // so that the next delegate gets actually loaded...
40         preferredHighlightBegin: window.x
41         preferredHighlightEnd: window.width
42         highlightRangeMode: ListView.StrictlyEnforceRange
43         boundsBehavior: Flickable.StopAtBounds
44
45         model: viewsModel
46         delegate: Loader {
47             id: modelLoader
48             source: component
49
50             ListView.onAdd: {
51                 viewsList.currentIndex = componentDepth
52             }
53         }
54     }
55
56     function showConfigDialog(index) {
57         configDialog.configModel = listSourceModel[index]
58         configDialog.state = "showSourceConfig"
59     }
60
61     SourceConfigDialog {
62         id:configDialog
63     }
64
65 /*
66 */
67
68     Component {
69         id: quitButtonDelegate
70         Item {
71             width: parent.width; height: 60
72             Text {
73                 text: "Quit"
74                 font { family: "Helvetica"; pixelSize: 16; bold: true }
75                 anchors {
76                     left: parent.left; leftMargin: 15
77                     verticalCenter: parent.verticalCenter
78                 }
79             }
80             MouseArea {
81                 anchors.fill: parent
82                 onClicked: Qt.quit()
83             }
84         }
85     }
86 }