Refactored StationScheduleDelegate to its own file.
authorLuciano Montanaro <mikelima@cirulla.net>
Thu, 12 Jan 2012 00:00:35 +0000 (01:00 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Thu, 12 Jan 2012 00:00:35 +0000 (01:00 +0100)
application/application.pro
application/resources/harmattan/qml/StationPage.qml
application/resources/harmattan/qml/StationScheduleDelegate.qml [new file with mode: 0644]

index ce0393c..0da349c 100644 (file)
@@ -118,7 +118,8 @@ QMLSOURCES = \
     resources/harmattan/qml/AboutPage.qml \
     resources/harmattan/qml/InfoBar.qml \
     resources/harmattan/qml/DroppedShadow.qml \
-    resources/harmattan/qml/DelayIndicator.qml
+    resources/harmattan/qml/DelayIndicator.qml \
+    resources/harmattan/qml/StationScheduleDelegate.qml
 
 OTHER_FILES += \
     resources/harmattan/applications/quandoparte.desktop \
index 7321dab..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
@@ -55,94 +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 {
-                    id: bodyRow
-                    anchors.fill: parent
-                    spacing: UiConstants.ButtonSpacing
-                    DelayIndicator {
-                        level: delayClass
-                    }
-                    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 {
-                            id: delayLabel
-                            text: delay
-                            font.bold: UiConstants.SubtitleFontBoldness
-                            font.pixelSize: UiConstants.SubtitleFontPixelSize
-                        }
-                    }
-                }
-                Label {
-                    anchors {
-                        bottom: bodyRow.bottom
-                        right: bodyRow.right
-                        rightMargin: UiConstants.DefaultMargin
-                    }
-                    text: qsTr("Platform ") + actualPlatform
-                    font.bold: UiConstants.SubtitleFontBoldness
-                    font.pixelSize: UiConstants.SubtitleFontPixelSize
-                }
-                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
-                        Qt.openUrlExternally(settings.queryBaseUrl + "/" + detailsUrl)
-                        console.log(settings.queryBaseUrl + "/" + detailsUrl)
-                    }
-                }
+            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 {
@@ -189,4 +111,4 @@ Page {
    function updateStation() {
         schedule.fetch(schedule.name)
    }
- }
+}
diff --git a/application/resources/harmattan/qml/StationScheduleDelegate.qml b/application/resources/harmattan/qml/StationScheduleDelegate.qml
new file mode 100644 (file)
index 0000000..54579fb
--- /dev/null
@@ -0,0 +1,103 @@
+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
+
+Item {
+    id: root
+    property variant type
+    property alias arrivalTime: arrivalTimeLabel.text
+    property alias departureTime: departureTimeLabel.text
+    property alias train: trainLabel.text
+    property string arrivalStation
+    property string departureStation
+    property alias delay: delayLabel.text
+    property string actualPlatform
+    property string expectedPlatfrom
+
+    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 {
+        id: bodyRow
+        anchors.fill: parent
+        spacing: UiConstants.ButtonSpacing
+        DelayIndicator {
+            level: delayClass
+        }
+        Column {
+            anchors.verticalCenter: parent.verticalCenter
+            Row {
+                spacing: UiConstants.ButtonSpacing
+                Label {
+                    id: arrivalTimeLabel
+                    font.bold: UiConstants.SpecialFontBoldness
+                    font.pixelSize: UiConstants.SpecialFontPixelSize
+                    visible: type === StationScheduleModel.ArrivalSchedule
+                }
+                Label {
+                    id: departureTimeLabel
+                    font.bold: UiConstants.SpecialFontBoldness
+                    font.pixelSize: UiConstants.SpecialFontPixelSize
+                    visible: type === StationScheduleModel.DepartureSchedule
+                }
+                Label {
+                    id: trainLabel
+                    font.bold: UiConstants.SpecialFontBoldness
+                    font.pixelSize: UiConstants.SpecialFontPixelSize
+                    color: UiConstants.AccentColor
+                }
+            }
+            Label {
+                text: qsTr("from ") + root.arrivalStation
+                font.bold: UiConstants.DefaultFontBoldness
+                font.pixelSize: UiConstants.DefaultFontPixelSize
+                visible: type === StationScheduleModel.ArrivalSchedule
+            }
+            Label {
+                text: qsTr("to ") + root.departureStation
+                font.bold: UiConstants.DefaultFontBoldness
+                font.pixelSize: UiConstants.DefaultFontPixelSize
+                visible: type === StationScheduleModel.DepartureSchedule
+            }
+            Label {
+                id: delayLabel
+                font.bold: UiConstants.SubtitleFontBoldness
+                font.pixelSize: UiConstants.SubtitleFontPixelSize
+            }
+        }
+    }
+    Label {
+        anchors {
+            bottom: bodyRow.bottom
+            right: bodyRow.right
+            rightMargin: UiConstants.DefaultMargin
+        }
+        text: qsTr("Platform ") + root.actualPlatform
+        font.bold: UiConstants.SubtitleFontBoldness
+        font.pixelSize: UiConstants.SubtitleFontPixelSize
+    }
+    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
+            Qt.openUrlExternally(settings.queryBaseUrl + "/" + detailsUrl)
+            console.log(settings.queryBaseUrl + "/" + detailsUrl)
+        }
+    }
+}