Start of a proper station schedule parsing.
[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     anchors.fill: parent
10
11     tools: ToolBarLayout {
12         id: toolBar
13         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
14         ToolIcon { iconId: "icon-m-toolbar-view-menu"; }
15     }
16     PageHeader {
17         id: header
18         anchors.top: parent.top
19         selectedIndex: settings.showArrivalsPreferred ? 1 : 0
20         options: ListModel {
21             id: dialogOptions
22             ListElement {
23                 name: QT_TR_NOOP("Departures")
24             }
25             ListElement {
26                 name: QT_TR_NOOP("Arrivals")
27             }
28         }
29     }
30     InfoBar {
31         id: info
32         anchors.top: header.bottom
33         text: parent.name
34     }
35     Rectangle {
36         id: shadow
37         width: parent.width
38         anchors.top: view.top
39         height: 5
40         gradient: Gradient {
41             GradientStop {color: "#aa000000"; position: 0.0}
42             GradientStop {color: "#00000000"; position: 1.0}
43         }
44     }
45     Binding {
46         target: settings
47         property: "showArrivalsPreferred"
48         value: header.selectedIndex === 1 ? true : false
49     }
50     LabelStyle {
51         id: labelStyle
52     }
53     Item {
54         id: view
55         anchors.top: info.bottom
56         anchors.bottom: tools.top
57         x: 16
58         y: 16
59         width: parent.width - 32
60         height: parent.height
61
62         ListView {
63             id: stationScheduleView
64             clip: true
65             width: parent.width
66             height: parent.height
67             model:  schedule
68             delegate: Item {
69                 id: listItem
70                 height: 192
71                 width: parent.width
72                 BorderImage {
73                     id: background
74                     anchors.fill: parent
75                     // Fill page borders
76                     visible: mouseArea.pressed
77                     source: "image://theme/meegotouch-list-background-pressed-center"
78                 }
79                 Row {
80                     anchors.fill: parent
81
82                     Column {
83                         anchors.verticalCenter: parent.verticalCenter
84
85                         Label {
86                             id: mainText
87                             text: model.display
88                             font.bold: true
89                         }
90                     }
91                 }
92                 MouseArea {
93                     id: mouseArea
94                     anchors.fill: background
95                     onClicked: {
96                         // Load an external page about the train, for now
97                     }
98                 }
99             }
100         }
101     }
102
103     StationScheduleModel {
104         id: schedule
105         onNameChanged: schedule.fetch(name)
106     }
107  }