Warning, /libraries/kpublictransport/tests/JourneySectionPage.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Layouts
0009 import QtQuick.Controls as QQC2
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kpublictransport
0012
0013 Kirigami.Page {
0014 property var journeySection
0015
0016 ColumnLayout {
0017 anchors.fill: parent
0018 spacing: Kirigami.Units.largeSpacing
0019
0020 GridLayout {
0021 Layout.fillWidth: true
0022 Layout.margins: Kirigami.Units.largeSpacing
0023 columns: 3
0024 rows: 4
0025
0026 Kirigami.Icon {
0027 Layout.rowSpan: 4
0028 id: icon
0029 source: journeySection.route.line.hasLogo ? journeySection.route.line.logo : journeySection.route.line.modeLogo
0030 width: height
0031 height: Kirigami.Units.iconSizes.large
0032 visible: source != ""
0033 }
0034
0035 QQC2.Label {
0036 Layout.row: 0
0037 Layout.column: 1
0038 Layout.fillWidth: true
0039 text: "<b>" + journeySection.route.line.modeString + " " + journeySection.route.line.name + "</b>"
0040 }
0041
0042 QQC2.Label {
0043 Layout.row: 0
0044 Layout.column: 2
0045 text: "<a href=\"#layout\">vehicle</a>"
0046 visible: journeySection.route.line.mode == Line.LongDistanceTrain
0047 onLinkActivated: applicationWindow().pageStack.push(vehicleLayoutPage, {"departure": journeySection.departure});
0048 }
0049
0050 QQC2.Label {
0051 Layout.row: 1
0052 Layout.column: 1
0053 Layout.columnSpan: 2
0054 text: "Direction: " + journeySection.route.direction
0055 }
0056
0057 QQC2.Label {
0058 Layout.row: 2
0059 Layout.column: 1
0060 Layout.columnSpan: 2
0061 text: "Distance: " + journeySection.distance / 1000.0 + "km"
0062 }
0063 QQC2.Label {
0064 Layout.row: 3
0065 Layout.column: 1
0066 Layout.columnSpan: 2
0067 text: "CO₂: " + journeySection.co2Emission + "g"
0068 visible: journeySection.co2Emission >= 0
0069 }
0070 }
0071
0072 ListView {
0073 Layout.fillHeight: true
0074 Layout.fillWidth: true
0075 clip: true
0076 header: RowLayout {
0077 enabled: journeySection.departure.disruptionEffect != Disruption.NoService
0078 width: parent.width - 2 * Kirigami.Units.largeSpacing
0079 x: Kirigami.Units.largeSpacing
0080 Rectangle {
0081 Layout.fillHeight: true
0082 width: Kirigami.Units.largeSpacing
0083 color: journeySection.route.line.hasColor ? journeySection.route.line.color : Kirigami.Theme.textColor
0084 }
0085
0086 QQC2.Label {
0087 text: journeySection.scheduledDepartureTime.toTimeString()
0088 }
0089 QQC2.Label {
0090 text: (journeySection.departureDelay >= 0 ? "+" : "") + journeySection.departureDelay
0091 color: journeySection.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0092 visible: journeySection.hasExpectedDepartureTime
0093 }
0094
0095 QQC2.Label {
0096 Layout.fillWidth: true
0097 text: "<a href=\"#loc\">" + journeySection.from.name + "</a>"
0098 onLinkActivated: {
0099 locationDetailsSheet.location = journeySection.from;
0100 locationDetailsSheet.open();
0101 }
0102 }
0103
0104 QQC2.Label {
0105 text: journeySection.hasExpectedDeparturePlatform ? journeySection.expectedDeparturePlatform : journeySection.scheduledDeparturePlatform
0106 color: JourneySection.hasExpectedDeparturePlatform ? (journeySection.departurePlatformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor) : Kirigami.Theme.textColor
0107 }
0108 }
0109
0110 delegate: QQC2.ItemDelegate {
0111 property var stop: modelData
0112 enabled: stop.disruptionEffect != Disruption.NoService
0113 highlighted: false
0114 width: ListView.view.width
0115 contentItem: GridLayout {
0116 columns: 5
0117 rows: 4
0118 Rectangle {
0119 Layout.column: 0
0120 Layout.row: 0
0121 Layout.fillHeight: true
0122 Layout.rowSpan: 4
0123 width: Kirigami.Units.largeSpacing
0124 color: stop.route.line.hasColor ? stop.route.line.color : Kirigami.Theme.textColor
0125 }
0126
0127 QQC2.Label {
0128 Layout.column: 1
0129 Layout.row: 0
0130 text: stop.scheduledArrivalTime.toTimeString()
0131 }
0132 QQC2.Label {
0133 Layout.column: 2
0134 Layout.row: 0
0135 text: (stop.arrivalDelay >= 0 ? "+" : "") + stop.arrivalDelay
0136 color: stop.arrivalDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0137 visible: stop.hasExpectedArrivalTime
0138 }
0139
0140 QQC2.Label {
0141 Layout.column: 3
0142 Layout.row: 0
0143 Layout.rowSpan: loadData.visible ? 1 : 2
0144 Layout.fillWidth: true
0145 Layout.fillHeight: true
0146 text: "<a href=\"#loc\">" + stop.stopPoint.name + "</a>" + (stop.route.line.mode == Line.LongDistanceTrain ? " (<a href=\"#layout\">vehicle</a>)" : "")
0147 verticalAlignment: Qt.AlignVCenter
0148 onLinkActivated: {
0149 if (link == "#loc") {
0150 locationDetailsSheet.location = stop.stopPoint;
0151 locationDetailsSheet.open();
0152 } else if (link == "#layout") {
0153 applicationWindow().pageStack.push(vehicleLayoutPage, {"departure": stop });
0154 }
0155 }
0156 }
0157
0158 RowLayout {
0159 id: loadData
0160 Layout.column: 3
0161 Layout.row: 1
0162 Layout.fillWidth: true
0163 visible: stop.loadInformation.length > 0
0164 QQC2.Label {
0165 text: "Load: ";
0166 }
0167 Repeater {
0168 model: stop.loadInformation
0169 RowLayout {
0170 QQC2.Label {
0171 text: {
0172 switch (modelData.load) {
0173 case Load.Low: return "Low";
0174 case Load.Medium: return "Medium";
0175 case Load.High: return "High";
0176 case Load.Full: return "Full";
0177 default: return "?"
0178 }
0179 }
0180 color: {
0181 switch (modelData.load) {
0182 case Load.Low: return Kirigami.Theme.positiveTextColor;
0183 case Load.Medium: return Kirigami.Theme.neutralTextColor;
0184 case Load.High:
0185 case Load.Full:
0186 return Kirigami.Theme.negativeTextColor;
0187 default:
0188 return Kirigami.Theme.textColor;
0189 }
0190 }
0191 }
0192 QQC2.Label {
0193 text: "(class " + modelData.seatingClass + ")"
0194 visible: modelData.seatingClass != ""
0195 }
0196 }
0197 }
0198 }
0199
0200 QQC2.Label {
0201 Layout.column: 1
0202 Layout.row: 1
0203 text: stop.scheduledDepartureTime.toTimeString()
0204 }
0205 QQC2.Label {
0206 Layout.column: 2
0207 Layout.row: 1
0208 text: (stop.departureDelay >= 0 ? "+" : "") + stop.departureDelay
0209 color: stop.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0210 visible: stop.hasExpectedDepartureTime
0211 }
0212
0213 QQC2.Label {
0214 Layout.column: 4
0215 Layout.row: 0
0216 Layout.rowSpan: 2
0217 Layout.fillHeight: true
0218 verticalAlignment: Qt.AlignVCenter
0219 text: stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform
0220 color: stop.hasExpectedPlatform ? (stop.platformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor) : Kirigami.Theme.textColor
0221 }
0222
0223 QQC2.Label {
0224 Layout.column: 1
0225 Layout.row: 2
0226 Layout.columnSpan: 3
0227 text: stop.notes.join("<br/>")
0228 textFormat: Text.RichText
0229 visible: stop.notes.length > 0
0230 font.italic: true
0231 }
0232 }
0233 }
0234
0235 footer: RowLayout {
0236 enabled: journeySection.arrival.disruptionEffect != Disruption.NoService
0237 width: parent.width - 2 * Kirigami.Units.largeSpacing
0238 x: Kirigami.Units.largeSpacing
0239 Rectangle {
0240 Layout.fillHeight: true
0241 width: Kirigami.Units.largeSpacing
0242 color: journeySection.route.line.hasColor ? journeySection.route.line.color : Kirigami.Theme.textColor
0243 }
0244
0245 QQC2.Label {
0246 text: journeySection.scheduledArrivalTime.toTimeString()
0247 }
0248 QQC2.Label {
0249 text: (journeySection.arrivalDelay >= 0 ? "+" : "") + journeySection.arrivalDelay
0250 color: journeySection.arrivalDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0251 visible: journeySection.hasExpectedArrivalTime
0252 }
0253
0254 QQC2.Label {
0255 Layout.fillWidth: true
0256 text: "<a href=\"#loc\">" + journeySection.to.name + "</a>"
0257 onLinkActivated: {
0258 locationDetailsSheet.location = journeySection.to;
0259 locationDetailsSheet.open();
0260 }
0261 }
0262
0263 QQC2.Label {
0264 text: journeySection.hasExpectedArrivalPlatform ? journeySection.expectedArrivalPlatform : journeySection.scheduledArrivalPlatform
0265 color: JourneySection.hasExpectedArrivalPlatform ? (journeySection.arrivalPlatformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor) : Kirigami.Theme.textColor
0266 }
0267 }
0268
0269 model: journeySection.intermediateStops
0270 }
0271 }
0272 }