7bcc5f9231ec731703d00fd285296ed3711a22d0
[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                     onCheckedChanged: settings.autoUpdate = checked
29                 }
30             }
31             MenuItem {
32                 text: qsTr("About Quando Parte")
33                 onClicked: Private.showAboutPage()
34             }
35             Component.onCompleted: periodicCheckSwitch.checked = settings.autoUpdate
36         }
37     }
38     PageHeader {
39         id: header
40         anchors.top: parent.top
41         selectedIndex: stationListProxyModel.sortingMode
42         options: ListModel {
43             id: dialogOptions
44             ListElement {
45                 name: QT_TR_NOOP("Stations by Name")
46             }
47             ListElement {
48                 name: QT_TR_NOOP("Stations by Distance")
49             }
50             ListElement {
51                 name: QT_TR_NOOP("Stations Recently Seen")
52             }
53         }
54     }
55     SearchBar {
56         id: searchField
57         anchors.top: header.bottom
58         visible: false
59     }
60     Binding {
61         target: stationListProxyModel
62         property: "searchPattern"
63         value: searchField.text
64     }
65     Binding {
66         target: stationListProxyModel
67         property: "sortingMode"
68         value: header.selectedIndex
69     }
70     Item {
71         id: mainView
72         anchors {
73             top: searchField.bottom
74             bottom: parent.bottom
75             left: parent.left
76             right: parent.right
77         }
78         DroppedShadow {
79             id: shadow
80             anchors.top: mainView.top
81         }
82         ListView {
83             id: stationListView
84             clip: true
85             width: parent.width
86             anchors {
87                 top: shadow.top
88                 bottom: parent.bottom
89             }
90             model:  stationListProxyModel
91             delegate: Item {
92                 id: listItem
93                 height: UiConstants.ListItemHeightSmall
94                 width: parent.width
95                 BorderImage {
96                     id: background
97                     anchors.fill: parent
98                     // Fill page borders
99                     visible: mouseArea.pressed
100                     source: "image://theme/meegotouch-list-fullwidth-background-pressed"
101                 }
102                 Row {
103                     anchors.fill: parent
104                     Item {
105                         width: UiConstants.DefaultMargin
106                         height: UiConstants.DefaultMargin
107                     }
108                     Column {
109                         anchors.verticalCenter: parent.verticalCenter
110
111                         Label {
112                             id: mainText
113                             text: Private.highlightSearch(model.display, UiConstants.AccentColor)
114                             font.bold: true
115                         }
116                     }
117                 }
118                 Image {
119                     anchors {
120                         left: parent.left
121                         right: parent.right
122                     }
123                     source: "image://theme/meegotouch-separator-background-horizontal"
124                 }
125                 MouseArea {
126                     id: mouseArea
127                     anchors.fill: background
128                     onClicked: {
129                         Private.loadStation(model.display)
130                     }
131                 }
132             }
133         }
134         ScrollDecorator {
135             id: decorator
136             flickableItem: stationListView
137         }
138     }
139 }
140