Improve layout of station list page
[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-back"; onClicked: pageStack.pop(); }
14         ToolIcon { iconId: "icon-m-toolbar-settings"; onClicked: settingsSheet.open(); }
15         ToolIcon { iconId: "icon-m-toolbar-view-menu"; onClicked: menu.open() }
16     }
17     Menu {
18         id: menu
19         content: MenuLayout {
20             MenuItem {
21                 text: qsTr("About Quando Parte")
22                 onClicked: Private.showAboutPage()
23             }
24         }
25     }
26     PageHeader {
27         id: header
28         anchors.top: parent.top
29         selectedIndex: stationListProxyModel.sortingMode
30         options: ListModel {
31             id: dialogOptions
32             ListElement {
33                 name: QT_TR_NOOP("Stations by Name")
34             }
35             ListElement {
36                 name: QT_TR_NOOP("Stations by Distance")
37             }
38             ListElement {
39                 name: QT_TR_NOOP("Stations Recently Seen")
40             }
41         }
42     }
43     SearchBar {
44         id: searchField
45         anchors.top: header.bottom
46     }
47     Binding {
48         target: stationListProxyModel
49         property: "searchPattern"
50         value: searchField.text
51     }
52     Binding {
53         target: stationListProxyModel
54         property: "sortingMode"
55         value: header.selectedIndex
56     }
57     Item {
58         id: mainView
59         anchors {
60             top: searchField.bottom
61             bottom: parent.bottom
62             left: parent.left
63             right: parent.right
64         }
65         Rectangle {
66             id: shadow
67             width: parent.width
68             anchors.top: mainView.top
69             height: 5
70             gradient: Gradient {
71                 GradientStop {color: "#aa000000"; position: 0.0}
72                 GradientStop {color: "#00000000"; position: 1.0}
73             }
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-background-pressed-center"
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.display, UiConstants.AccentColor)
107                             font.bold: true
108                         }
109                     }
110                 }
111                 MouseArea {
112                     id: mouseArea
113                     anchors.fill: background
114                     onClicked: {
115                         Private.loadStation(model.display)
116                     }
117                 }
118             }
119         }
120         ScrollDecorator {
121             id: decorator
122             flickableItem: stationListView
123         }
124     }
125
126     Sheet {
127         id: settingsSheet
128         acceptButtonText: qsTr("Save")
129         rejectButtonText: qsTr("Cancel")
130         content: Item {
131             x: 16
132             y: 16
133             width: parent.width - 32
134             height: parent.height - 32
135             Column {
136                 spacing: 16
137                 anchors.fill: parent
138                 Item {
139                     height: 40
140                     anchors.leftMargin: UiConstants.DefaultMargin
141                     anchors.left: parent.left
142                     anchors.right: parent.right
143                     Label {
144                         font.bold: true
145                         text: qsTr("Show Last Station on Startup")
146                         anchors.verticalCenter: parent.verticalCenter
147                         anchors.left: parent.left
148                     }
149                     Switch {
150                         anchors.verticalCenter: parent.verticalCenter
151                         id: showLastStationSwitch
152                         anchors.right: parent.right
153                     }
154                 }
155                 Item {
156                     height: 40
157                     anchors.leftMargin: UiConstants.DefaultMargin
158                     anchors.left: parent.left
159                     anchors.right: parent.right
160                     Label {
161                         font.bold: true
162                         text: qsTr("Update Display Periodically")
163                         anchors.verticalCenter: parent.verticalCenter
164                     }
165                     Switch {
166                         anchors.verticalCenter: parent.verticalCenter
167                         anchors.right: parent.right
168                         id: periodicCheckSwitch
169                     }
170                 }
171             }
172         }
173     }
174 }
175