property string sourceUrl: ''
property bool busy: true
+ property bool isStation: false
function refresh() {
busy = true
- itip.load_departures(sourceUrl)
- console.log('refreshing')
+ console.debug('refreshing')
+
+ if (isStation) {
+ console.debug('station based')
+ itip.load_station_departures(gstation)
+ } else {
+ console.debug('one line')
+ itip.load_departures(sourceUrl)
+ }
+ }
+
+ function isCorrectInput () {
+ return resultRealtime.sourceUrl != '' || (resultRealtime.isStation && resultRealtime.gstation != '')
}
- onSourceUrlChanged: {
+ onGstationChanged: {
+ console.debug('gstation changed')
refresh()
- console.log('source url changed: ' + sourceUrl)
}
Connections {
onDeparturesLoaded: {
busy = false
- departuresModel.clear()
-
- var departures = itip.get_departures()
-
- for (var d in departures) {
- console.log('time: ' + departures[d].time)
- var row = {'line': departures[d].line, 'station': departures[d].station, 'destination': departures[d].direction, 'departure': departures[d].time, 'lowfloor': departures[d].lowfloor}
- departuresModel.append(row)
- }
}
}
spacing: 10
Text {
id: l
- text: line // <----
+ text: model.line // <----
anchors.verticalCenter: parent.verticalCenter
//width: 70
font.pixelSize: UIConstants.FONT_XLARGE
Text {
id: s
- text: station // <----
+ text: model.station // <----
width: parent.parent.parent.width - l.width - dep.width - 15
elide: Text.ElideRight
font.pixelSize: UIConstants.FONT_LARGE
Text {
id: d
- text: destination // <----
+ text: model.direction // <--- -
width: parent.parent.parent.width - l.width - dep.width - 15
elide: Text.ElideRight
color: !theme.inverted ? UIConstants.COLOR_SECONDARY_FOREGROUND : UIConstants.COLOR_INVERTED_SECONDARY_FOREGROUND
Text {
id: dep
// FIXME strange int float transformation appears
- text: departure
+ text: model.time
anchors.right: parent.right
anchors.rightMargin: UIConstants.DEFAULT_MARGIN
- font.italic: lowfloor == 1
+ font.italic: lowfloor
font.bold: true
font.pixelSize: UIConstants.FONT_XLARGE
font.family: ExtrasConstants.FONT_FAMILY_LIGHT
smooth: true
Text {
+ id: header
+
anchors {
top: parent.top
left: parent.left
}
}
- model: ListModel {
- id: departuresModel
- }
+ model: resultModel
delegate: departureDelegate
- visible: !resultRealtime.busy && resultRealtime.sourceUrl != ''
+ visible: !resultRealtime.busy && isCorrectInput()
}
ScrollDecorator {
BusyIndicator {
id: busyIndicator
- visible: resultRealtime.busy && resultRealtime.sourceUrl != ''
+ visible: resultRealtime.busy && isCorrectInput()
running: visible
platformStyle: BusyIndicatorStyle { size: 'large' }
anchors.centerIn: parent