Warning, /utilities/ktrip/src/qml/ConnectionDetailsPage.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 import QtQuick 2.2
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Controls 2.4
0010 import org.kde.kirigami 2.4 as Kirigami
0011 import org.kde.kpublictransport 1.0
0012 import org.kde.ktrip 1.0
0013 
0014 Kirigami.ScrollablePage {
0015     id: root
0016     title: i18nc("@title", "Details")
0017 
0018     property var journey
0019 
0020     Kirigami.CardsListView {
0021         model: root.journey.sections
0022 
0023         delegate: Loader {
0024             width: parent.width
0025 
0026             sourceComponent: {
0027                 switch (model.modelData.mode) {
0028                 case JourneySection.Walking:
0029                     return walking;
0030                 case JourneySection.Waiting:
0031                     return waiting;
0032                 case JourneySection.Transfer:
0033                     return transfer;
0034                 default:
0035                     return cardComponent;
0036                 }
0037             }
0038             property var theData: model.modelData
0039         }
0040     }
0041 
0042     Component {
0043         id: walking
0044         Label {
0045             text: i18np("Walking (%1 minute)", "Walking (%1 minutes)", theData.duration / 60)
0046             horizontalAlignment: Text.AlignHCenter
0047         }
0048     }
0049 
0050     Component {
0051         id: waiting
0052         Label {
0053             text: i18np("Waiting (%1 minute)", "Waiting (%1 minutes)", theData.duration / 60)
0054             horizontalAlignment: Text.AlignHCenter
0055         }
0056     }
0057 
0058     Component {
0059         id: transfer
0060         Label {
0061             text: i18np("Transfer (%1 minute)", "Transfer (%1 minutes)", theData.duration / 60)
0062             horizontalAlignment: Text.AlignHCenter
0063         }
0064     }
0065 
0066     Component {
0067         id: cardComponent
0068 
0069         Kirigami.AbstractCard {
0070             id: cardDelegate
0071 
0072             header: Column {
0073 
0074                 RowLayout {
0075                     width: parent.width
0076                     Kirigami.Icon {
0077                         visible: theData.route.line.hasLogo
0078                         source: theData.route.line.logo
0079                         Layout.fillHeight: true
0080                         Layout.preferredWidth: height
0081                     }
0082 
0083                     Kirigami.Heading {
0084                         id: headerLabel
0085                         level: 4
0086                         font.strikeout: theData.disruptionEffect == Disruption.NoService
0087                         color: theData.disruptionEffect == Disruption.NoService ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0088                         text: theData.route.line.name
0089                     }
0090 
0091                     Item {
0092                         Layout.fillWidth: true
0093                     }
0094 
0095                     Button {
0096                         icon.name: intermediateStops.expanded ? "collapse" : "expand"
0097                         text: intermediateStops.expanded ? i18n("Hide intermediate Stops") : i18n("Show intermediate Stops")
0098                         display: Button.IconOnly
0099                         flat: true
0100                         Layout.preferredWidth: height // Work around Material button being too wide
0101                         onClicked: intermediateStops.expanded = !intermediateStops.expanded
0102                     }
0103                 }
0104 
0105                 Item {
0106                     width: 1
0107                     height: cardDelegate.topPadding
0108                 }
0109 
0110                 Kirigami.Separator {
0111                     anchors.left: parent.left
0112                     anchors.right: parent.right
0113                 }
0114             }
0115 
0116             contentItem: Column {
0117                 id: topLayout
0118 
0119                 RowLayout {
0120                     width: parent.width
0121                     Label {
0122                         text: theData.scheduledDepartureTime.toLocaleTimeString(Locale.ShortFormat)
0123                     }
0124 
0125                     Label {
0126                         text: theData.expectedDepartureTime.toLocaleTimeString(Locale.ShortFormat)
0127                         visible: theData.departureDelay > 0
0128                         color: Kirigami.Theme.negativeTextColor
0129                     }
0130 
0131                     Label {
0132                         text: theData.from.name
0133                         wrapMode: Text.Wrap
0134                         Layout.fillWidth: true
0135                     }
0136 
0137                     Button {
0138                         visible: theData.from.hasCoordinate
0139                         icon.name: "mark-location-symbolic"
0140                         flat: true
0141                         Layout.preferredWidth: height // Work around Material button being too wide
0142                         onClicked: Controller.showOnMap(theData.from)
0143                     }
0144 
0145                     Label {
0146                         text: theData.scheduledDeparturePlatform
0147                     }
0148                 }
0149 
0150                 Repeater {
0151                     id: intermediateStops
0152 
0153                     property var expanded: false
0154                     model: theData.intermediateStops
0155 
0156                     delegate: RowLayout {
0157                         visible: intermediateStops.expanded
0158                         width: parent.width
0159 
0160                         Item {
0161                             width: 3 * Kirigami.Units.largeSpacing
0162                         }
0163 
0164                         Label {
0165                             text: modelData.scheduledDepartureTime.toLocaleTimeString(Locale.ShortFormat)
0166                         }
0167 
0168                         Label {
0169                             text: modelData.expectedDepartureTime.toLocaleTimeString(Locale.ShortFormat)
0170                             visible: modelData.departureDelay > 0
0171                             color: Kirigami.Theme.negativeTextColor
0172                         }
0173 
0174                         Label {
0175                             text: modelData.stopPoint.name
0176                             wrapMode: Text.Wrap
0177                             Layout.fillWidth: true
0178                         }
0179 
0180                         Label {
0181                             text: modelData.scheduledPlatform
0182                         }
0183                     }
0184                 }
0185 
0186                 RowLayout {
0187                     width: parent.width
0188                     Label {
0189                         text: theData.scheduledArrivalTime.toLocaleTimeString(Locale.ShortFormat)
0190                     }
0191 
0192                     Label {
0193                         text: theData.expectedArrivalTime.toLocaleTimeString(Locale.ShortFormat)
0194                         visible: theData.arrivalDelay > 0
0195                         color: Kirigami.Theme.negativeTextColor
0196                     }
0197 
0198                     Label {
0199                         text: theData.to.name
0200                         wrapMode: Text.Wrap
0201                         Layout.fillWidth: true
0202                     }
0203 
0204                     Button {
0205                         visible: theData.to.hasCoordinate
0206                         icon.name: "mark-location-symbolic"
0207                         flat: true
0208                         Layout.preferredWidth: height // Work around Material button being too wide
0209                         onClicked: Controller.showOnMap(theData.to)
0210                     }
0211 
0212                     Label {
0213                         text: theData.scheduledArrivalPlatform
0214                     }
0215                 }
0216 
0217                 Label {
0218                     text: theData.notes.join("<br>")
0219                     onLinkActivated: link => Qt.openUrlExternally(link)
0220                     topPadding: Kirigami.Units.largeSpacing
0221                     width: parent.width
0222                     wrapMode: Text.Wrap
0223                 }
0224             }
0225         }
0226     }
0227 }