Warning, /libraries/kpublictransport/tests/pureqmltest.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.kpublictransport
0012
0013 Kirigami.ApplicationWindow {
0014 title: "Pure QML Journey Query Example"
0015 width: 640
0016 height: 800
0017
0018 pageStack.initialPage: journyQueryPage
0019
0020 Manager {
0021 id: ptMgr;
0022 }
0023
0024 JourneyQueryModel {
0025 id: journeyModel
0026 manager: ptMgr
0027 }
0028
0029 globalDrawer: Kirigami.GlobalDrawer {
0030 actions: [
0031 Kirigami.Action {
0032 icon.name: "help-about-symbolic"
0033 text: "Current Data Sources"
0034 enabled: journeyModel.attributions.length > 0
0035 onTriggered: {
0036 aboutSheet.attributions = Qt.binding(function() { return journeyModel.attributions; });
0037 aboutSheet.open();
0038 }
0039 },
0040 Kirigami.Action {
0041 icon.name: "help-about-symbolic"
0042 text: "All Data Sources"
0043 onTriggered: {
0044 aboutSheet.attributions = Qt.binding(function() { return ptMgr.attributions; });
0045 aboutSheet.open();
0046 }
0047 }
0048 ]
0049 }
0050
0051 AttributionSheet { id: aboutSheet }
0052
0053 Component {
0054 id: journyQueryPage
0055 Kirigami.Page {
0056 ColumnLayout {
0057 anchors.fill: parent
0058 QQC2.TextField {
0059 id: fromName
0060 }
0061 QQC2.TextField {
0062 id: toName
0063 }
0064 QQC2.Button {
0065 text: "Query"
0066 onClicked: {
0067 var from = journeyModel.request.from;
0068 from.name = fromName.text;
0069 journeyModel.request.from = from;
0070 var to = journeyModel.request.to;
0071 to.name = toName.text;
0072 journeyModel.request.to = to;
0073 }
0074 }
0075
0076 ListView {
0077 Layout.fillHeight: true
0078 Layout.fillWidth: true
0079 model: journeyModel
0080 clip: true
0081 delegate: QQC2.ItemDelegate {
0082 width: ListView.view.width
0083 contentItem: GridLayout {
0084 rows: 2
0085 columns: 2
0086 QQC2.Label {
0087 text: journey.scheduledDepartureTime
0088 }
0089 QQC2.Label {
0090 Layout.fillWidth: true
0091 text: journey.sections[0].from.name;
0092 }
0093 QQC2.Label {
0094 text: journey.scheduledArrivalTime
0095 }
0096 QQC2.Label {
0097 Layout.fillWidth: true
0098 text: journey.sections[journey.sections.length - 1].to.name;
0099 }
0100 }
0101 }
0102
0103 QQC2.BusyIndicator {
0104 anchors.centerIn: parent
0105 running: journeyModel.loading
0106 }
0107
0108 QQC2.Label {
0109 anchors.centerIn: parent
0110 width: parent.width
0111 text: journeyModel.errorMessage
0112 color: Kirigami.Theme.negativeTextColor
0113 wrapMode: Text.Wrap
0114 }
0115 }
0116 }
0117 }
0118 }
0119 }