Use the new code field to fetch the station schedule
[quandoparte] / application / resources / harmattan / qml / StationListPage.qml
1 import QtQuick 1.0
2 import QtMobility.location 1.1
3 import com.nokia.meego 1.0
4 import net.cirulla.quandoparte 1.0
5 import "uiconstants.js" as UiConstants
6 import "StationListPage.js" as Private
7
8 Page {
9     property variant stationView
10     id: stationListPage
11     tools: ToolBarLayout {
12         id: toolBar
13         ToolIcon { iconId: "icon-m-toolbar-search"; onClicked: searchField.visible = !searchField.visible; }
14         ToolIcon { iconId: "icon-m-toolbar-view-menu"; onClicked: menu.open() }
15     }
16     Menu {
17         id: menu
18         content: MenuLayout {
19             MenuItem {
20                 text: qsTr("Update Periodically")
21                 Switch {
22                     id: periodicCheckSwitch
23                     anchors {
24                         verticalCenter: parent.verticalCenter
25                         right: parent.right
26                         rightMargin: UiConstants.DefaultMargin
27                     }
28                     onCheckedChanged: settings.autoUpdate = checked
29                 }
30             }
31             MenuItem {
32                 text: qsTr("About Quando Parte")
33                 onClicked: Private.showAboutPage()
34             }
35             Component.onCompleted: periodicCheckSwitch.checked = settings.autoUpdate
36         }
37     }
38     PageHeader {
39         id: header
40         anchors.top: parent.top
41         selectedIndex: stationListProxyModel.sortingMode
42         options: [
43             qsTr("Stations by Name"),
44             qsTr("Stations by Distance"),
45             qsTr("Stations Recently Seen")
46         ]
47     }
48     SearchBar {
49         id: searchField
50         anchors.top: header.bottom
51         visible: false
52     }
53     Binding {
54         target: stationListProxyModel
55         property: "searchPattern"
56         value: searchField.text
57     }
58     Binding {
59         target: stationListProxyModel
60         property: "sortingMode"
61         value: header.selectedIndex
62     }
63     Item {
64         id: mainView
65         anchors {
66             top: searchField.bottom
67             bottom: parent.bottom
68             left: parent.left
69             right: parent.right
70         }
71         DroppedShadow {
72             id: shadow
73             anchors.top: mainView.top
74         }
75         ListView {
76             id: stationListView
77             clip: true
78             width: parent.width
79             anchors {
80                 top: shadow.top
81                 bottom: parent.bottom
82             }
83             model:  stationListProxyModel
84             delegate: Item {
85                 id: listItem
86                 height: UiConstants.ListItemHeightSmall
87                 width: parent.width
88                 BorderImage {
89                     id: background
90                     anchors.fill: parent
91                     // Fill page borders
92                     visible: mouseArea.pressed
93                     source: "image://theme/meegotouch-list-fullwidth-background-pressed"
94                 }
95                 Row {
96                     anchors.fill: parent
97                     Item {
98                         width: UiConstants.DefaultMargin
99                         height: UiConstants.DefaultMargin
100                     }
101                     Column {
102                         anchors.verticalCenter: parent.verticalCenter
103
104                         Label {
105                             id: mainText
106                             text: Private.highlightSearch(model.name, UiConstants.AccentColor)
107                             font.bold: true
108                         }
109                         Label {
110                             id: subText
111                             text: (model.code !== undefined) ? model.code : "none"
112                             font.bold: UiConstants.SubtitleFontBoldness
113                             font.pixelSize: UiConstants.SubtitleFontPixelSize
114                         }
115                     }
116                 }
117                 Image {
118                     anchors {
119                         left: parent.left
120                         right: parent.right
121                     }
122                     source: "image://theme/meegotouch-separator-background-horizontal"
123                 }
124                 MouseArea {
125                     id: mouseArea
126                     anchors.fill: background
127                     onClicked: {
128                         Private.loadStation(model.name, model.code)
129                     }
130                 }
131             }
132         }
133         ScrollDecorator {
134             id: decorator
135             flickableItem: stationListView
136         }
137     }
138 }
139