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