Refactored StationScheduleDelegate to its own file.
[quandoparte] / application / resources / harmattan / qml / StationPage.qml
index d86e4da..5fe1e60 100644 (file)
 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
 
 Page {
     property alias name: schedule.name
-    anchors.fill: parent
 
     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: settings.showArrivalsPreferred ? 1 : 0
-        options: ListModel {
-            id: dialogOptions
-            ListElement {
-                name: QT_TR_NOOP("Departures")
-            }
-            ListElement {
-                name: QT_TR_NOOP("Arrivals")
-            }
-        }
+        selectedIndex: schedule.type
+        options: [
+            qsTr("Departures"),
+            qsTr("Arrivals")
+        ]
     }
     InfoBar {
-        id: info
+        id: infoBar
         anchors.top: header.bottom
         text: parent.name
     }
-    Rectangle {
-        id: shadow
-        width: parent.width
-        anchors.top: view.top
-        height: 5
-        gradient: Gradient {
-            GradientStop {color: "#aa000000"; position: 0.0}
-            GradientStop {color: "#00000000"; position: 1.0}
-        }
-    }
     Binding {
-        target: settings
-        property: "showArrivalsPreferred"
-        value: header.selectedIndex === 1 ? true : false
+        target: schedule
+        property: "type"
+        value: header.selectedIndex
     }
     LabelStyle {
         id: labelStyle
     }
     Item {
         id: view
-        anchors.top: info.bottom
-        anchors.bottom: tools.top
-        x: 16
-        y: 16
-        width: parent.width - 32
-        height: parent.height
-
+        anchors {
+            top: infoBar.bottom
+            bottom: parent.bottom
+            left: parent.left
+            right: parent.right
+        }
+        DroppedShadow {
+            id: shadow
+            anchors.top: view.top
+        }
         ListView {
             id: stationScheduleView
             clip: true
             visible: false
             width: parent.width
-            height: parent.height
-            model:  schedule
-            delegate: Item {
-                id: listItem
-                height: 64
-                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
-
-                    Column {
-                        anchors.verticalCenter: parent.verticalCenter
-
-                        Label {
-                            id: mainText
-                            text: train
-                            font.bold: true
-                        }
-                    }
-                }
-                Image {
-                    source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
-                    anchors.right: parent.right;
-                    anchors.verticalCenter: parent.verticalCenter
-                }
-                MouseArea {
-                    id: mouseArea
-                    anchors.fill: background
-                    onClicked: {
-                        // Load an external page about the train, for now
-                    }
-                }
+            anchors {
+                top: shadow.top
+                bottom: parent.bottom
             }
+            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 {
+            id: decorator
+            flickableItem: stationScheduleView
         }
         BusyIndicator {
             id: busyIndicator
-            anchors.centerIn: view
+            platformStyle: BusyIndicatorStyle {
+                size: "large"
+            }
+            anchors.centerIn: parent
             visible: !stationScheduleView.visible
             running: visible
         }
@@ -132,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)
+   }
+}