Add active cover
authorLuciano Montanaro <mikelima@cirulla.net>
Tue, 31 Dec 2013 15:49:16 +0000 (16:49 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 31 Dec 2013 15:49:16 +0000 (16:49 +0100)
Reqorked the QML to show the first schedules on the application cover.
Had to move a few things around as well.

application/resources/sailfish/qml/cover/CoverPage.qml
application/resources/sailfish/qml/main.qml
application/resources/sailfish/qml/pages/StationListPage.js
application/resources/sailfish/qml/pages/StationPage.qml

index 0ef61ab..0dda240 100644 (file)
@@ -1,12 +1,31 @@
 import QtQuick 2.0
 import Sailfish.Silica 1.0
+import net.cirulla.quandoparte 1.0
+import "../pages/components"
 
 CoverBackground {
     CoverPlaceholder {
-        anchors.centerIn: parent
+        anchors.fill: parent
         text: qsTr("Quando Parte")
         icon.source: "/usr/share/icons/hicolor/86x86/apps/quandoparte.png"
+       visible: stationScheduleView.count === 0
+    }
+    SilicaListView {
+        id: stationScheduleView
+       anchors.fill: parent
+        model: schedule
+        delegate: StationScheduleDelegate {
+            width: stationScheduleView.width
+            compact: true
+            type: schedule.type
+            arrivalTime: model.arrivalTime
+            departureTime: model.departureTime
+            train: model.train
+            arrivalStation: model.arrivalStation
+            departureStation: model.departureStation
+            delay: model.delay
+            actualPlatform: model.actualPlatform
+            expectedPlatfrom: model.expectedPlatform
+        }
     }
 }
-
-
index 3463613..baa9b19 100644 (file)
@@ -1,5 +1,6 @@
 import QtQuick 2.0
 import Sailfish.Silica 1.0
+import net.cirulla.quandoparte 1.0
 import "pages"
 
 ApplicationWindow {
@@ -10,4 +11,7 @@ ApplicationWindow {
         id: updateTimer
         interval: 120
     }
+    StationScheduleModel {
+        id: schedule
+    }
 }
index 7a06bc2..306c3c7 100644 (file)
@@ -19,13 +19,10 @@ function loadStation(name, code)
         stationListPage.stationView = view
         pageStack.push(view)
 
-        /*
-            XXX Ugliness ahead! Changing the name triggers the station
-            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
+        if (code === undefined) {
+            code = ""
+        }
+        schedule.fetch(name, code)
     }
     else
         console.log('Cannot load component: ' + component.errorString());
index 18fc8e1..a892462 100644 (file)
@@ -4,9 +4,6 @@ import net.cirulla.quandoparte 1.0
 import "components"
 
 Page {
-    property alias name: schedule.name
-    property alias code: schedule.code
-
     SilicaFlickable {
         id: view
         pressDelay: 0
@@ -37,7 +34,7 @@ Page {
         }
         PageHeader {
             id: header
-            title: name
+            title: schedule.name
         }
         SilicaListView {
             id: stationScheduleView
@@ -104,7 +101,7 @@ Page {
                     visible: true
                 }
             },
-            State {
+            State  {
                 name: "ready"
                 PropertyChanges {
                     target: stationScheduleView
@@ -137,13 +134,20 @@ Page {
             }
         ]
 
+        /*
         StationScheduleModel {
             id: schedule
             onNameChanged: view.updateStation()
             onLayoutChanged: if (error) view.state = "error"
                              else view.state = "ready"
         }
-
+        */
+        Connections {
+            target: schedule
+            // onNameChanged: view.updateStation()
+            onLayoutChanged: if (schedule.error) view.state = "error"
+                             else view.state = "ready"
+        }
         Component.onCompleted: {
             updateTimer.triggered.connect(view.updateStation)
             view.state = "loading"