Warning, /pim/itinerary/src/app/TrainPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0002 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: LGPL-2.0-or-later 0004 0005 import QtQuick 0006 import QtQuick.Layouts 0007 import QtQuick.Controls as QQC2 0008 import org.kde.kirigami as Kirigami 0009 import org.kde.kirigamiaddons.formcard as FormCard 0010 import org.kde.kpublictransport as KPublicTransport 0011 import org.kde.kitinerary 0012 import org.kde.itinerary 0013 0014 DetailsPage { 0015 id: root 0016 0017 title: i18n("Train Ticket") 0018 editor: TrainEditor { 0019 controller: root.controller 0020 } 0021 0022 data: BarcodeScanModeButton { 0023 page: root 0024 visible: ticketToken.hasBarcode 0025 } 0026 0027 Component { 0028 id: alternativePage 0029 AlternativeJourneyPage { 0030 controller: root.controller 0031 publicTransportManager: LiveDataManager.publicTransportManager 0032 } 0033 } 0034 0035 Component { 0036 id: vehicleLayoutPage 0037 VehicleLayoutPage { 0038 publicTransportManager: root.controller.liveDataManager.publicTransportManager 0039 selectedVehicleSection: root.reservation.reservedTicket.ticketedSeat.seatSection 0040 selectedClasses: root.reservation.reservedTicket.ticketedSeat.seatingType 0041 seat: root.reservation.reservedTicket.ticketedSeat.seatNumber 0042 0043 property bool arrival 0044 0045 onLayoutUpdated: root.controller.setVehicleLayout(vehicleLayout, arrival); 0046 } 0047 } 0048 0049 ColumnLayout { 0050 spacing: 0 0051 0052 CardPageTitle { 0053 emojiIcon: "🚅" 0054 text: { 0055 if (reservationFor.trainName || reservationFor.trainNumber) { 0056 return reservationFor.trainName + " " + reservationFor.trainNumber 0057 } 0058 return i18n("%1 to %2", reservationFor.departureStation.name, reservationFor.arrivalStation.name); 0059 } 0060 } 0061 0062 FormCard.FormCard { 0063 visible: ticketToken.ticketTokenCount > 0 0064 // ticket barcode 0065 TicketTokenDelegate { 0066 id: ticketToken 0067 Layout.fillWidth: true 0068 resIds: ReservationManager.reservationsForBatch(root.batchId) 0069 onCurrentReservationIdChanged: { 0070 if (!currentReservationId) 0071 return; 0072 root.currentReservationId = currentReservationId; 0073 } 0074 onScanModeToggled: scanModeController.toggle() 0075 } 0076 } 0077 0078 // departure data 0079 FormCard.FormHeader { 0080 title: i18nc("Train departure", "Departure") 0081 } 0082 0083 FormCard.FormCard { 0084 FormCard.FormTextDelegate { 0085 id: departureTimeDelegate 0086 text: i18n("Departure time") 0087 visible: departureTimeLabel.text.length > 0 0088 contentItem: ColumnLayout { 0089 spacing: Kirigami.Units.smallSpacing 0090 QQC2.Label { 0091 text: departureTimeDelegate.text 0092 Layout.fillWidth: true 0093 elide: Text.ElideRight 0094 Accessible.ignored: true 0095 } 0096 RowLayout { 0097 Layout.fillWidth: true 0098 QQC2.Label { 0099 id: departureTimeLabel 0100 text: Localizer.formatDateTime(reservationFor, "departureTime") 0101 color: Kirigami.Theme.disabledTextColor 0102 font: Kirigami.Theme.smallFont 0103 elide: Text.ElideRight 0104 } 0105 QQC2.Label { 0106 text: (departure.departureDelay >= 0 ? "+" : "") + departure.departureDelay 0107 color: (departure.departureDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor 0108 visible: departure.hasExpectedDepartureTime 0109 Accessible.ignored: !visible 0110 } 0111 } 0112 } 0113 } 0114 FormCard.FormTextDelegate { 0115 text: i18n("Departure date") 0116 visible: !departureTimeDelegate.visible && text.length > 0 0117 description: Localizer.formatDate(reservationFor, "departureDay") 0118 } 0119 0120 FormCard.FormDelegateSeparator {} 0121 0122 FormCard.FormTextDelegate { 0123 text: i18nc("train station", "Station") 0124 description: reservationFor.departureStation.name 0125 visible: description 0126 } 0127 0128 FormCard.FormDelegateSeparator { visible: reservationFor.departureStation.name } 0129 0130 FormPlatformDelegate { 0131 id: departurePlatformDelegate 0132 stopover: departure 0133 sections: root.controller.departurePlatformSections 0134 scheduledPlatform: reservationFor.departurePlatform 0135 } 0136 0137 FormCard.FormDelegateSeparator { visible: departurePlatformDelegate.visible } 0138 0139 FormPlaceDelegate { 0140 id: departureDelegate 0141 place: reservationFor.departureStation 0142 controller: root.controller 0143 isRangeBegin: true 0144 } 0145 0146 FormCard.FormDelegateSeparator { 0147 visible: departureDelegate.visible 0148 } 0149 0150 FormCard.FormTextDelegate { 0151 text: i18n("Additional notes") 0152 description: departure.notes.join("<br/>") 0153 descriptionItem.textFormat: Text.RichText 0154 descriptionItem.wrapMode: Text.Wrap 0155 visible: departure.notes.length > 0 0156 font.italic: true 0157 onLinkActivated: Qt.openUrlExternally(link) 0158 } 0159 } 0160 0161 // arrival data 0162 FormCard.FormHeader { 0163 title: i18nc("Train arrival", "Arrival") 0164 } 0165 0166 FormCard.FormCard { 0167 FormCard.FormTextDelegate { 0168 id: arrivalTimeDelegate 0169 text: i18n("Arrival time") 0170 visible: arrivalTimeLabel.text.length > 0 0171 contentItem: ColumnLayout { 0172 Layout.fillWidth: true 0173 spacing: Kirigami.Units.smallSpacing 0174 QQC2.Label { 0175 text: arrivalTimeDelegate.text 0176 Layout.fillWidth: true 0177 elide: Text.ElideRight 0178 Accessible.ignored: true 0179 } 0180 RowLayout { 0181 Layout.fillWidth: true 0182 QQC2.Label { 0183 id: arrivalTimeLabel 0184 text: Localizer.formatDateTime(reservationFor, "arrivalTime") 0185 color: Kirigami.Theme.disabledTextColor 0186 font: Kirigami.Theme.smallFont 0187 elide: Text.ElideRight 0188 } 0189 QQC2.Label { 0190 font: Kirigami.Theme.smallFont 0191 text: (arrival.arrivalDelay >= 0 ? "+" : "") + arrival.arrivalDelay 0192 color: (arrival.arrivalDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor 0193 visible: arrival.hasExpectedArrivalTime 0194 Accessible.ignored: !visible 0195 } 0196 } 0197 } 0198 } 0199 0200 FormCard.FormDelegateSeparator { visible: arrivalTimeLabel.text.length > 0 } 0201 0202 FormCard.FormTextDelegate { 0203 text: i18nc("train station", "Station") 0204 description: reservationFor.arrivalStation.name 0205 } 0206 0207 FormCard.FormDelegateSeparator { visible: reservationFor.arrivalStation.name } 0208 0209 FormPlatformDelegate { 0210 id: arrivalPlatformDelegate 0211 stopover: arrival 0212 sections: root.controller.arrivalPlatformSections 0213 scheduledPlatform: reservationFor.arrivalPlatform 0214 } 0215 0216 FormCard.FormDelegateSeparator { visible: arrivalPlatformDelegate.visible } 0217 0218 FormPlaceDelegate { 0219 id: arrivalDelegate 0220 place: reservationFor.arrivalStation 0221 controller: root.controller 0222 isRangeEnd: true 0223 } 0224 0225 FormCard.FormDelegateSeparator { 0226 visible: arrivalDelegate 0227 } 0228 0229 FormCard.FormTextDelegate { 0230 text: i18n("Additional notes") 0231 description: arrival.notes.join("<br/>") 0232 descriptionItem.textFormat: Text.RichText 0233 descriptionItem.wrapMode: Text.Wrap 0234 visible: arrival.notes.length > 0 0235 font.italic: true 0236 onLinkActivated: Qt.openUrlExternally(link) 0237 } 0238 } 0239 0240 // seat reservation 0241 FormCard.FormHeader { 0242 visible: seatCard.visible 0243 title: i18n("Seat") 0244 } 0245 0246 FormCard.FormCard { 0247 id: seatCard 0248 visible: coachLabel.visible || seatLabel.visible || classLabel.visible || departureLayoutButton.visible || arrivalLayoutButton.visible 0249 FormCard.FormTextDelegate { 0250 id: coachLabel 0251 text: i18nc("coach of a train", "Coach:") 0252 description: root.reservation.reservedTicket ? root.reservation.reservedTicket.ticketedSeat.seatSection : '' 0253 visible: description 0254 } 0255 FormCard.FormDelegateSeparator { 0256 visible: root.reservation.reservedTicket ? root.reservation.reservedTicket.ticketedSeat.seatSection : false 0257 } 0258 FormCard.FormTextDelegate { 0259 id: seatLabel 0260 text: i18n("Seat:") 0261 description: root.reservation.reservedTicket ? root.reservation.reservedTicket.ticketedSeat.seatNumber : '' 0262 visible: description 0263 } 0264 FormCard.FormDelegateSeparator { 0265 visible: root.reservation.reservedTicket ? root.reservation.reservedTicket.ticketedSeat.seatNumber : false 0266 } 0267 FormCard.FormTextDelegate { 0268 id: classLabel 0269 text: i18n("Class:") 0270 description: root.reservation.reservedTicket ? root.reservation.reservedTicket.ticketedSeat.seatingType : '' 0271 visible: description 0272 } 0273 FormCard.FormDelegateSeparator { 0274 visible: classLabel.visible 0275 } 0276 FormCard.FormButtonDelegate { 0277 id: departureLayoutButton 0278 text: i18n("Departure Vehicle Layout") 0279 icon.name: "view-list-symbolic" 0280 enabled: departure && (departure.route.line.mode == KPublicTransport.Line.LongDistanceTrain || departure.route.line.mode == KPublicTransport.Line.Train || departure.route.name !== "") 0281 onClicked: applicationWindow().pageStack.push(vehicleLayoutPage, {stopover: root.controller.departure, arrival: false}) 0282 visible: enabled 0283 } 0284 FormCard.FormButtonDelegate { 0285 id: arrivalLayoutButton 0286 text: i18n("Arrival Vehicle Layout") 0287 icon.name: "view-list-symbolic" 0288 enabled: arrival && (arrival.route.line.mode == KPublicTransport.Line.LongDistanceTrain || arrival.route.line.mode == KPublicTransport.Line.Train || arrival.route.name !== "") 0289 onClicked: applicationWindow().pageStack.push(vehicleLayoutPage, {stopover: root.controller.arrival, arrival: true}); 0290 visible: enabled 0291 0292 } 0293 } 0294 0295 ProgramMembershipCard { 0296 programMembership: root.reservation.programMembershipUsed 0297 } 0298 0299 BookingCard { 0300 reservation: root.reservation 0301 } 0302 0303 ReservationDocumentsCard { 0304 controller: root.controller 0305 } 0306 0307 ActionsCard { 0308 batchId: root.batchId 0309 editor: root.editor 0310 reservation: root.reservation 0311 additionalActions: [ 0312 QQC2.Action { 0313 text: i18n("Alternatives") 0314 icon.name: "clock" 0315 onTriggered: applicationWindow().pageStack.push(alternativePage) 0316 }, 0317 Kirigami.Action { 0318 text: i18n("Journey Details") 0319 icon.name: "view-calendar-day" 0320 onTriggered: applicationWindow().pageStack.push(journeySectionPage, {"journeySection": root.controller.journey}); 0321 Component.onCompleted: { 0322 visible = Qt.binding(function() { return root.controller.journey && root.controller.journey.intermediateStops.length > 0}); 0323 } 0324 }, 0325 Kirigami.Action { 0326 text: "Test Notification" 0327 icon.name: "notifications" 0328 visible: Settings.developmentMode 0329 onTriggered: LiveDataManager.showNotification(root.batchId) 0330 } 0331 ] 0332 } 0333 } 0334 }