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