(www) Update index 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 {
14             iconId: "icon-m-toolbar-search" + (theme.inverted ? "-white": "")
15             onClicked: searchField.open = !searchField.open
16         }
17         ToolIcon {
18             iconId: "icon-m-toolbar-view-menu" + (theme.inverted ? "-white": "")
19             onClicked: menu.open()
20         }
21     }
22     Menu {
23         id: menu
24         content: MenuLayout {
25             MenuItem {
26                 text: qsTr("Update Periodically")
27                 Switch {
28                     id: periodicCheckSwitch
29                     anchors {
30                         verticalCenter: parent.verticalCenter
31                         right: parent.right
32                         rightMargin: UiConstants.DefaultMargin
33                     }
34                     checked: settings.autoUpdate
35                     onCheckedChanged: settings.autoUpdate = checked
36                 }
37             }
38             MenuItem {
39                 text: qsTr("Use Dark Theme")
40                 Switch {
41                     id: darkThemeSwitchSwitch
42                     anchors {
43                         verticalCenter: parent.verticalCenter
44                         right: parent.right
45                         rightMargin: UiConstants.DefaultMargin
46                     }
47                     checked: settings.darkThemePreferred
48                     onCheckedChanged: {
49                         settings.darkThemePreferred = checked
50                         theme.inverted = checked
51                     }
52                 }
53             }
54             MenuItem {
55                 text: qsTr("About Quando Parte")
56                 onClicked: Private.showAboutPage()
57             }
58             Component.onCompleted: periodicCheckSwitch.checked = settings.autoUpdate
59         }
60     }
61     PageHeader {
62         id: header
63         anchors.top: parent.top
64         selectedIndex: stationListProxyModel.sortingMode
65         options: [
66             qsTr("Stations by Name"),
67             qsTr("Stations by Distance"),
68             qsTr("Stations Recently Seen")
69         ]
70     }
71     SearchBar {
72         id: searchField
73         anchors.top: header.bottom
74         open: false
75     }
76     Binding {
77         target: stationListProxyModel
78         property: "searchPattern"
79         value: searchField.text
80     }
81     Binding {
82         target: stationListProxyModel
83         property: "sortingMode"
84         value: header.selectedIndex
85     }
86     Item {
87         id: mainView
88         anchors {
89             top: searchField.bottom
90             bottom: parent.bottom
91             left: parent.left
92             right: parent.right
93         }
94         DroppedShadow {
95             id: shadow
96             anchors.top: mainView.top
97         }
98         ListView {
99             id: stationListView
100             clip: true
101             width: parent.width
102             cacheBuffer: 10
103             anchors {
104                 top: shadow.top
105                 bottom: parent.bottom
106             }
107             model:  stationListProxyModel
108             delegate: Item {
109                 id: listItem
110                 height: UiConstants.ListItemHeightSmall
111                 width: parent.width
112                 BorderImage {
113                     id: background
114                     anchors.fill: parent
115                     // Fill page borders
116                     visible: mouseArea.pressed
117                     source: "image://theme/meegotouch-list-fullwidth-" + (theme.inverted ? "inverted-" : "") + "background-pressed"
118                 }
119                 Row {
120                     anchors.fill: parent
121                     Item {
122                         width: UiConstants.DefaultMargin
123                         height: UiConstants.DefaultMargin
124                     }
125                     Column {
126                         anchors.verticalCenter: parent.verticalCenter
127
128                         Label {
129                             id: mainText
130                             text: Private.highlightSearch(model.name, UiConstants.AccentColor)
131                             font.bold: true
132                         }
133                     }
134                 }
135                 Image {
136                     anchors {
137                         left: parent.left
138                         right: parent.right
139                     }
140                     source: "image://theme/meegotouch-separator-" + (theme.inverted ? "inverted-" : "") + "background-horizontal"
141                 }
142                 MouseArea {
143                     id: mouseArea
144                     anchors.fill: background
145                     onClicked: {
146                         Private.loadStation(model.name, model.code)
147                     }
148                 }
149             }
150         }
151         ScrollDecorator {
152             id: decorator
153             flickableItem: stationListView
154         }
155     }
156 }