Warning, /pim/itinerary/src/app/JourneySummaryDelegate.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0004
0005 SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007
0008 import QtQuick
0009 import QtQuick.Layouts
0010 import QtQuick.Controls as QQC2
0011 import org.kde.kirigami as Kirigami
0012 import org.kde.kirigamiaddons.formcard as FormCard
0013 import org.kde.kpublictransport
0014 import org.kde.itinerary
0015
0016 FormCard.AbstractFormDelegate {
0017 id: root
0018
0019 required property var journey
0020
0021 function maxLoad(loadInformation) {
0022 var load = Load.Unknown;
0023 for (var i = 0; i < loadInformation.length; ++i) {
0024 load = Math.max(load, loadInformation[i].load);
0025 }
0026 return load;
0027 }
0028
0029 readonly property int sectionWithMaxLoad: {
0030 var loadMax = Load.Unknown;
0031 var loadMaxIdx = -1;
0032 for (var i = 0; root.journey != undefined && i < root.journey.sections.length; ++i) {
0033 var l = maxLoad(root.journey.sections[i].loadInformation);
0034 if (l > loadMax) {
0035 loadMax = l;
0036 loadMaxIdx = i;
0037 }
0038 }
0039 return loadMaxIdx;
0040 }
0041
0042 contentItem: ColumnLayout {
0043 RowLayout {
0044 Repeater {
0045 model: root.journey.sections
0046 delegate: TransportIcon {
0047 source: PublicTransport.journeySectionIcon(modelData)
0048 color: PublicTransport.warnAboutSection(modelData) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0049 isMask: modelData.mode != JourneySection.PublicTransport || (!modelData.route.line.hasLogo && !modelData.route.line.hasModeLogo)
0050 size: Kirigami.Units.iconSizes.small
0051 Accessible.name: PublicTransport.journeySectionLabel(modelData)
0052 }
0053 }
0054 QQC2.Label {
0055 text: i18ncp("number of switches to another transport", "One change", "%1 changes", root.journey.numberOfChanges)
0056 Layout.fillWidth: true
0057 Accessible.ignored: !parent.visible
0058 }
0059
0060 VehicleLoadIndicator {
0061 loadInformation: sectionWithMaxLoad < 0 ? undefined : root.journey.sections[sectionWithMaxLoad].loadInformation
0062 }
0063 }
0064
0065 QQC2.Label {
0066 text: i18n("Click to extend")
0067 }
0068 }
0069 }