Warning, /pim/itinerary/src/app/PublicTransportBackendPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 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.i18n.localeData 0012 import org.kde.kpublictransport as KPublicTransport 0013 import org.kde.itinerary 0014 0015 Kirigami.ScrollablePage { 0016 id: root 0017 title: i18n("Public Transport Information Sources") 0018 0019 property alias publicTransportManager: backendModel.manager 0020 0021 KPublicTransport.BackendModel { 0022 id: backendModel 0023 mode: KPublicTransport.BackendModel.GroupByCountry 0024 } 0025 0026 Component { 0027 id: backendDelegate 0028 QQC2.ItemDelegate { 0029 id: delegate 0030 highlighted: false 0031 enabled: model.itemEnabled 0032 width: ListView.view.width 0033 text: model.name 0034 0035 contentItem: Item { 0036 anchors.margins: Kirigami.Units.largeSpacing 0037 implicitHeight: childrenRect.height 0038 0039 QQC2.Label { 0040 id: nameLabel 0041 text: model.name 0042 anchors.left: parent.left 0043 anchors.top: parent.top 0044 anchors.right: securityIcon.left 0045 anchors.rightMargin: Kirigami.Units.largeSpacing 0046 // try to retain trailing abbreviations when we have to elide 0047 elide: text.endsWith(")") ? Text.ElideMiddle : Text.ElideRight 0048 Accessible.ignored: true 0049 } 0050 Kirigami.Icon { 0051 id: securityIcon 0052 source: model.isSecure ? "channel-secure-symbolic" : "channel-insecure-symbolic" 0053 color: model.isSecure ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.negativeTextColor 0054 width: height 0055 height: Kirigami.Units.gridUnit 0056 anchors.top: parent.top 0057 anchors.right: toggle.left 0058 } 0059 QQC2.Switch { 0060 id: toggle 0061 checked: model.backendEnabled 0062 onToggled: model.backendEnabled = checked; 0063 anchors.top: parent.top 0064 anchors.right: parent.right 0065 } 0066 QQC2.Label { 0067 anchors.top: nameLabel.bottom 0068 anchors.left: parent.left 0069 anchors.right: toggle.left 0070 anchors.topMargin: Kirigami.Units.smallSpacing 0071 text: model.description 0072 font.italic: true 0073 wrapMode: Text.WordWrap 0074 } 0075 } 0076 0077 onClicked: { 0078 toggle.toggle(); // does not trigger the signal handler for toggled... 0079 model.backendEnabled = toggle.checked; 0080 } 0081 Accessible.onToggleAction: delegate.clicked() 0082 } 0083 } 0084 0085 ListView { 0086 model: backendModel 0087 delegate: backendDelegate 0088 0089 section.property: "countryCode" 0090 section.delegate: Kirigami.ListSectionHeader { 0091 text: { 0092 switch (section) { 0093 case "": 0094 case "UN": 0095 return i18n("Global") 0096 case "EU": 0097 return i18n("🇪🇺 European Union"); 0098 default: 0099 const c = Country.fromAlpha2(section); 0100 return c.emojiFlag + " " + c.name; 0101 } 0102 } 0103 width: ListView.view.width 0104 Accessible.name: { 0105 switch (section) { 0106 case "": 0107 case "UN": 0108 return i18n("Global") 0109 case "EU": 0110 return i18n("European Union"); 0111 default: 0112 return Country.fromAlpha2(section).name; 0113 } 0114 } 0115 } 0116 section.criteria: ViewSection.FullString 0117 } 0118 }