Warning, /utilities/ktrip/src/qml/LocationQueryPage.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.4
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     property bool showCached: true
0016     property var callback
0017 
0018     header: Kirigami.SearchField {
0019         id: queryTextField
0020 
0021         visible: Manager.enabledBackends.length !== 0
0022         width: parent.width
0023         onAccepted: {
0024             queryModel.request = Controller.createLocationRequest(text);
0025             showCached = false;
0026         }
0027     }
0028 
0029     ListView {
0030         id: locationView
0031         model: showCached ? cacheModel : queryModel
0032 
0033         delegate: ItemDelegate {
0034             visible: Manager.enabledBackends.length !== 0
0035             text: location.name
0036             width: ListView.view.width
0037             onClicked: {
0038                 cacheModel.addCachedLocation(location);
0039                 callback(location);
0040                 pageStack.pop();
0041             }
0042         }
0043 
0044         Kirigami.PlaceholderMessage {
0045             text: i18n("No locations found")
0046             visible: locationView.count === 0 && !queryModel.loading && !noProvidersMessage.visible
0047             anchors.centerIn: parent
0048         }
0049 
0050         Kirigami.PlaceholderMessage {
0051             id: noProvidersMessage
0052             text: i18n("No providers enabled")
0053             visible: Manager.enabledBackends.length === 0
0054             helpfulAction: Action {
0055                 text: i18n("Configure providers")
0056                 icon.name: "configure"
0057                 onTriggered: window.pageStack.push(Qt.resolvedUrl("BackendPage.qml"))
0058             }
0059             anchors.centerIn: parent
0060         }
0061 
0062         BusyIndicator {
0063             running: queryModel.loading
0064             anchors.centerIn: parent
0065         }
0066 
0067         KPT.LocationQueryModel {
0068             id: queryModel
0069             manager: Manager
0070         }
0071 
0072         LocationCacheModel {
0073             id: cacheModel
0074         }
0075     }
0076 }