Added delay class indicator
[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                     anchors.fill: parent
77                     spacing: UiConstants.ButtonSpacing
78                     DelayIndicator {
79                         level: delayClass
80                     }
81                     Column {
82                         anchors.verticalCenter: parent.verticalCenter
83                         Row {
84                             spacing: UiConstants.ButtonSpacing
85                             Label {
86                                 text: arrivalTime
87                                 font.bold: UiConstants.SpecialFontBoldness
88                                 font.pixelSize: UiConstants.SpecialFontPixelSize
89                                 visible: schedule.type === StationScheduleModel.ArrivalSchedule
90                             }
91                             Label {
92                                 text: departureTime
93                                 font.bold: UiConstants.SpecialFontBoldness
94                                 font.pixelSize: UiConstants.SpecialFontPixelSize
95                                 visible: schedule.type === StationScheduleModel.DepartureSchedule
96                             }
97                             Label {
98                                 text: train
99                                 font.bold: UiConstants.SpecialFontBoldness
100                                 font.pixelSize: UiConstants.SpecialFontPixelSize
101                                 color: UiConstants.AccentColor
102                             }
103                         }
104                         Label {
105                             text: qsTr("from ") + arrivalStation
106                             font.bold: UiConstants.DefaultFontBoldness
107                             font.pixelSize: UiConstants.DefaultFontPixelSize
108                             visible: schedule.type === StationScheduleModel.ArrivalSchedule
109                         }
110                         Label {
111                             text: qsTr("to ") + departureStation
112                             font.bold: UiConstants.DefaultFontBoldness
113                             font.pixelSize: UiConstants.DefaultFontPixelSize
114                             visible: schedule.type === StationScheduleModel.DepartureSchedule
115                         }
116                         Label {
117                             text: delay
118                             font.bold: UiConstants.SubtitleFontBoldness
119                             font.pixelSize: UiConstants.SubtitleFontPixelSize
120                         }
121                     }
122                 }
123                 Image {
124                     source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
125                     anchors.right: parent.right;
126                     anchors.verticalCenter: parent.verticalCenter
127                 }
128                 Image {
129                     anchors {
130                         left: parent.left
131                         right: parent.right
132                     }
133                     source: "image://theme/meegotouch-separator-background-horizontal"
134                 }
135                 MouseArea {
136                     id: mouseArea
137                     anchors.fill: background
138                     onClicked: {
139                         // Load an external page about the train, for now
140                     }
141                 }
142             }
143         }
144         ScrollDecorator {
145             id: decorator
146             flickableItem: stationScheduleView
147         }
148         BusyIndicator {
149             id: busyIndicator
150             platformStyle: BusyIndicatorStyle {
151                 size: "large"
152             }
153             anchors.centerIn: parent
154             visible: !stationScheduleView.visible
155             running: visible
156         }
157         states: [
158             State {
159                 name: "loading"
160                 PropertyChanges {
161                     target: stationScheduleView
162                     visible: false
163                 }
164             },
165             State {
166                 name: "ready"
167                 PropertyChanges {
168                     target: stationScheduleView
169                     visible: true
170                 }
171             }
172         ]
173     }
174     StationScheduleModel {
175         id: schedule
176         onNameChanged: schedule.fetch(name)
177         onLayoutChanged: view.state = "ready"
178     }
179
180  }