Removed test ListModel
[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
5 Page {
6     property variant stationView
7     id: stationListPage
8     tools: ToolBarLayout {
9         id: toolBar
10         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
11         ToolIcon { iconId: "icon-m-toolbar-settings"; onClicked: settingsSheet.open(); }
12         ToolIcon { iconId: "icon-m-toolbar-view-menu"; }
13     }
14
15     function loadStation()
16     {
17         var component = Qt.createComponent("StationPage.qml");
18         if (component.status == Component.Ready) {
19             var view = component.createObject(stationListPage)
20             stationListPage.stationView = view
21             pageStack.push(view)
22             view.html = "<h1>Hello World</h1><p>Lorem ipsum</p>"
23         }
24         else
25             console.log('Cannot load component: ' + component.errorString());
26     }
27
28     function highlightSearch(s)
29     {
30         return s.replace(searchField.text,
31                          '<span style="text-decoration:underline">' +
32                          searchField.text + '</span>')
33     }
34
35     Column {
36         width: parent.width
37         height: parent.height
38         TextField {
39             id: searchField
40             width: parent.width
41             placeholderText: "Search..."
42             platformStyle: TextFieldStyle { paddingRight: clearButton.width }
43             onTextChanged: {
44             }
45             Image {
46                 id: clearButton
47                 anchors.right: parent.right
48                 anchors.verticalCenter: parent.verticalCenter
49                 source: "image://theme/icon-m-input-clear"
50                 MouseArea {
51                     anchors.fill: parent
52                     onClicked: {
53                         inputContext.reset()
54                         searchField.text = ""
55                     }
56                 }
57             }
58         }
59         Rectangle {
60             height: 16
61         }
62         ListView {
63             id: stationListView
64             clip: true
65             width: parent.width
66             height: parent.height
67             model:  stationListProxyModel
68             delegate: Item {
69                 id: listItem
70                 height: 48
71                 width: parent.width
72                 BorderImage {
73                     id: background
74                     anchors.fill: parent
75                     // Fill page borders
76                     visible: mouseArea.pressed
77                     source: "image://theme/meegotouch-list-background-pressed-center"
78                 }
79                 Row {
80                     anchors.fill: parent
81
82                     Column {
83                         anchors.verticalCenter: parent.verticalCenter
84
85                         Label {
86                             id: mainText
87                             text: highlightSearch(model.display)
88                             font.bold: true
89                         }
90                     }
91                 }
92                 MouseArea {
93                     id: mouseArea
94                     anchors.fill: background
95                     onClicked: {
96                         stationListPage.loadStation(model.display)
97                     }
98                 }
99             }
100         }
101     }
102
103     Sheet {
104         id: settingsSheet
105         acceptButtonText: "Save"
106         rejectButtonText: "Cancel"
107         content: Item {
108             x: 16
109             y: 16
110             width: parent.width - 32
111             height: parent.height - 32
112             Column {
113                 spacing: 16
114                 anchors.fill: parent
115                 Row {
116                     height: 40
117                     spacing: 16
118                     anchors.left: parent.left
119                     anchors.right: parent.right
120                     Label {
121                         font.bold: true
122                         text: "Show Last Station on Startup"
123                         anchors.verticalCenter: parent.verticalCenter
124                     }
125                     Switch {
126                         anchors.verticalCenter: parent.verticalCenter
127                         id: showLastStationSwitch
128                         anchors.right: parent.right
129                     }
130                 }
131                 Row {
132                     height: 40
133                     spacing: 16
134                     anchors.left: parent.left
135                     anchors.right: parent.right
136                     Label {
137                         font.bold: true
138                         text: "Update Display Periodically"
139                         anchors.verticalCenter: parent.verticalCenter
140                     }
141                     Switch {
142                         anchors.verticalCenter: parent.verticalCenter
143                         anchors.right: parent.right
144                         id: periodicCheckSwitch
145                     }
146                 }
147             }
148         }
149     }
150 }
151