2 import Sailfish.Silica 1.0
3 import net.cirulla.quandoparte 1.0
12 function updateStation() {
13 view.state = "loading"
14 console.log("Updating station with " + schedule.name + ", " + schedule.code)
15 schedule.fetch(schedule.name, schedule.code)
20 text: qsTr("Update Schedule")
21 onClicked: view.updateStation()
24 text: (schedule.type === StationScheduleModel.ArrivalSchedule ?
25 qsTr("Show Departures") :
26 qsTr("Show Arrivals"))
27 onClicked: (schedule.type = schedule.type === StationScheduleModel.ArrivalSchedule ?
28 StationScheduleModel.DepartureSchedule :
29 StationScheduleModel.ArrivalSchedule)
32 text: (schedule.type === StationScheduleModel.DepartureSchedule ? qsTr("Departures") : qsTr("Arrivals"))
40 id: stationScheduleView
41 anchors.top: header.bottom
42 anchors.bottom: parent.bottom
46 cacheBuffer: 4 * Theme.itemSizeExtraLarge
48 delegate: StationScheduleDelegate {
49 width: stationScheduleView.width
51 arrivalTime: model.arrivalTime
52 departureTime: model.departureTime
54 arrivalStation: model.arrivalStation
55 departureStation: model.departureStation
57 actualPlatform: model.actualPlatform
58 expectedPlatfrom: model.expectedPlatform
61 enabled: stationScheduleView.count === 0
62 text: qsTr("No trains are scheduled at this time")
67 anchors.centerIn: parent
69 size: BusyIndicatorSize.Large
76 spacing: Theme.paddingLarge
78 textFormat: Text.StyledText
79 wrapMode: Text.WordWrap
80 text: "<p>" + qsTr("Error!") + "</p><p>" + schedule.error + "</p>"
82 font.pixelSize: Theme.fontSizeHuge
83 horizontalAlignment: Text.AlignHCenter
92 target: stationScheduleView
100 target: busyIndicator
107 target: stationScheduleView
115 target: busyIndicator
123 target: stationScheduleView
131 target: busyIndicator
138 StationScheduleModel {
140 onNameChanged: view.updateStation()
141 onLayoutChanged: if (error) view.state = "error"
142 else view.state = "ready"
147 // onNameChanged: view.updateStation()
148 onLayoutChanged: if (schedule.error) view.state = "error"
149 else view.state = "ready"
151 Component.onCompleted: {
152 updateTimer.triggered.connect(view.updateStation)
153 view.state = "loading"
155 VerticalScrollDecorator {}