2 import com.nokia.meego 1.0
3 import QtMobility.location 1.1
5 import "UIConstants.js" as UIConstants
6 import "ExtrasConstants.js" as ExtrasConstants
10 orientationLock: PageOrientation.LockPortrait
12 property bool canRefresh: realtimeResult.sourceUrl != '' || (realtimeResult.isStation && realtimeResult.gstation != '')
13 //property alias stationSelect: stationSelector
14 property variant nearbyStations
16 function showFavorites() {
17 favSelector.model.clear();
18 for (var i=0; i<favManager.getCount(); i++) {
19 var data = eval('(' + favManager.getItem(i) + ')');
20 favSelector.model.append(data);
22 favSelector.model.sync();
27 lineSearchButton.clicked()
31 realtimeResult.refresh()
34 function fillNearbyStations(lat, lon) {
35 nearbyStations = itip.get_nearby_stations(lat, lon)
38 function showNearby() {
39 console.log("show nearby")
41 var stations = nearbyStations;
42 stationSelectorModel.clear();
43 for (var idx in stations) {
44 stationSelectorModel.append({'name': stations[idx]});
47 stationSelector.open();
51 visible: !parent.canRefresh
52 anchors.centerIn: parent
54 text: '<p><strong>Welcome, traveller!<br></strong></p><p>Press <img src="image://theme/icon-m-toolbar-search"> to search for<br>departure information.</p><p>Press <img src="image://theme/icon-m-toolbar-view-menu"> for nearby stations.<br></p><p><strong>Have a safe journey.</strong></p>'
71 GradientStop { position: 0; color: '#777' }
72 GradientStop { position: 1; color: '#aaa' }
83 verticalCenter: parent.verticalCenter
91 property int increaseMeGently: 0
93 verticalCenter: parent.verticalCenter
98 if (favManager.isFavorite(realtimeResult.gline, realtimeResult.gdirection, realtimeResult.gstation, realtimeResult.sourceUrl, realtimeResult.isStation, increaseMeGently)) {
99 'icon-m-toolbar-favorite-mark'
101 'icon-m-toolbar-favorite-unmark'
105 favManager.toggleFavorite(realtimeResult.gline, realtimeResult.gdirection, realtimeResult.gstation, realtimeResult.sourceUrl, realtimeResult.isStation);
106 increaseMeGently = increaseMeGently + 1;
113 updateInterval: 10000
118 fillNearbyStations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude)
124 titleText: 'Select nearby station'
127 id: stationSelectorModel
131 realtimeResult.isStation = true
132 realtimeResult.gline = ''
133 realtimeResult.sourceUrl = ''
135 gstation.text = stationSelectorModel.get(selectedIndex).name
136 realtimeResult.gstation = stationSelectorModel.get(selectedIndex).name
137 console.log('station to get: ' + realtimeResult.gstation)
143 placeholderText: 'Line'
152 right: lineSearchButton.left
162 drag.axis: Drag.YAxis
164 drag.maximumY: parent.height
171 gline.text = currentLine
173 /* We usually want to select a station after selecting a line */
174 stationPickerButton.clicked()
190 iconSource: 'image://theme/icon-m-common-search'
193 lineSheet.currentLine = ''
199 placeholderText: 'Station'
206 right: stationPickerButton.left
209 rightMargin: 10*stationPickerButton.opacity
216 gstation.text = stationSheet.currentStation
218 realtimeResult.gline = stationSheet.currentLine
219 realtimeResult.gdirection = stationSheet.currentDirection
220 realtimeResult.isStation = false
221 realtimeResult.sourceUrl = itip.get_directions_url(stationSheet.currentLine, stationSheet.currentDirection, stationSheet.currentStation)
222 realtimeResult.gstation = stationSheet.currentStation
224 console.debug('url to get: ' + realtimeResult.sourceUrl)
225 realtimeResult.refresh()
230 id: stationPickerButton
234 bottom: gstation.bottom
241 width: lineSearchButton.width * opacity
242 //iconSource: 'image://theme/icon-m-common-location-picker'
243 iconSource: 'image://theme/icon-m-toolbar-list'
247 stationSheet.loadData(gline.text)
258 bottom: parent.bottom
264 gline: stationSheet.currentLine
265 gstation: stationSheet.currentStation
266 gdirection: stationSheet.currentDirection
268 sourceUrl: stationSheet.currentUrl
273 titleText: 'Your favorites'
278 realtimeResult.isStation = model.get(selectedIndex).isstation
279 realtimeResult.gline = model.get(selectedIndex).gline
280 realtimeResult.gdirection = model.get(selectedIndex).gdirection
281 realtimeResult.sourceUrl = model.get(selectedIndex).sourceurl
282 realtimeResult.gstation = model.get(selectedIndex).gstation
283 realtimeResult.refresh()