Display the platform information in the Station schedule view
[quandoparte] / application / resources / harmattan / qml / StationPage.qml
1 import QtQuick 1.1
2 import QtWebKit 1.0
3 import com.nokia.meego 1.0
4 import net.cirulla.quandoparte 1.0
5 import "uiconstants.js" as UiConstants
6
7 Page {
8     property alias name: schedule.name
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"; }
14     }
15     PageHeader {
16         id: header
17         anchors.top: parent.top
18         selectedIndex: schedule.type
19         options: ListModel {
20             id: dialogOptions
21             ListElement {
22                 name: QT_TR_NOOP("Departures")
23             }
24             ListElement {
25                 name: QT_TR_NOOP("Arrivals")
26             }
27         }
28     }
29     InfoBar {
30         id: infoBar
31         anchors.top: header.bottom
32         text: parent.name
33     }
34     Binding {
35         target: schedule
36         property: "type"
37         value: header.selectedIndex
38     }
39     LabelStyle {
40         id: labelStyle
41     }
42     Item {
43         id: view
44         anchors {
45             top: infoBar.bottom
46             bottom: parent.bottom
47             left: parent.left
48             right: parent.right
49         }
50         DroppedShadow {
51             id: shadow
52             anchors.top: view.top
53         }
54         ListView {
55             id: stationScheduleView
56             clip: true
57             visible: false
58             width: parent.width
59             anchors {
60                 top: shadow.top
61                 bottom: parent.bottom
62             }
63             model:  schedule
64             delegate: Item {
65                 id: listItem
66                 height: UiConstants.ListItemHeightDefault
67                 width: parent.width
68                 BorderImage {
69                     id: background
70                     anchors.fill: parent
71                     // Fill page borders
72                     visible: mouseArea.pressed
73                     source: "image://theme/meegotouch-list-background-pressed-center"
74                 }
75                 Row {
76                     id: bodyRow
77                     anchors.fill: parent
78                     spacing: UiConstants.ButtonSpacing
79                     DelayIndicator {
80                         level: delayClass
81                     }
82                     Column {
83                         anchors.verticalCenter: parent.verticalCenter
84                         Row {
85                             spacing: UiConstants.ButtonSpacing
86                             Label {
87                                 text: arrivalTime
88                                 font.bold: UiConstants.SpecialFontBoldness
89                                 font.pixelSize: UiConstants.SpecialFontPixelSize
90                                 visible: schedule.type === StationScheduleModel.ArrivalSchedule
91                             }
92                             Label {
93                                 text: departureTime
94                                 font.bold: UiConstants.SpecialFontBoldness
95                                 font.pixelSize: UiConstants.SpecialFontPixelSize
96                                 visible: schedule.type === StationScheduleModel.DepartureSchedule
97                             }
98                             Label {
99                                 text: train
100                                 font.bold: UiConstants.SpecialFontBoldness
101                                 font.pixelSize: UiConstants.SpecialFontPixelSize
102                                 color: UiConstants.AccentColor
103                             }
104                         }
105                         Label {
106                             text: qsTr("from ") + arrivalStation
107                             font.bold: UiConstants.DefaultFontBoldness
108                             font.pixelSize: UiConstants.DefaultFontPixelSize
109                             visible: schedule.type === StationScheduleModel.ArrivalSchedule
110                         }
111                         Label {
112                             text: qsTr("to ") + departureStation
113                             font.bold: UiConstants.DefaultFontBoldness
114                             font.pixelSize: UiConstants.DefaultFontPixelSize
115                             visible: schedule.type === StationScheduleModel.DepartureSchedule
116                         }
117                         Label {
118                             id: delayLabel
119                             text: delay
120                             font.bold: UiConstants.SubtitleFontBoldness
121                             font.pixelSize: UiConstants.SubtitleFontPixelSize
122                         }
123                     }
124                     Label {
125                         anchors {
126                             bottom: bodyRow.bottom
127                             right: bodyRow.right
128                             rightMargin: UiConstants.DefaultMargin
129                         }
130                         text: qsTr("Platform ") + actualPlatform
131                         font.bold: UiConstants.SubtitleFontBoldness
132                         font.pixelSize: UiConstants.SubtitleFontPixelSize
133                     }
134                 }
135                 Image {
136                     anchors {
137                         left: parent.left
138                         right: parent.right
139                     }
140                     source: "image://theme/meegotouch-separator-background-horizontal"
141                 }
142                 MouseArea {
143                     id: mouseArea
144                     anchors.fill: background
145                     onClicked: {
146                         // Load an external page about the train, for now
147                     }
148                 }
149             }
150         }
151         ScrollDecorator {
152             id: decorator
153             flickableItem: stationScheduleView
154         }
155         BusyIndicator {
156             id: busyIndicator
157             platformStyle: BusyIndicatorStyle {
158                 size: "large"
159             }
160             anchors.centerIn: parent
161             visible: !stationScheduleView.visible
162             running: visible
163         }
164         states: [
165             State {
166                 name: "loading"
167                 PropertyChanges {
168                     target: stationScheduleView
169                     visible: false
170                 }
171             },
172             State {
173                 name: "ready"
174                 PropertyChanges {
175                     target: stationScheduleView
176                     visible: true
177                 }
178             }
179         ]
180     }
181     StationScheduleModel {
182         id: schedule
183         onNameChanged: schedule.fetch(name)
184         onLayoutChanged: view.state = "ready"
185     }
186
187  }