54579fbb21c8a745c94873020957d4c94949737e
[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 ") + root.arrivalStation
60                 font.bold: UiConstants.DefaultFontBoldness
61                 font.pixelSize: UiConstants.DefaultFontPixelSize
62                 visible: type === StationScheduleModel.ArrivalSchedule
63             }
64             Label {
65                 text: qsTr("to ") + 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 ") + root.actualPlatform
84         font.bold: UiConstants.SubtitleFontBoldness
85         font.pixelSize: UiConstants.SubtitleFontPixelSize
86     }
87     Image {
88         anchors {
89             left: parent.left
90             right: parent.right
91         }
92         source: "image://theme/meegotouch-separator-background-horizontal"
93     }
94     MouseArea {
95         id: mouseArea
96         anchors.fill: background
97         onClicked: {
98             // Load an external page about the train, for now
99             Qt.openUrlExternally(settings.queryBaseUrl + "/" + detailsUrl)
100             console.log(settings.queryBaseUrl + "/" + detailsUrl)
101         }
102     }
103 }