366be298d1b794857b1b66d57687788cf034312e
[quandoparte] / application / resources / harmattan / qml / StationScheduleDelegate.qml
1 import QtQuick 1.1
2 import QtWebKit 1.0
3 import com.nokia.meego 1.0
4 import net.cirulla.quandoparte 1.0
5 import "uiconstants.js" as UiConstants
6
7 Item {
8     id: root
9     property variant type
10     property alias arrivalTime: arrivalTimeLabel.text
11     property alias departureTime: departureTimeLabel.text
12     property alias train: trainLabel.text
13     property string arrivalStation
14     property string departureStation
15     property alias delay: delayLabel.text
16     property string actualPlatform
17     property string expectedPlatfrom
18
19     height: UiConstants.ListItemHeightDefault
20     width: parent.width
21     BorderImage {
22         id: background
23         anchors.fill: parent
24         // Fill page borders
25         visible: mouseArea.pressed
26         source: "image://theme/meegotouch-list-background-pressed-center"
27     }
28     Row {
29         id: bodyRow
30         anchors.fill: parent
31         spacing: UiConstants.ButtonSpacing
32         DelayIndicator {
33             level: delayClass
34         }
35         Column {
36             anchors.verticalCenter: parent.verticalCenter
37             Row {
38                 spacing: UiConstants.ButtonSpacing
39                 Label {
40                     id: arrivalTimeLabel
41                     font.bold: UiConstants.SpecialFontBoldness
42                     font.pixelSize: UiConstants.SpecialFontPixelSize
43                     visible: type === StationScheduleModel.ArrivalSchedule
44                 }
45                 Label {
46                     id: departureTimeLabel
47                     font.bold: UiConstants.SpecialFontBoldness
48                     font.pixelSize: UiConstants.SpecialFontPixelSize
49                     visible: type === StationScheduleModel.DepartureSchedule
50                 }
51                 Label {
52                     id: trainLabel
53                     font.bold: UiConstants.SpecialFontBoldness
54                     font.pixelSize: UiConstants.SpecialFontPixelSize
55                     color: UiConstants.AccentColor
56                 }
57             }
58             Label {
59                 text: qsTr("from %1").arg(root.arrivalStation)
60                 font.bold: UiConstants.DefaultFontBoldness
61                 font.pixelSize: UiConstants.DefaultFontPixelSize
62                 visible: type === StationScheduleModel.ArrivalSchedule
63             }
64             Label {
65                 text: qsTr("to %1").arg(root.departureStation)
66                 font.bold: UiConstants.DefaultFontBoldness
67                 font.pixelSize: UiConstants.DefaultFontPixelSize
68                 visible: type === StationScheduleModel.DepartureSchedule
69             }
70             Label {
71                 id: delayLabel
72                 font.bold: UiConstants.SubtitleFontBoldness
73                 font.pixelSize: UiConstants.SubtitleFontPixelSize
74             }
75         }
76     }
77     Label {
78         anchors {
79             bottom: bodyRow.bottom
80             right: bodyRow.right
81             rightMargin: UiConstants.DefaultMargin
82         }
83         text: qsTr("Platform %1").arg((root.actualPlatform === "--") ? root.expectedPlatfrom : root.actualPlatform)
84         color: root.actualPlatform === "--" ? "#ddd" : UiConstants.AccentColor
85         font.bold: UiConstants.SubtitleFontBoldness
86         font.pixelSize: UiConstants.SubtitleFontPixelSize
87     }
88     Image {
89         anchors {
90             left: parent.left
91             right: parent.right
92         }
93         source: "image://theme/meegotouch-separator-background-horizontal"
94     }
95     MouseArea {
96         id: mouseArea
97         anchors.fill: background
98         onClicked: {
99             // Load an external page about the train, for now
100             Qt.openUrlExternally(settings.queryBaseUrl + "/" + detailsUrl)
101             console.log(settings.queryBaseUrl + "/" + detailsUrl)
102         }
103     }
104 }