Warning, /pim/itinerary/src/app/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 QtLocation as QtLocation
0011 import QtPositioning as QtPositioning
0012 import org.kde.kirigami as Kirigami
0013 import org.kde.kirigamiaddons.formcard as FormCard
0014 import org.kde.kirigamiaddons.components as Components
0015 import org.kde.kpublictransport
0016 import org.kde.itinerary
0017
0018
0019 Kirigami.Page {
0020 id: root
0021 Kirigami.Theme.inherit: false
0022 Kirigami.Theme.colorSet: Kirigami.Theme.View
0023
0024 title: i18n("Journey Details")
0025
0026 property var journeySection
0027 property alias showProgress: sectionModel.showProgress
0028 property alias enableMapView: mapButton.visible
0029 default property alias _children: root.children
0030
0031 Kirigami.ColumnView.preventStealing: view.currentItem.objectName === "sectionMap"
0032
0033 padding: 0
0034 header: ColumnLayout {
0035 spacing: 0
0036 visible: root.journeySection != undefined
0037
0038 GridLayout {
0039 columns: 2
0040 columnSpacing: Kirigami.Units.largeSpacing
0041 rows: 4
0042 rowSpacing: 0
0043
0044 Layout.margins: Kirigami.Units.gridUnit
0045
0046 TransportIcon {
0047 Layout.rowSpan: 4
0048 Layout.alignment: Qt.AlignTop
0049 Layout.rightMargin: Kirigami.Units.largeSpacing
0050 id: icon
0051 source: PublicTransport.lineIcon(journeySection.route.line)
0052 Layout.preferredWidth: height
0053 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0054 isMask: !journeySection.route.line.hasLogo && !journeySection.route.line.hasModeLogo
0055 }
0056
0057 QQC2.Label {
0058 Layout.row: 0
0059 Layout.column: 1
0060 Layout.fillWidth: true
0061 text: "<b>" + journeySection.route.line.modeString + " " + journeySection.route.line.name + "</b>"
0062 }
0063
0064 QQC2.Label {
0065 Layout.row: 1
0066 Layout.column: 1
0067 Layout.columnSpan: 2
0068 text: i18n("Direction: %1", journeySection.route.direction)
0069 visible: journeySection.route.direction !== ""
0070 }
0071
0072 QQC2.Label {
0073 Layout.row: 2
0074 Layout.column: 1
0075 Layout.columnSpan: 2
0076 text: i18n("Distance: %1", Localizer.formatDistance(journeySection.distance))
0077 visible: journeySection.distance > 0
0078 }
0079 QQC2.Label {
0080 Layout.row: 3
0081 Layout.column: 1
0082 Layout.columnSpan: 2
0083 text: i18n("Average Speed: %1", Localizer.formatSpeed(journeySection.distance / journeySection.duration * 3.6))
0084 visible: journeySection.distance > 0 && journeySection.duration > 0
0085 }
0086 QQC2.Label {
0087 Layout.row: 4
0088 Layout.column: 1
0089 Layout.columnSpan: 2
0090 text: i18n("CO₂: %1", Localizer.formatWeight(journeySection.co2Emission))
0091 visible: journeySection.co2Emission > 0
0092 }
0093
0094 QQC2.Label {
0095 id: notesLabel
0096 Layout.row: 5
0097 Layout.column: 1
0098 Layout.columnSpan: 2
0099 Layout.fillWidth: true
0100 text: journeySection.notes.join("<br/>")
0101 textFormat: Text.RichText
0102 wrapMode: Text.Wrap
0103 verticalAlignment: Text.AlignTop
0104 // Doesn't work with RichText.
0105 elide: Text.ElideRight
0106 maximumLineCount: 5
0107 Layout.maximumHeight: Kirigami.Units.gridUnit * maximumLineCount
0108 clip: true
0109 visible: journeySection.notes.length > 0
0110 font.italic: true
0111 onLinkActivated: Qt.openUrlExternally(link)
0112
0113 SheetDrawer {
0114 id: moreNotesSheet
0115 contentItem: QQC2.Label {
0116 Layout.fillWidth: true
0117 text: journeySection.notes.join("<br/>")
0118 textFormat: Text.RichText
0119 wrapMode: Text.Wrap
0120 onLinkActivated: Qt.openUrlExternally(link)
0121 padding: Kirigami.Units.largeSpacing * 2
0122 }
0123 }
0124 }
0125
0126 Kirigami.LinkButton {
0127 Layout.row: 6
0128 Layout.column: 1
0129 Layout.columnSpan: 2
0130 text: i18nc("@action:button", "Show More…")
0131 visible: notesLabel.implicitHeight > notesLabel.height
0132 onClicked: {
0133 moreNotesSheet.open();
0134 }
0135 }
0136 }
0137
0138 Kirigami.Separator {
0139 Layout.fillWidth: true
0140 }
0141 }
0142 JourneySectionModel {
0143 id: sectionModel
0144 journeySection: root.journeySection
0145
0146 }
0147 SheetDrawer {
0148 id: sheetDrawer
0149 property var stop
0150 property bool isDeparture: false
0151 property bool isArrival: false
0152 anchors.fill: parent
0153 headerItem: Component {
0154 RowLayout {
0155 id: headerLayout
0156
0157 Kirigami.Heading {
0158 text: sheetDrawer.stop.stopPoint.name
0159 Layout.fillWidth: true
0160 Layout.leftMargin: Kirigami.Units.largeSpacing
0161 elide: Qt.ElideRight
0162 }
0163 QQC2.Label {
0164 id: departureTime
0165 Layout.rightMargin: delayLabel.visible ? 0:Kirigami.Units.largeSpacing
0166 text: Localizer.formatTime(sheetDrawer.stop, "scheduledDepartureTime")
0167 // visible: sheetDrawer.stop.scheduledDepartureTime > 0
0168 font.strikeout: sheetDrawer.stop.disruptionEffect === Disruption.NoService
0169 }
0170
0171 QQC2.Label {
0172 id: delayLabel
0173 Layout.rightMargin: Kirigami.Units.largeSpacing
0174 text: (sheetDrawer.stop.departureDelay >= 0 ? "+" : "") + sheetDrawer.stop.departureDelay
0175 color: sheetDrawer.stop.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0176 visible: departureTime.visible && sheetDrawer.stop.hasExpectedDepartureTime && sheetDrawer.stop.disruptionEffect !== Disruption.NoService
0177 }
0178 }
0179 }
0180
0181
0182
0183 contentItem: Component{
0184
0185 ColumnLayout {
0186 id: contentLayout
0187 spacing:0
0188 width: parent.width
0189 FormCard.FormTextDelegate {
0190 Layout.fillWidth: true
0191 id: platformDelegate
0192 text: i18n("Platform:")
0193 description: {
0194 const platform = sheetDrawer.stop.hasExpectedPlatform ? sheetDrawer.stop.expectedPlatform : sheetDrawer.stop.scheduledPlatform;
0195
0196 if (platform.length === 0) {
0197 return '';
0198 }
0199
0200 switch (sheetDrawer.stop.route.line.mode) {
0201 case Line.Train:
0202 case Line.Funicular:
0203 case Line.LocalTrain:
0204 case Line.LongDistanceTrain:
0205 case Line.Metro:
0206 case Line.RailShuttle:
0207 case Line.RapidTransit:
0208 case Line.Tramway:
0209 return platform
0210 case Line.Ferry:
0211 return platform
0212 default:
0213 return platform
0214 }
0215 }
0216 visible: description
0217 }
0218 FormCard.AbstractFormDelegate {
0219 Layout.fillWidth: true
0220 visible: sheetDrawer.stop.loadInformation != ""
0221 contentItem: ColumnLayout {
0222 spacing: Kirigami.Units.mediumSpacing
0223
0224 QQC2.Label {
0225 text: i18n("Vehicle Load:")
0226 elide: Text.ElideRight
0227 Layout.fillWidth: true
0228 Accessible.ignored: true
0229 }
0230 VehicleLoadIndicator {
0231 loadInformation: sheetDrawer.stop.loadInformation
0232 }
0233 }
0234
0235 background: Item{}
0236 }
0237 Item{Layout.fillHeight: true}
0238 FormCard.FormDelegateSeparator {}
0239 FormCard.FormButtonDelegate {
0240 Layout.fillWidth: true
0241 text: i18n("Show location")
0242 icon.name: "map-symbolic"
0243 onClicked: {
0244 sheetDrawer.close()
0245 const args = {
0246 coordinate: Qt.point(sheetDrawer.stop.stopPoint.longitude, sheetDrawer.stop.stopPoint.latitude),
0247 placeName: sheetDrawer.stop.stopPoint.name
0248 };
0249 if (!sheetDrawer.isDeparture) {
0250 args.arrivalPlatformName = sheetDrawer.stop.hasExpectedPlatform ? sheetDrawer.stop.expectedPlatform : sheetDrawer.stop.scheduledPlatform;
0251 args.arrivalPlatformMode = PublicTransport.lineModeToPlatformMode(sheetDrawer.stop.route.line.mode);
0252 args.arrivalPlatformIfopt = sheetDrawer.stop.stopPoint.identifier("ifopt");
0253 }
0254 if (!sheetDrawer.isArrival) {
0255 args.departurePlatformName = sheetDrawer.stop.hasExpectedPlatform ? sheetDrawer.stop.expectedPlatform : sheetDrawer.stop.scheduledPlatform;
0256 args.departurePlatformMode = PublicTransport.lineModeToPlatformMode(sheetDrawer.stop.route.line.mode);
0257 args.departurePlatformIfopt = sheetDrawer.stop.stopPoint.identifier("ifopt");
0258 }
0259
0260 // ensure the map page ends up on top
0261 if (applicationWindow().pageStack.layers.depth < 2)
0262 applicationWindow().pageStack.push(indoorMapPage, args);
0263 else
0264 applicationWindow().pageStack.layers.push(indoorMapPage, args);
0265 }
0266 }
0267 }
0268 }
0269
0270 }
0271
0272 ColumnLayout{
0273 anchors.fill: parent
0274 spacing: 0
0275
0276 QQC2.SwipeView {
0277 id: view
0278 clip: true
0279 interactive: root.enableMapView
0280 Layout.fillHeight: true
0281 Layout.fillWidth: true
0282 Item {
0283 id: listPage
0284
0285 objectName: "sectionList"
0286
0287 QQC2.ScrollView{
0288 id: scrollview
0289 anchors.fill: parent
0290
0291 ListView {
0292 clip: true
0293 model: sectionModel
0294 header: JourneySectionStopDelegate {
0295 stop: journeySection.departure
0296 isDeparture: true
0297 trailingProgress: sectionModel.departureTrailingProgress
0298 stopoverPassed: sectionModel.departed
0299 Binding {
0300 target: sectionModel
0301 property: "departureTrailingSegmentLength"
0302 value: trailingSegmentLength
0303 }
0304 visible: root.journeySection != undefined
0305 }
0306 delegate: JourneySectionStopDelegate {
0307 stop: model.stopover
0308 leadingProgress: model.leadingProgress
0309 trailingProgress: model.trailingProgress
0310 stopoverPassed: model.stopoverPassed
0311 Binding {
0312 target: model
0313 property: "leadingLength"
0314 value: leadingSegmentLength
0315 }
0316 Binding {
0317 target: model
0318 property: "trailingLength"
0319 value: trailingSegmentLength
0320 }
0321 }
0322 footer: JourneySectionStopDelegate {
0323 stop: journeySection.arrival
0324 isArrival: true
0325 leadingProgress: sectionModel.arrivalLeadingProgress
0326 stopoverPassed: sectionModel.arrived
0327 Binding {
0328 target: sectionModel
0329 property: "arrivalLeadingSegmentLength"
0330 value: leadingSegmentLength
0331 }
0332 visible: root.journeySection != undefined
0333 }
0334 }
0335 }
0336 }
0337 Item {
0338 id: mapPage
0339
0340 objectName: "sectionMap"
0341
0342 MapView {
0343 id: map
0344 anchors.fill: parent
0345 QtLocation.MapPolyline {
0346 id: line
0347 line.width: 10
0348 line.color: journeySection.route.line.hasColor ? journeySection.route.line.color : Kirigami.Theme.textColor
0349 path: PublicTransport.pathToGeoCoordinates(journeySection)
0350 }
0351
0352 QtLocation.MapQuickItem {
0353 coordinate {
0354
0355 latitude: journeySection.departure.stopPoint.latitude
0356 longitude: journeySection.departure.stopPoint.longitude
0357 }
0358 anchorPoint.x: sourceItem.width/2
0359 anchorPoint.y: sourceItem.height/2
0360 sourceItem: Rectangle {
0361 width:15
0362 height:15
0363 radius: height/2
0364 border.width: 2
0365 border.color: line.line.color
0366 MouseArea {
0367 anchors.fill: parent
0368 scale: 2
0369 onClicked: {
0370 sheetDrawer.open()
0371 sheetDrawer.isArrival = false
0372 sheetDrawer.isDeparture = true
0373 sheetDrawer.stop = journeySection.departure
0374 }
0375 }
0376 }
0377 }
0378
0379 Repeater {
0380 model: sectionModel
0381
0382 QtLocation.MapQuickItem {
0383 coordinate {
0384
0385 latitude: model.stopover.stopPoint.latitude
0386 longitude: model.stopover.stopPoint.longitude
0387 }
0388 anchorPoint.x: sourceItem.width/2
0389 anchorPoint.y: sourceItem.height/2
0390 sourceItem: Rectangle {
0391 width: 6
0392 height: 6
0393 radius: height/2
0394 opacity: 0.5
0395 MouseArea {
0396 anchors.fill: parent
0397 scale: 3
0398 onClicked: {
0399 sheetDrawer.open()
0400 sheetDrawer.isArrival = false
0401 sheetDrawer.isDeparture = false
0402 sheetDrawer.stop = model.stopover
0403 }
0404 }
0405 }
0406 }
0407 }
0408 QtLocation.MapQuickItem {
0409 coordinate {
0410
0411 latitude: journeySection.arrival.stopPoint.latitude
0412 longitude: journeySection.arrival.stopPoint.longitude
0413 }
0414 anchorPoint.x: sourceItem.width/2
0415 anchorPoint.y: sourceItem.height/2
0416
0417 Component.onCompleted: {
0418 map.center.latitude = line.path[(line.pathLength()/2).toFixed(0)].latitude
0419 map.center.longitude = line.path[(line.pathLength()/2).toFixed(0)].longitude
0420 }
0421 sourceItem: Rectangle {
0422 width:15
0423 height:15
0424 radius: height/2
0425 border.width: 2
0426 border.color: line.line.color
0427 MouseArea {
0428 anchors.fill: parent
0429 scale: 2
0430 onClicked: {
0431 sheetDrawer.open()
0432 sheetDrawer.isArrival = true
0433 sheetDrawer.isDeparture = false
0434 sheetDrawer.stop = journeySection.arrival
0435 }
0436 }
0437 }
0438 }
0439 }
0440 }
0441 }
0442 }
0443
0444 Components.FloatingButton {
0445 id: mapButton
0446 icon.name: checked ? "format-list-unordered" : "map-gnomonic"
0447 text: i18nc("@action:button", "Show Map")
0448 onClicked: view.currentIndex === 0 ? view.currentIndex = 1 : view.currentIndex = 0
0449 checkable: true
0450 checked: view.currentIndex === 1
0451
0452 anchors {
0453 right: parent.right
0454 rightMargin: Kirigami.Units.largeSpacing + (scrollview.QQC2.ScrollBar && scrollview.QQC2.ScrollBar.vertical ? scrollview.QQC2.ScrollBar.vertical.width : 0)
0455 bottom: parent.bottom
0456 bottomMargin: Kirigami.Units.largeSpacing
0457 }
0458
0459 }
0460
0461
0462 }