Warning, /pim/itinerary/src/app/AlternativeJourneyPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019-2021 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls as QQC2 0010 import org.kde.kirigami as Kirigami 0011 import org.kde.kpublictransport 0012 import org.kde.itinerary 0013 0014 JourneyQueryPage { 0015 id: root 0016 0017 required property QtObject controller 0018 0019 title: i18n("Alternative Connections") 0020 0021 journeyRequest: controller.journeyRequestFull 0022 0023 function updateRequest() { 0024 root.journeyRequest = fullJourneyAction.chhecked ? controller.journexRequestFull : controller.journeyRequestOne; 0025 0026 let allLineModes = true; 0027 for (const s of [longDistanceModeAction, localTrainModeAction, rapidTransitModeAction, busModeAction, ferryModeAction]) { 0028 if (!s.checked) { 0029 allLineModes = false; 0030 } 0031 } 0032 0033 let lineModes = []; 0034 if (!allLineModes) { 0035 if (longDistanceModeAction.checked) 0036 lineModes.push(Line.LongDistanceTrain, Line.Train); 0037 if (localTrainModeAction.checked) 0038 lineModes.push(Line.LocalTrain); 0039 if (rapidTransitModeAction.checked) 0040 lineModes.push(Line.RapidTransit, Line.Metro, Line.Tramway, Line.RailShuttle); 0041 if (busModeAction.checked) 0042 lineModes.push(Line.Bus, Line.Coach); 0043 if (ferryModeAction.checked) 0044 lineModes.push(Line.Ferry, Line.Boat); 0045 } 0046 root.journeyRequest.lineModes = lineModes; 0047 return req; 0048 } 0049 0050 onJourneyChanged: replaceWarningDialog.open() 0051 0052 Component.onCompleted: { 0053 for (const action of [fullJourneyAction, oneJourneyAction, actionSeparator, longDistanceModeAction, localTrainModeAction, rapidTransitModeAction, busModeAction, ferryModeAction]) { 0054 actions.push(action); 0055 } 0056 } 0057 0058 data: [ 0059 QQC2.ActionGroup { id: journeyActionGroup }, 0060 Kirigami.Action { 0061 id: fullJourneyAction 0062 text: i18nc("to travel destination", "To %1", controller.journeyRequestFull.to.name) 0063 checkable: true 0064 checked: controller.journeyRequestFull.to.name == root.journeyRequest.to.name 0065 icon.name: "go-next-symbolic" 0066 visible: controller.journeyRequestFull.to.name != controller.journeyRequestOne.to.name 0067 QQC2.ActionGroup.group: journeyActionGroup 0068 onTriggered: updateRequest() 0069 }, 0070 Kirigami.Action { 0071 id: oneJourneyAction 0072 text: i18nc("to travel destination", "To %1", controller.journeyRequestOne.to.name) 0073 checkable: true 0074 checked: controller.journeyRequestOne.to.name == root.journeyRequest.to.name 0075 icon.name: "go-next-symbolic" 0076 visible: controller.journeyRequestFull.to.name != controller.journeyRequestOne.to.name 0077 QQC2.ActionGroup.group: journeyActionGroup 0078 onTriggered: updateRequest() 0079 }, 0080 0081 Kirigami.Action { 0082 id: actionSeparator 0083 separator: true 0084 }, 0085 0086 Kirigami.Action { 0087 id: longDistanceModeAction 0088 text: i18nc("journey query search constraint, title", "Long distance trains") 0089 icon.source: PublicTransport.lineModeIcon(Line.LongDistanceTrain) 0090 checkable: true 0091 checked: true 0092 onTriggered: updateRequest() 0093 }, 0094 Kirigami.Action { 0095 id: localTrainModeAction 0096 text: i18nc("journey query search constraint, title", "Local trains") 0097 icon.source: PublicTransport.lineModeIcon(Line.LocalTrain) 0098 checkable: true 0099 checked: true 0100 onTriggered: updateRequest() 0101 }, 0102 Kirigami.Action { 0103 id: rapidTransitModeAction 0104 text: i18nc("journey query search constraint, title", "Rapid transit") 0105 icon.source: PublicTransport.lineModeIcon(Line.Tramway) 0106 checkable: true 0107 checked: true 0108 onTriggered: updateRequest() 0109 }, 0110 Kirigami.Action { 0111 id: busModeAction 0112 text: i18nc("journey query search constraint, title", "Bus") 0113 icon.source: PublicTransport.lineModeIcon(Line.Bus) 0114 checkable: true 0115 checked: true 0116 onTriggered: updateRequest() 0117 }, 0118 Kirigami.Action { 0119 id: ferryModeAction 0120 text: i18nc("journey query search constraint, title", "Ferry") 0121 icon.source: PublicTransport.lineModeIcon(Line.Ferry) 0122 checkable: true 0123 checked: true 0124 onTriggered: updateRequest() 0125 }, 0126 0127 Kirigami.PromptDialog { 0128 id: replaceWarningDialog 0129 0130 title: i18n("Replace Journey") 0131 subtitle: i18n("Do you really want to replace your existing reservation with the newly selected journey?") 0132 standardButtons: QQC2.Dialog.No 0133 customFooterActions: [ 0134 Kirigami.Action { 0135 text: i18n("Replace") 0136 icon.name: "document-save" 0137 onTriggered: { 0138 controller.applyJourney(root.journey, root.journeyRequest.to.name == controller.journeyRequestFull.to.name); 0139 replaceWarningDialog.close() 0140 applicationWindow().pageStack.pop(); 0141 } 0142 } 0143 ] 0144 } 0145 ] 0146 }