2 import Sailfish.Silica 1.0
3 import net.cirulla.quandoparte 1.0
7 property alias name: schedule.name
8 property alias code: schedule.code
15 function updateStation() {
16 view.state = "loading"
17 console.log("Updating station with " + schedule.name + ", " + schedule.code)
18 schedule.fetch(schedule.name, schedule.code)
23 text: qsTr("Update Schedule")
24 onClicked: view.updateStation()
27 text: (schedule.type === StationScheduleModel.ArrivalSchedule ?
28 qsTr("Show Departures") :
29 qsTr("Show Arrivals"))
30 onClicked: (schedule.type = schedule.type === StationScheduleModel.ArrivalSchedule ?
31 StationScheduleModel.DepartureSchedule :
32 StationScheduleModel.ArrivalSchedule)
35 text: (schedule.type === StationScheduleModel.DepartureSchedule ? qsTr("Departures") : qsTr("Arrivals"))
43 id: stationScheduleView
44 anchors.top: header.bottom
45 anchors.bottom: parent.bottom
49 cacheBuffer: 4 * Theme.itemSizeExtraLarge
51 delegate: StationScheduleDelegate {
52 width: stationScheduleView.width
54 arrivalTime: model.arrivalTime
55 departureTime: model.departureTime
57 arrivalStation: model.arrivalStation
58 departureStation: model.departureStation
60 actualPlatform: model.actualPlatform
61 expectedPlatfrom: model.expectedPlatform
64 enabled: stationScheduleView.count === 0
65 text: qsTr("No trains are scheduled at this time")
70 anchors.centerIn: parent
72 size: BusyIndicatorSize.Large
79 spacing: Theme.paddingLarge
81 textFormat: Text.StyledText
82 wrapMode: Text.WordWrap
83 text: "<p>" + qsTr("Error!") + "</p><p>" + schedule.error + "</p>"
85 font.pixelSize: Theme.fontSizeHuge
86 horizontalAlignment: Text.AlignHCenter
95 target: stationScheduleView
103 target: busyIndicator
110 target: stationScheduleView
118 target: busyIndicator
126 target: stationScheduleView
134 target: busyIndicator
140 StationScheduleModel {
142 onNameChanged: view.updateStation()
143 onLayoutChanged: if (error) view.state = "error"
144 else view.state = "ready"
147 Component.onCompleted: {
148 updateTimer.triggered.connect(view.updateStation)
149 view.state = "loading"
151 VerticalScrollDecorator {}