Warning, /pim/itinerary/src/app/JourneySectionStopDelegate.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 import org.kde.itinerary 0013 0014 Item { 0015 id: root 0016 property var stop 0017 property bool isDeparture: false 0018 property bool isArrival: false 0019 0020 readonly property bool isSameTime: stop.scheduledDepartureTime.getTime() == stop.scheduledArrivalTime.getTime() 0021 readonly property bool isSingleTime: !(stop.scheduledDepartureTime > 0 && stop.scheduledArrivalTime > 0) || isSameTime 0022 0023 // outbound progress overlay properties 0024 readonly property real leadingSegmentLength: lineSegment.leadingLineLength 0025 readonly property real trailingSegmentLength: lineSegment.trailingLineLength + (notesLabel.visible ? stopNotesLine.height : 0) 0026 // inbound progress overlay properties 0027 property alias leadingProgress: lineSegment.leadingProgress 0028 property real trailingProgress 0029 property alias stopoverPassed: lineSegment.showStop 0030 0031 x: Kirigami.Units.gridUnit 0032 implicitHeight: layout.implicitHeight + Kirigami.Units.gridUnit * 2 0033 implicitWidth: ListView.view.width - x - Kirigami.Units.largeSpacing 0034 0035 GridLayout { 0036 id: layout 0037 width: parent.width 0038 height: parent.height 0039 columns: 6 0040 rows: 3 0041 rowSpacing: 0 0042 JourneySectionStopDelegateLineSegment { 0043 id: lineSegment 0044 Layout.column: 0 0045 Layout.row: 0 0046 Layout.fillHeight: true 0047 Layout.rowSpan: 2 0048 0049 isArrival: root.isArrival 0050 isDeparture: root.isDeparture 0051 lineColor: stop.route.line.hasColor ? stop.route.line.color : Kirigami.Theme.textColor 0052 hasStop: !isIntermediate || stop.disruptionEffect !== Disruption.NoService 0053 showStop: false 0054 trailingProgress: Math.min(1.0, (root.trailingProgress * root.trailingSegmentLength) / lineSegment.trailingLineLength) 0055 } 0056 0057 QQC2.Label { 0058 id: arrivalTime 0059 Layout.column: 1 0060 Layout.row: 0 0061 Layout.rowSpan: isSingleTime ? 2 : 1 0062 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignBottom 0063 text: Localizer.formatTime(stop, "scheduledArrivalTime") 0064 visible: stop.scheduledArrivalTime > 0 && !isSameTime 0065 font.strikeout: stop.disruptionEffect === Disruption.NoService 0066 } 0067 QQC2.Label { 0068 Layout.column: 2 0069 Layout.row: 0 0070 Layout.rowSpan: arrivalTime.Layout.rowSpan 0071 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignBottom 0072 text: (stop.arrivalDelay >= 0 ? "+" : "") + stop.arrivalDelay 0073 color: stop.arrivalDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor 0074 visible: stop.hasExpectedArrivalTime && !isSameTime && stop.disruptionEffect !== Disruption.NoService 0075 } 0076 0077 QQC2.Label { 0078 Layout.column: 3 0079 Layout.row: 0 0080 Layout.rowSpan: arrivalTime.Layout.rowSpan 0081 Layout.fillWidth: true 0082 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignBottom 0083 text: stop.stopPoint.name 0084 elide: Text.ElideRight 0085 font.bold: root.isDeparture || root.isArrival 0086 font.strikeout: stop.disruptionEffect === Disruption.NoService 0087 } 0088 0089 QQC2.Label { 0090 id: departureTime 0091 Layout.column: 1 0092 Layout.row: isSingleTime ? 0 : 1 0093 Layout.rowSpan: isSingleTime ? 2 : 1 0094 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignTop 0095 text: Localizer.formatTime(stop, "scheduledDepartureTime") 0096 visible: stop.scheduledDepartureTime > 0 0097 font.strikeout: stop.disruptionEffect === Disruption.NoService 0098 } 0099 0100 QQC2.Label { 0101 Layout.column: 2 0102 Layout.row: departureTime.Layout.row 0103 Layout.rowSpan: departureTime.Layout.rowSpan 0104 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignTop 0105 text: (stop.departureDelay >= 0 ? "+" : "") + stop.departureDelay 0106 color: stop.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor 0107 visible: departureTime.visible && stop.hasExpectedDepartureTime && stop.disruptionEffect !== Disruption.NoService 0108 } 0109 0110 VehicleLoadIndicator { 0111 Layout.column: 3 0112 Layout.row: 1 0113 Layout.rowSpan: 1 0114 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignTop 0115 loadInformation: stop.loadInformation 0116 } 0117 0118 QQC2.Label { 0119 Layout.column: 4 0120 Layout.row: 0 0121 Layout.rowSpan: arrivalTime.Layout.rowSpan 0122 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignBottom 0123 0124 color: stop.hasExpectedPlatform ? (stop.platformChanged ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor) : Kirigami.Theme.textColor 0125 text: { 0126 const platform = stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform; 0127 0128 if (platform.length === 0) { 0129 return ''; 0130 } 0131 0132 switch (stop.route.line.mode) { 0133 case Line.Train: 0134 case Line.Funicular: 0135 case Line.LocalTrain: 0136 case Line.LongDistanceTrain: 0137 case Line.Metro: 0138 case Line.RailShuttle: 0139 case Line.RapidTransit: 0140 case Line.Tramway: 0141 return i18nc("Abreviation of train platform", "Pl. %1", platform) 0142 case Line.Ferry: 0143 return i18nc("Ferry dock, if possible use an abreviation", "Dock %1", platform) 0144 default: 0145 return i18nc("Generic abreviation of platform", "Pl. %1", platform) 0146 } 0147 } 0148 visible: stop.disruptionEffect !== Disruption.NoService 0149 } 0150 0151 QQC2.ToolButton { 0152 Layout.column: 5 0153 Layout.row: 0 0154 Layout.rowSpan: arrivalTime.Layout.rowSpan 0155 Layout.alignment: isSingleTime ? Qt.AlignVCenter : Qt.AlignBottom 0156 Layout.bottomMargin: isSingleTime ? 0 : Math.round(-height / 4) 0157 visible: stop.stopPoint.hasCoordinate && stop.disruptionEffect !== Disruption.NoService 0158 icon.name: "map-symbolic" 0159 text: i18n("Show location") 0160 display: QQC2.AbstractButton.IconOnly 0161 onClicked: { 0162 const args = { 0163 coordinate: Qt.point(stop.stopPoint.longitude, stop.stopPoint.latitude), 0164 placeName: stop.stopPoint.name 0165 }; 0166 if (!isDeparture) { 0167 args.arrivalPlatformName = stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform; 0168 args.arrivalPlatformMode = PublicTransport.lineModeToPlatformMode(stop.route.line.mode); 0169 args.arrivalPlatformIfopt = stop.stopPoint.identifier("ifopt"); 0170 } 0171 if (!isArrival) { 0172 args.departurePlatformName = stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform; 0173 args.departurePlatformMode = PublicTransport.lineModeToPlatformMode(stop.route.line.mode); 0174 args.departurePlatformIfopt = stop.stopPoint.identifier("ifopt"); 0175 } 0176 0177 // ensure the map page ends up on top 0178 if (applicationWindow().pageStack.layers.depth < 2) 0179 applicationWindow().pageStack.push(indoorMapPage, args); 0180 else 0181 applicationWindow().pageStack.layers.push(indoorMapPage, args); 0182 } 0183 0184 QQC2.ToolTip.text: text 0185 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0186 QQC2.ToolTip.visible: hovered 0187 } 0188 0189 0190 JourneySectionStopDelegateLineSegment { 0191 id: stopNotesLine 0192 Layout.column: 0 0193 Layout.row: 2 0194 Layout.fillHeight: true 0195 visible: notesLabel.visible 0196 lineColor: stop.route.line.hasColor ? stop.route.line.color : Kirigami.Theme.textColor 0197 hasStop: false 0198 showStop: false 0199 leadingProgress: Math.max(0, ((root.trailingProgress * root.trailingSegmentLength) - lineSegment.trailingLineLength) / stopNotesLine.height) 0200 trailingProgress: stopNotesLine.leadingProgress 0201 } 0202 QQC2.Label { 0203 id: notesLabel 0204 Layout.column: 3 0205 Layout.row: 2 0206 Layout.columnSpan: 3 0207 Layout.fillWidth: true 0208 Layout.fillHeight: true 0209 verticalAlignment: Qt.AlignTop 0210 text: stop.notes.join("<br/>") 0211 textFormat: Text.RichText 0212 wrapMode: Text.Wrap 0213 visible: stop.notes.length > 0 && !isDeparture 0214 font.italic: true 0215 onLinkActivated: Qt.openUrlExternally(link) 0216 color: Kirigami.Theme.disabledTextColor 0217 } 0218 } 0219 }