2 import com.nokia.meego 1.0
3 import "UIConstants.js" as UIConstants
4 import "ExtrasConstants.js" as ExtrasConstants
9 property bool canRefresh: realtimeResult.sourceUrl != ''
12 realtimeResult.refresh()
22 horizontalCenter: parent.horizontalCenter
28 titleText: 'Select line'
33 Component.onCompleted: {
34 var lines = itip.get_lines()
36 for (var idx in lines) {
37 lineSelectorModel.append({'name': lines[idx]})
42 // XXX It would be nice if we could make a delegate with
43 // icons (i.e. U1, U2, ... in the right colors), but we
44 // would have to "copy" the default delegate style
47 console.log('accepted: ' + selectedIndex)
48 gline.text = lineSelectorModel.get(selectedIndex).name
53 placeholderText: 'Line'
62 right: lineSearchButton.left
66 // TODO: Check if text matches an item in lineSelectorModel and
67 // set selectedIndex in lineSelector to the right item
70 if (lineSelector.selectedIndex == -1) {
74 // Disable selection in line selector if user changes the text
75 if (lineSelectorModel.get(lineSelector.selectedIndex).name != text) {
76 lineSelector.selectedIndex = -1
85 drag.maximumY: parent.height
100 iconSource: 'image://theme/icon-m-common-search'
102 onClicked: lineSelector.open()
106 placeholderText: 'Station'
112 right: stationPickerButton.left
115 rightMargin: 10*stationPickerButton.opacity
121 property string currentLine: ''
122 property string currentDirection: ''
123 property string currentStation: ''
125 acceptButtonText: 'Select'
126 rejectButtonText: 'Cancel'
128 function loadData(lineName) {
129 stationSheet.currentLine = lineName
131 directionChooser.direction1 = ''
132 directionChooser.direction2 = ''
134 directionChooserBusyIndicator.running = true
135 itip.load_directions(stationSheet.currentLine)
137 firstDirection.clicked()
138 directionChooser.checkedButton = firstDirection
144 onDirectionsLoaded: {
145 directionChooserBusyIndicator.running = false
147 directionChooser.direction1 = itip.get_direction(0)
148 directionChooser.direction2 = itip.get_direction(1)
150 firstDirection.clicked()
151 directionChooser.checkedButton = firstDirection
160 property string direction1
161 property string direction2
163 visible: !directionChooserBusyIndicator.running
165 function chosen(idx) {
166 console.log('direction chosen: '+ idx)
168 stationSelectorListView.selectedIndex = -1
171 stationSheet.currentDirection = directionChooser.direction1
173 stationSheet.currentDirection = directionChooser.direction2
176 directionChooserModel.clear()
177 var stations = itip.get_stations(stationSheet.currentLine, stationSheet.currentDirection)
179 for (var s in stations) {
180 directionChooserModel.append({'station': stations[s]})
193 text: 'Richtung ' + directionChooser.direction1
194 onClicked: directionChooser.chosen(1)
199 text: 'Richtung ' + directionChooser.direction2
200 onClicked: directionChooser.chosen(2)
205 id: stationSelectorListView
206 visible: !directionChooserBusyIndicator.running
208 property int selectedIndex: -1
209 onSelectedIndexChanged: {
210 console.log('current index: ' + selectedIndex)
211 if (selectedIndex != -1) {
212 stationSheet.currentStation = directionChooserModel.get(selectedIndex).station
214 stationSheet.currentStation = ''
220 top: directionChooser.bottom
223 bottom: parent.bottom
229 id: directionChooserModel
232 delegate: StationListItem { selector: stationSelectorListView }
236 flickableItem: stationSelectorListView
240 id: directionChooserBusyIndicator
241 anchors.centerIn: parent
243 platformStyle: BusyIndicatorStyle { size: 'large' }
248 gstation.text = stationSheet.currentStation
250 realtimeResult.gline = stationSheet.currentLine
251 realtimeResult.gstation = stationSheet.currentStation
252 realtimeResult.gdirection = stationSheet.currentDirection
254 realtimeResult.sourceUrl = itip.get_directions_url(stationSheet.currentLine, stationSheet.currentDirection, stationSheet.currentStation)
255 console.log('url to get: ' + realtimeResult.sourceUrl)
261 id: stationPickerButton
265 bottom: gstation.bottom
270 Behavior on opacity { PropertyAnimation { } }
272 opacity: gline.text != '' // XXX: Check if the line is valid
274 width: lineSearchButton.width * opacity
275 //iconSource: 'image://theme/icon-m-common-location-picker'
276 iconSource: 'image://theme/icon-m-toolbar-list'
280 stationSheet.loadData(gline.text)
291 bottom: parent.bottom
297 gline: stationSheet.currentLine
298 gstation: stationSheet.currentStation
299 gdirection: stationSheet.currentDirection
301 sourceUrl: stationSheet.currentUrl