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