Moved JavaScript to its own file
[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     Component.onCompleted: {
12         stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
13     }
14     tools: ToolBarLayout {
15         id: toolBar
16         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
17         ToolIcon { iconId: "icon-m-toolbar-settings"; onClicked: settingsSheet.open(); }
18         ToolIcon { iconId: "icon-m-toolbar-view-menu"; }
19     }
20
21     DataProvider {
22         id: provider
23         onStationScheduleReady: {
24             if (Private.view !== undefined) {
25                 Private.view.html = result
26                 //Private.view.url = url
27             }
28         }
29     }
30     PageHeader {
31         id: header
32         anchors.top: parent.top
33         selectedIndex: stationListProxyModel.sortingMode
34         options: ListModel {
35             id: dialogOptions
36             ListElement {
37                 name: QT_TR_NOOP("Stations by Name")
38             }
39             ListElement {
40                 name: QT_TR_NOOP("Stations by Distance")
41             }
42             ListElement {
43                 name: QT_TR_NOOP("Stations Recently Seen")
44             }
45         }
46     }
47     SearchBar {
48         id: searchField
49         anchors.top: header.bottom
50     }
51     Binding {
52         target: stationListProxyModel
53         property: "searchPattern"
54         value: searchField.text
55     }
56     Binding {
57         target: stationListProxyModel
58         property: "sortingMode"
59         value: header.selectedIndex
60     }
61     Rectangle {
62         id: shadow
63         width: parent.width
64         anchors.top: mainView.top
65         height: 5
66         gradient: Gradient {
67             GradientStop {color: "#aa000000"; position: 0.0}
68             GradientStop {color: "#00000000"; position: 1.0}
69         }
70     }
71     Item {
72         id: mainView
73         x: 16
74         y: 16
75         anchors.top: searchField.bottom
76         width: parent.width - 32
77         height: parent.height
78         ListView {
79             id: stationListView
80             clip: true
81             width: parent.width
82             height: parent.height
83             model:  stationListProxyModel
84             delegate: Item {
85                 id: listItem
86                 height: 48
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-background-pressed-center"
94                 }
95                 Row {
96                     anchors.fill: parent
97
98                     Column {
99                         anchors.verticalCenter: parent.verticalCenter
100
101                         Label {
102                             id: mainText
103                             text: Private.highlightSearch(model.display)
104                             font.bold: true
105                         }
106                     }
107                 }
108                 MouseArea {
109                     id: mouseArea
110                     anchors.fill: background
111                     onClicked: {
112                         Private.loadStation(model.display)
113                     }
114                 }
115             }
116         }
117     }
118
119     Sheet {
120         id: settingsSheet
121         acceptButtonText: qsTr("Save")
122         rejectButtonText: qsTr("Cancel")
123         content: Item {
124             x: 16
125             y: 16
126             width: parent.width - 32
127             height: parent.height - 32
128             Column {
129                 spacing: 16
130                 anchors.fill: parent
131                 Item {
132                     height: 40
133                     anchors.leftMargin: UiConstants.DefaultMargins
134                     anchors.left: parent.left
135                     anchors.right: parent.right
136                     Label {
137                         font.bold: true
138                         text: "Show Last Station on Startup"
139                         anchors.verticalCenter: parent.verticalCenter
140                         anchors.left: parent.left
141                     }
142                     Switch {
143                         anchors.verticalCenter: parent.verticalCenter
144                         id: showLastStationSwitch
145                         anchors.right: parent.right
146                     }
147                 }
148                 Item {
149                     height: 40
150                     anchors.leftMargin: UiConstants.DefaultMargins
151                     anchors.left: parent.left
152                     anchors.right: parent.right
153                     Label {
154                         font.bold: true
155                         text: "Update Display Periodically"
156                         anchors.verticalCenter: parent.verticalCenter
157                     }
158                     Switch {
159                         anchors.verticalCenter: parent.verticalCenter
160                         anchors.right: parent.right
161                         id: periodicCheckSwitch
162                     }
163                 }
164             }
165         }
166     }
167 }
168