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