Warning, /utilities/ktrip/src/qml/ConnectionsPage.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.12 as Kirigami
0011 import org.kde.kpublictransport 1.0 as KPT
0012 import org.kde.ktrip 1.0
0013 
0014 Kirigami.ScrollablePage
0015 {
0016     title: i18nc("@title", "Connections")
0017 
0018     header: Kirigami.InlineMessage {
0019         type: Kirigami.MessageType.Error
0020         text: theModel.errorMessage
0021         visible: theModel.errorMessage != ""
0022     }
0023 
0024     ListView {
0025 
0026         id: connectionList
0027 
0028         model: KPT.JourneyQueryModel {
0029             id: theModel
0030             request: Controller.createJourneyRequest()
0031             manager: Manager
0032         }
0033 
0034         header: ToolButton {
0035             width: parent.width
0036             visible: theModel.canQueryPrevious
0037             onClicked: theModel.queryPrevious()
0038             icon.name: "go-up-symbolic"
0039         }
0040 
0041         delegate: Kirigami.AbstractListItem {
0042 
0043             highlighted: false
0044             onClicked: pageStack.push(Qt.resolvedUrl("ConnectionDetailsPage.qml"), {journey: journey})
0045             readonly property bool cancelled: journey.disruptionEffect == KPT.Disruption.NoService
0046             readonly property var firstSection: journey.sections[0]
0047             readonly property var lastSection: journey.sections[journey.sections.length - 1]
0048 
0049             Column {
0050 
0051                 ConnectionHeading {
0052                     journey: model.journey
0053                 }
0054 
0055                 RowLayout {
0056                     width: parent.width
0057                     Label {
0058                         text: i18n("%1 %2", firstSection.scheduledDepartureTime.toLocaleTimeString(Locale.ShortFormat), firstSection.from.name)
0059                         font.strikeout: cancelled
0060                     }
0061 
0062                     Label {
0063                         visible: firstSection.hasExpectedDepartureTime
0064                         text: i18n("+%1", firstSection.departureDelay)
0065                         color: firstSection.departureDelay > 0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0066                         font.strikeout: cancelled
0067                     }
0068 
0069                     Item {
0070                         Layout.fillWidth: true
0071                     }
0072 
0073                     Label {
0074                         text: i18np("%1 change", "%1 changes", journey.numberOfChanges)
0075                         visible: journey.numberOfChanges > 0
0076                         font.strikeout: cancelled
0077                         Layout.alignment: Qt.AlignRight
0078                     }
0079                 }
0080 
0081                 RowLayout {
0082                     width: parent.width
0083                     Label {
0084                         text: i18n("%1 %2", lastSection.scheduledArrivalTime.toLocaleTimeString(Locale.ShortFormat), lastSection.to.name)
0085                         font.strikeout: cancelled
0086                     }
0087                     Label {
0088                         Layout.fillWidth: true
0089                         visible: lastSection.hasExpectedArrivalTime
0090                         text: i18n("+%1", lastSection.arrivalDelay)
0091                         color: lastSection.arrivalDelay > 0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
0092                         font.strikeout: cancelled
0093                     }
0094                 }
0095             }
0096         }
0097 
0098         footer: ToolButton {
0099             width: parent.width
0100             visible: theModel.canQueryNext
0101             onClicked: theModel.queryNext()
0102             icon.name: "go-down-symbolic"
0103         }
0104 
0105         Kirigami.PlaceholderMessage {
0106             text: i18n("No connections found")
0107             anchors.centerIn: parent
0108             visible: connectionList.count === 0 && !theModel.loading
0109         }
0110 
0111         BusyIndicator {
0112             running: theModel.loading
0113             anchors.centerIn: parent
0114         }
0115     }
0116 }