Warning, /pim/itinerary/src/app/BusDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2018 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 TimelineDelegate {
0015     id: root
0016     property bool expanded: false
0017     property var journeySection: root.controller.journey
0018     headerIconSource: departure.route.line.mode == Line.Unknown ? "qrc:///images/bus.svg" : PublicTransport.lineModeIcon(departure.route.line.mode)
0019     Item {
0020         JourneySectionModel {
0021             id: sectionModel
0022             journeySection: root.journeySection
0023         }
0024     }
0025 
0026     headerItem: RowLayout {
0027         QQC2.Label {
0028             id: headerLabel
0029             text: {
0030                 if (reservationFor.busName || reservationFor.busNumber ) {
0031                     return reservationFor.busName + " " + reservationFor.busNumber
0032                 }
0033                 return i18n("%1 to %2", reservationFor.departureBusStop.name, reservationFor.arrivalBusStop.name);
0034             }
0035             color: root.headerTextColor
0036             Accessible.ignored: true
0037         }
0038         QQC2.Label {
0039             text: departure.route.direction? "→ " + departure.route.direction : ""
0040             color: root.headerTextColor
0041             elide: Text.ElideRight
0042             Layout.fillWidth: true
0043         }
0044         QQC2.Label {
0045             text: Localizer.formatTime(reservationFor, "departureTime")
0046             color: root.headerTextColor
0047         }
0048         QQC2.Label {
0049             text: (departure.departureDelay >= 0 ? "+" : "") + departure.departureDelay
0050             color: (departure.departureDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0051             visible: departure.hasExpectedDepartureTime
0052             Accessible.ignored: !visible
0053         }
0054     }
0055 
0056 
0057     contentItem: Column {
0058         id: topLayout
0059 
0060         RowLayout {
0061             width: parent.width
0062             JourneySectionStopDelegateLineSegment {
0063 
0064                 Layout.fillHeight: true
0065                 lineColor: departure.route.line.hasColor ? departure.route.line.color : Kirigami.Theme.textColor
0066                 isDeparture: true
0067             }
0068 
0069             ColumnLayout{
0070                 Layout.bottomMargin:  Kirigami.Units.largeSpacing
0071 
0072                 spacing:0
0073                 Layout.fillHeight: true
0074                 Layout.fillWidth: true
0075                 RowLayout {
0076                     Layout.fillHeight: true
0077                     Layout.fillWidth: true
0078                     RowLayout {
0079                         Layout.minimumWidth: depTime.width + Kirigami.Units.largeSpacing * 3.5
0080                         QQC2.Label {
0081                             id: depTime
0082                             text: Localizer.formatTime(reservationFor, "departureTime")
0083                         }
0084                         QQC2.Label {
0085                             text: (departure.departureDelay >= 0 ? "+" : "") + departure.departureDelay
0086                             color: (departure.departureDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0087                             visible: departure.hasExpectedDepartureTime
0088                             Accessible.ignored: !visible
0089                         }
0090                     }
0091                     QQC2.Label {
0092                         Layout.fillWidth: true
0093                         font.bold: true
0094                         text: reservationFor.departureBusStop.name
0095                         elide: Text.ElideRight
0096                     }
0097                 }
0098 
0099                 RowLayout{
0100                     Item{
0101                         Layout.minimumWidth: depTime.width + Kirigami.Units.largeSpacing * 3.5
0102                     }
0103                     QQC2.Label {
0104                         Layout.fillWidth: true
0105 
0106                         visible: text.length > 0
0107                         text: Localizer.formatAddressWithContext(reservationFor.departureBusStop.address,
0108                                                                  reservationFor.arrivalBusStop.address,
0109                                                                  Settings.homeCountryIsoCode)
0110                         width: topLayout.width
0111                     }
0112                 }
0113             }
0114         }
0115 
0116         RowLayout {
0117             width: parent.width
0118             JourneySectionStopDelegateLineSegment {
0119                 Layout.fillHeight: true
0120                 lineColor: departure.route.line.hasColor ? departure.route.line.color : Kirigami.Theme.textColor
0121                 isDeparture: false
0122                 hasStop: false
0123             }
0124             QQC2.ToolButton {
0125                 visible: stopRepeater.count !== 0
0126                 Layout.fillWidth: true
0127                 onClicked: expanded = !expanded
0128                 contentItem: RowLayout {
0129                     spacing: 0
0130                     Kirigami.Icon {
0131                         source: expanded? "arrow-up" : "arrow-down"
0132                         implicitHeight: Kirigami.Units.largeSpacing*2
0133                         color: Kirigami.Theme.disabledTextColor
0134                     }
0135                     QQC2.Label {
0136                         text: i18np("1 intermediate stop", "%1 intermediate stops", stopRepeater.count)
0137                         color: Kirigami.Theme.disabledTextColor
0138                         Layout.rightMargin: Kirigami.Units.largeSpacing
0139                     }
0140                     Kirigami.Separator {
0141                         Layout.topMargin: Kirigami.Units.smallSpacing
0142                         Layout.bottomMargin: Kirigami.Units.smallSpacing
0143                         Layout.fillWidth: true
0144                     }
0145                 }
0146             }
0147             Kirigami.Separator {
0148                 visible: stopRepeater.count === 0
0149                 Layout.topMargin: Kirigami.Units.smallSpacing
0150                 Layout.bottomMargin: Kirigami.Units.smallSpacing
0151                 Layout.fillWidth: true
0152             }
0153         }
0154 
0155         Repeater {
0156             id: stopRepeater
0157             model: sectionModel
0158             delegate: RowLayout {
0159                 id: stopDelegate
0160                 property bool hidden: !expanded
0161 
0162                 clip: true
0163                 visible: false
0164                 onHiddenChanged:
0165                     if (!hidden) {
0166                         visible = true
0167                         showAnimation.running=true
0168                     } else {
0169                         hideAnimation.running = true
0170                     }
0171                 PropertyAnimation { id: showAnimation;
0172                                     target: stopDelegate;
0173                                     property: "height";
0174                                     from: 0;
0175                                     to: stopDelegate.implicitHeight;
0176                                     duration: 200
0177                                     easing.type: Easing.InOutCubic
0178                 }
0179 
0180                 PropertyAnimation { id: hideAnimation;
0181                                     target: stopDelegate;
0182                                     property: "height";
0183                                     from: stopDelegate.implicitHeight;
0184                                     to: 0;
0185                                     duration: 200
0186                                     onFinished: stopDelegate.visible = false
0187                                     easing.type: Easing.InOutCubic
0188 
0189                 }
0190                 width: parent.width
0191                 JourneySectionStopDelegateLineSegment {
0192 
0193                     Layout.fillHeight: true
0194                     lineColor: departure.route.line.hasColor ? departure.route.line.color : Kirigami.Theme.textColor
0195                     hasStop: model.stopover.disruptionEffect !== Disruption.NoService
0196                 }
0197                 RowLayout {
0198                     Layout.minimumWidth: depTime.width + Kirigami.Units.largeSpacing * 3.5
0199                     QQC2.Label{
0200                         text: Localizer.formatTime(model.stopover , "scheduledDepartureTime")
0201                         font.strikeout: model.stopover.disruptionEffect === Disruption.NoService
0202                     }
0203                     QQC2.Label {
0204                         text: (model.stopover.arrivalDelay >= 0 ? "+" : "") + model.stopover.arrivalDelay
0205                         color: (model.stopover.arrivalDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0206                         visible: model.stopover.hasExpectedArrivalTime && model.stopover.disruptionEffect !== Disruption.NoService
0207                         Accessible.ignored: !visible
0208                     }
0209                 }
0210                 QQC2.Label{
0211                     text: model.stopover.stopPoint.name
0212                     Layout.fillWidth: true
0213                     elide: Text.ElideRight
0214                     font.strikeout: model.stopover.disruptionEffect === Disruption.NoService
0215                 }
0216             }
0217         }
0218 
0219         RowLayout {
0220             width: parent.width
0221             JourneySectionStopDelegateLineSegment {
0222 
0223                 Layout.fillHeight: true
0224                 lineColor: departure.route.line.hasColor ? departure.route.line.color : Kirigami.Theme.textColor
0225                 isArrival: true
0226             }
0227             ColumnLayout{
0228                 Layout.topMargin:  Kirigami.Units.largeSpacing
0229 
0230                 spacing:0
0231                 Layout.fillHeight: true
0232                 Layout.fillWidth: true
0233                 RowLayout {
0234                     Layout.fillHeight: true
0235                     Layout.fillWidth: true
0236                     RowLayout {
0237                         Layout.minimumWidth: depTime.width + Kirigami.Units.largeSpacing * 3.5
0238                         QQC2.Label {
0239                             text: Localizer.formatTime(reservationFor, "arrivalTime")
0240                         }
0241                         QQC2.Label {
0242                             text: (arrival.arrivalDelay >= 0 ? "+" : "") + arrival.arrivalDelay
0243                             color: (arrival.arrivalDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0244                             visible: arrival.hasExpectedArrivalTime
0245                             Accessible.ignored: !visible
0246                         }
0247                     }
0248                     QQC2.Label {
0249                         Layout.fillWidth: true
0250                         font.bold: true
0251                         text: reservationFor.arrivalBusStop.name
0252                         elide: Text.ElideRight
0253                     }
0254                 }
0255 
0256                 RowLayout {
0257                     Item{
0258                         Layout.minimumWidth: depTime.width + Kirigami.Units.largeSpacing * 3.5
0259                     }
0260                     QQC2.Label {
0261                         Layout.fillWidth: true
0262 
0263                         visible: text.length > 0
0264                         width: topLayout.width
0265                         text: Localizer.formatAddressWithContext(reservationFor.arrivalBusStop.address,
0266                                                                  reservationFor.departureBusStop.address,
0267                                                                  Settings.homeCountryIsoCode)
0268                     }
0269                 }
0270             }
0271         }
0272     }
0273 
0274     onClicked: showDetailsPage(busDetailsPage, root.batchId)
0275     Accessible.name: headerLabel.text
0276 }