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