Refactored StationScheduleDelegate to its own file.
[quandoparte] / application / resources / harmattan / qml / StationPage.qml
index 48c33e7..5fe1e60 100644 (file)
@@ -1,5 +1,4 @@
 import QtQuick 1.1
-import QtWebKit 1.0
 import com.nokia.meego 1.0
 import net.cirulla.quandoparte 1.0
 import "uiconstants.js" as UiConstants
@@ -9,22 +8,17 @@ Page {
 
     tools: ToolBarLayout {
         id: toolBar
-        ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
-        ToolIcon { iconId: "icon-m-toolbar-view-menu"; }
+        ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop() }
+        ToolIcon { iconId: "icon-m-toolbar-view-menu"; onClicked: menu.open() }
     }
     PageHeader {
         id: header
         anchors.top: parent.top
         selectedIndex: schedule.type
-        options: ListModel {
-            id: dialogOptions
-            ListElement {
-                name: QT_TR_NOOP("Departures")
-            }
-            ListElement {
-                name: QT_TR_NOOP("Arrivals")
-            }
-        }
+        options: [
+            qsTr("Departures"),
+            qsTr("Arrivals")
+        ]
     }
     InfoBar {
         id: infoBar
@@ -60,83 +54,17 @@ Page {
                 top: shadow.top
                 bottom: parent.bottom
             }
-            model:  schedule
-            delegate: Item {
-                id: listItem
-                height: UiConstants.ListItemHeightDefault
-                width: parent.width
-                BorderImage {
-                    id: background
-                    anchors.fill: parent
-                    // Fill page borders
-                    visible: mouseArea.pressed
-                    source: "image://theme/meegotouch-list-background-pressed-center"
-                }
-                Row {
-                    anchors.fill: parent
-
-                    spacing: UiConstants.ButtonSpacing
-                    Column {
-                        anchors.verticalCenter: parent.verticalCenter
-                        Row {
-                            spacing: UiConstants.ButtonSpacing
-                            Label {
-                                text: arrivalTime
-                                font.bold: UiConstants.SpecialFontBoldness
-                                font.pixelSize: UiConstants.SpecialFontPixelSize
-                                visible: schedule.type === StationScheduleModel.ArrivalSchedule
-                            }
-                            Label {
-                                text: departureTime
-                                font.bold: UiConstants.SpecialFontBoldness
-                                font.pixelSize: UiConstants.SpecialFontPixelSize
-                                visible: schedule.type === StationScheduleModel.DepartureSchedule
-                            }
-                            Label {
-                                text: train
-                                font.bold: UiConstants.SpecialFontBoldness
-                                font.pixelSize: UiConstants.SpecialFontPixelSize
-                                color: UiConstants.AccentColor
-                            }
-                        }
-                        Label {
-                            text: qsTr("from ") + arrivalStation
-                            font.bold: UiConstants.DefaultFontBoldness
-                            font.pixelSize: UiConstants.DefaultFontPixelSize
-                            visible: schedule.type === StationScheduleModel.ArrivalSchedule
-                        }
-                        Label {
-                            text: qsTr("to ") + departureStation
-                            font.bold: UiConstants.DefaultFontBoldness
-                            font.pixelSize: UiConstants.DefaultFontPixelSize
-                            visible: schedule.type === StationScheduleModel.DepartureSchedule
-                        }
-                        Label {
-                            text: delay
-                            font.bold: UiConstants.SubtitleFontBoldness
-                            font.pixelSize: UiConstants.SubtitleFontPixelSize
-                        }
-                    }
-                }
-                Image {
-                    source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
-                    anchors.right: parent.right;
-                    anchors.verticalCenter: parent.verticalCenter
-                }
-                Image {
-                    anchors {
-                        left: parent.left
-                        right: parent.right
-                    }
-                    source: "image://theme/meegotouch-separator-background-horizontal"
-                }
-                MouseArea {
-                    id: mouseArea
-                    anchors.fill: background
-                    onClicked: {
-                        // Load an external page about the train, for now
-                    }
-                }
+            model: schedule
+            delegate: StationScheduleDelegate {
+                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
             }
         }
         ScrollDecorator {
@@ -174,5 +102,13 @@ Page {
         onNameChanged: schedule.fetch(name)
         onLayoutChanged: view.state = "ready"
     }
-
- }
+    Settings {
+        id: settings
+    }
+   Component.onCompleted: {
+       updateTimer.timeout.connect(updateStation)
+   }
+   function updateStation() {
+        schedule.fetch(schedule.name)
+   }
+}