Use the new code field to fetch the station schedule
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 22:15:36 +0000 (23:15 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 22:15:36 +0000 (23:15 +0100)
This completes the fix for bug #7003

application/resources/harmattan/qml/StationListPage.js
application/resources/harmattan/qml/StationListPage.qml
application/resources/harmattan/qml/StationPage.qml

index b5c4046..ac4a1c6 100644 (file)
@@ -11,13 +11,20 @@ function showAboutPage()
         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
index 1904340..21fda92 100644 (file)
@@ -103,9 +103,15 @@ Page {
 
                         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 {
@@ -119,7 +125,7 @@ Page {
                     id: mouseArea
                     anchors.fill: background
                     onClicked: {
-                        Private.loadStation(model.display)
+                        Private.loadStation(model.name, model.code)
                     }
                 }
             }
index d8d502a..0ed556b 100644 (file)
@@ -5,6 +5,7 @@ import "uiconstants.js" as UiConstants
 
 Page {
     property alias name: schedule.name
+    property alias code: schedule.code
 
     tools: ToolBarLayout {
         id: toolBar
@@ -99,13 +100,14 @@ Page {
     }
     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)
     }
 }