d8d502a4146810cf55904e1c6c8bb9f9187f9f7d
[quandoparte] / application / resources / harmattan / qml / StationPage.qml
1 import QtQuick 1.1
2 import com.nokia.meego 1.0
3 import net.cirulla.quandoparte 1.0
4 import "uiconstants.js" as UiConstants
5
6 Page {
7     property alias name: schedule.name
8
9     tools: ToolBarLayout {
10         id: toolBar
11         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop() }
12         ToolIcon { iconId: "icon-m-toolbar-view-menu"; onClicked: menu.open() }
13     }
14     PageHeader {
15         id: header
16         anchors.top: parent.top
17         selectedIndex: schedule.type
18         options: [
19             qsTr("Departures"),
20             qsTr("Arrivals")
21         ]
22     }
23     InfoBar {
24         id: infoBar
25         anchors.top: header.bottom
26         text: parent.name
27     }
28     Binding {
29         target: schedule
30         property: "type"
31         value: header.selectedIndex
32     }
33     LabelStyle {
34         id: labelStyle
35     }
36     Item {
37         id: view
38         anchors {
39             top: infoBar.bottom
40             bottom: parent.bottom
41             left: parent.left
42             right: parent.right
43         }
44         DroppedShadow {
45             id: shadow
46             anchors.top: view.top
47         }
48         ListView {
49             id: stationScheduleView
50             clip: true
51             visible: false
52             width: parent.width
53             anchors {
54                 top: shadow.top
55                 bottom: parent.bottom
56             }
57             model: schedule
58             delegate: StationScheduleDelegate {
59                 type: schedule.type
60                 arrivalTime: model.arrivalTime
61                 departureTime: model.departureTime
62                 train: model.train
63                 arrivalStation: model.arrivalStation
64                 departureStation: model.departureStation
65                 delay: model.delay
66                 actualPlatform: model.actualPlatform
67                 expectedPlatfrom: model.expectedPlatform
68             }
69         }
70         ScrollDecorator {
71             id: decorator
72             flickableItem: stationScheduleView
73         }
74         BusyIndicator {
75             id: busyIndicator
76             platformStyle: BusyIndicatorStyle {
77                 size: "large"
78             }
79             anchors.centerIn: parent
80             visible: !stationScheduleView.visible
81             running: visible
82         }
83         states: [
84             State {
85                 name: "loading"
86                 PropertyChanges {
87                     target: stationScheduleView
88                     visible: false
89                 }
90             },
91             State {
92                 name: "ready"
93                 PropertyChanges {
94                     target: stationScheduleView
95                     visible: true
96                 }
97             }
98         ]
99     }
100     StationScheduleModel {
101         id: schedule
102         onNameChanged: schedule.fetch(name)
103         onLayoutChanged: view.state = "ready"
104     }
105     Component.onCompleted: {
106         updateTimer.timeout.connect(updateStation)
107     }
108     function updateStation() {
109         schedule.fetch(schedule.name)
110     }
111 }