Rework user interface
[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                 }
29             }
30             MenuItem {
31                 text: qsTr("About Quando Parte")
32                 onClicked: Private.showAboutPage()
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         visible: false
57     }
58     Binding {
59         target: stationListProxyModel
60         property: "searchPattern"
61         value: searchField.text
62     }
63     Binding {
64         target: stationListProxyModel
65         property: "sortingMode"
66         value: header.selectedIndex
67     }
68     Item {
69         id: mainView
70         anchors {
71             top: searchField.bottom
72             bottom: parent.bottom
73             left: parent.left
74             right: parent.right
75         }
76         DroppedShadow {
77             id: shadow
78             anchors.top: mainView.top
79         }
80         ListView {
81             id: stationListView
82             clip: true
83             width: parent.width
84             anchors {
85                 top: shadow.top
86                 bottom: parent.bottom
87             }
88             model:  stationListProxyModel
89             delegate: Item {
90                 id: listItem
91                 height: UiConstants.ListItemHeightSmall
92                 width: parent.width
93                 BorderImage {
94                     id: background
95                     anchors.fill: parent
96                     // Fill page borders
97                     visible: mouseArea.pressed
98                     source: "image://theme/meegotouch-list-fullwidth-background-pressed"
99                 }
100                 Row {
101                     anchors.fill: parent
102                     Item {
103                         width: UiConstants.DefaultMargin
104                         height: UiConstants.DefaultMargin
105                     }
106                     Column {
107                         anchors.verticalCenter: parent.verticalCenter
108
109                         Label {
110                             id: mainText
111                             text: Private.highlightSearch(model.display, UiConstants.AccentColor)
112                             font.bold: true
113                         }
114                     }
115                 }
116                 Image {
117                     anchors {
118                         left: parent.left
119                         right: parent.right
120                     }
121                     source: "image://theme/meegotouch-separator-background-horizontal"
122                 }
123                 MouseArea {
124                     id: mouseArea
125                     anchors.fill: background
126                     onClicked: {
127                         Private.loadStation(model.display)
128                     }
129                 }
130             }
131         }
132         ScrollDecorator {
133             id: decorator
134             flickableItem: stationListView
135         }
136     }
137
138     Sheet {
139         id: settingsSheet
140         acceptButtonText: qsTr("Save")
141         rejectButtonText: qsTr("Cancel")
142         content: Item {
143             x: 16
144             y: 16
145             width: parent.width - 32
146             height: parent.height - 32
147             Column {
148                 spacing: 16
149                 anchors.fill: parent
150                 Item {
151                     height: 40
152                     anchors.leftMargin: UiConstants.DefaultMargin
153                     anchors.left: parent.left
154                     anchors.right: parent.right
155                     Label {
156                         font.bold: true
157                         text: qsTr("Show Last Station on Startup")
158                         anchors.verticalCenter: parent.verticalCenter
159                         anchors.left: parent.left
160                     }
161                     Switch {
162                         anchors.verticalCenter: parent.verticalCenter
163                         id: showLastStationSwitch
164                         anchors.right: parent.right
165                     }
166                 }
167             }
168         }
169     }
170 }
171