console.log('Cannot load component: ' + component.errorString());
}
-function loadStation(name)
+function loadStation(name, code)
{
var component = Qt.createComponent("StationPage.qml");
if (component.status === Component.Ready) {
view = component.createObject(stationListPage)
stationListPage.stationView = view
pageStack.push(view)
+
+ /*
+ XXX Ugliness ahead! Changing the name triggers the station
+ to schedule to be fetched. So any extra data (the code specifically)
+ must be set before changing the name.
+ */
+ if (code !== undefined) view.code = code
view.name = name
}
else
Label {
id: mainText
- text: Private.highlightSearch(model.display, UiConstants.AccentColor)
+ text: Private.highlightSearch(model.name, UiConstants.AccentColor)
font.bold: true
}
+ Label {
+ id: subText
+ text: (model.code !== undefined) ? model.code : "none"
+ font.bold: UiConstants.SubtitleFontBoldness
+ font.pixelSize: UiConstants.SubtitleFontPixelSize
+ }
}
}
Image {
id: mouseArea
anchors.fill: background
onClicked: {
- Private.loadStation(model.display)
+ Private.loadStation(model.name, model.code)
}
}
}
Page {
property alias name: schedule.name
+ property alias code: schedule.code
tools: ToolBarLayout {
id: toolBar
}
StationScheduleModel {
id: schedule
- onNameChanged: schedule.fetch(name)
+ onNameChanged: updateStation()
onLayoutChanged: view.state = "ready"
}
Component.onCompleted: {
updateTimer.timeout.connect(updateStation)
}
function updateStation() {
- schedule.fetch(schedule.name)
+ console.log("Updating station with " + schedule.name + ", " + schedule.code)
+ schedule.fetch(schedule.name, schedule.code)
}
}