382c7ca95f73bb9afe7a65ccd84613a3b20942ec
[quandoparte] / application / resources / sailfish / qml / pages / StationListPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import net.cirulla.quandoparte 1.0
4 import "StationListPage.js" as Private
5
6 Page {
7     id: stationListPage
8     property variant stationView
9     property string searchPattern
10     Binding {
11         target: stationListProxyModel
12         property: "searchPattern"
13         value: stationListPage.searchPattern
14     }
15     SilicaListView {
16         id: stationListView
17         clip: true
18         width: parent.width
19         cacheBuffer: 10
20         anchors.top: parent.top
21         anchors.bottom: parent.bottom
22         model:  stationListProxyModel
23         PullDownMenu {
24             MenuItem {
25                 text: qsTr("About Quando Parte")
26                 onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
27             }
28             MenuItem {
29                 text: qsTr("Stations by Name")
30                 onClicked: stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
31             }
32             MenuItem {
33                 text: qsTr("Stations by Distance")
34                 onClicked: stationListProxyModel.sortingMode = StationListProxyModel.DistanceSorting
35             }
36             MenuItem {
37                 text: qsTr("Stations Recently Seen")
38                 onClicked: stationListProxyModel.sortingMode = StationListProxyModel.RecentUsageSorting
39             }
40         }
41         header: SearchField {
42             id: searchField
43             placeholderText: qsTr("Search station...")
44             onTextChanged: stationListPage.searchPattern = searchField.text
45             width: stationListPage.width
46         }
47         delegate: BackgroundItem {
48             id: listItem
49             height: Theme.itemSizeSmall
50             width: parent.width
51             Label {
52                 id: mainText
53                 anchors {
54                     verticalCenter: parent.Center
55                     margins: Theme.paddingMedium
56                 }
57                 x: Theme.paddingLarge
58                 textFormat: Text.StyledText
59                 text: model.name ? Private.highlightSearch(model.name, Theme.highlightColor) : ""
60             }
61             onClicked: Private.loadStation(model.name, model.code)
62         }
63         section {
64             criteria: ViewSection.FirstCharacter
65             delegate: BackgroundItem {
66                 height: Theme.itemSizeSmall
67                 width: parent.width
68                 Label {
69                     id: sectionLabel
70                     text: section
71                 }
72             }
73         }
74     }
75 }