From e0600543c2c0a0e28e91d86df2e7642df9fd9d40 Mon Sep 17 00:00:00 2001 From: Luciano Montanaro Date: Tue, 31 Dec 2013 16:49:16 +0100 Subject: [PATCH] Add active cover Reqorked the QML to show the first schedules on the application cover. Had to move a few things around as well. --- .../resources/sailfish/qml/cover/CoverPage.qml | 25 +++++++++++++++++--- application/resources/sailfish/qml/main.qml | 4 ++++ .../sailfish/qml/pages/StationListPage.js | 11 ++++----- .../resources/sailfish/qml/pages/StationPage.qml | 16 ++++++++----- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/application/resources/sailfish/qml/cover/CoverPage.qml b/application/resources/sailfish/qml/cover/CoverPage.qml index 0ef61ab..0dda240 100644 --- a/application/resources/sailfish/qml/cover/CoverPage.qml +++ b/application/resources/sailfish/qml/cover/CoverPage.qml @@ -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 + } } } - - diff --git a/application/resources/sailfish/qml/main.qml b/application/resources/sailfish/qml/main.qml index 3463613..baa9b19 100644 --- a/application/resources/sailfish/qml/main.qml +++ b/application/resources/sailfish/qml/main.qml @@ -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 + } } diff --git a/application/resources/sailfish/qml/pages/StationListPage.js b/application/resources/sailfish/qml/pages/StationListPage.js index 7a06bc2..306c3c7 100644 --- a/application/resources/sailfish/qml/pages/StationListPage.js +++ b/application/resources/sailfish/qml/pages/StationListPage.js @@ -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()); diff --git a/application/resources/sailfish/qml/pages/StationPage.qml b/application/resources/sailfish/qml/pages/StationPage.qml index 18fc8e1..a892462 100644 --- a/application/resources/sailfish/qml/pages/StationPage.qml +++ b/application/resources/sailfish/qml/pages/StationPage.qml @@ -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" -- 1.7.9.5