Warning, /education/marble/src/apps/marble-maps/SearchField.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2015 Gábor Péterffy <peterffy95@gmail.com>
0004 // SPDX-FileCopyrightText: 2015 Dennis Nienhüser <nienhueser@kde.org>
0005 // SPDX-FileCopyrightText: 2015 Mikhail Ivchenko <ematirov@gmail.com>
0006 //
0007
0008 import QtQuick 2.3
0009 import QtQuick.Controls 1.3
0010 import QtQuick.Controls.Styles 1.3
0011
0012 Item {
0013 id: root
0014 height: field.height
0015
0016 property alias query: field.text
0017 property alias hasFocus: field.activeFocus
0018
0019 property alias completionModel: completion.model
0020 property bool busy: false
0021
0022 signal searchRequested(string query)
0023 signal completionRequested(string query)
0024 signal cleared()
0025 signal menuButtonClicked()
0026
0027 function search(query) {
0028 routingManager.clearSearchResultPlacemarks();
0029 query = query.trim();
0030 if(query.toLowerCase() === "ok marble" || query.toLowerCase() === "okdbg") {
0031 app.state = "developer";
0032 } else if(query !== "") {
0033 root.busy = true;
0034 searchRequested(query);
0035 field.focus = false;
0036 }
0037 }
0038
0039 SystemPalette{
0040 id: palette
0041 colorGroup: SystemPalette.Active
0042 }
0043
0044 Rectangle {
0045 anchors.fill: parent
0046 color: palette.base
0047 border.color: palette.shadow
0048 border.width: 1
0049 }
0050
0051 FlatButton {
0052 id: menuButton
0053 anchors.verticalCenter: parent.verticalCenter
0054 anchors.left: parent.left
0055 anchors.leftMargin: 10
0056 height: 0.7 * field.height
0057 width: height
0058 imageSource: "qrc:///menu.png"
0059
0060 MouseArea {
0061 anchors.fill: parent
0062 onClicked: root.menuButtonClicked()
0063 }
0064 }
0065
0066 TextField {
0067 id: field
0068 anchors.left: menuButton.right
0069 anchors.right: parent.right
0070
0071 placeholderText: qsTr("Search")
0072 font.pointSize: 16
0073 textColor: palette.text
0074 inputMethodHints: Qt.ImhNoPredictiveText
0075 onAccepted: root.search(text)
0076 onTextChanged: root.completionRequested(text)
0077
0078 BusyIndicator {
0079 id: searchBusyIndicator
0080 anchors.verticalCenter: parent.verticalCenter
0081 anchors.right: clearButton.visible ? clearButton.left : clearButton.right
0082 anchors.rightMargin: 10
0083 visible: running
0084 height: 0.7 * field.height
0085 width: height
0086 running: root.busy
0087
0088 style: BusyIndicatorStyle {
0089 indicator: Image {
0090 visible: control.running
0091 source: "busy_indicator.png"
0092 RotationAnimator on rotation {
0093 running: control.running
0094 loops: Animation.Infinite
0095 duration: 1500
0096 from: 0 ; to: 360
0097 }
0098 }
0099 }
0100 }
0101
0102 FlatButton {
0103 id: clearButton
0104 anchors.verticalCenter: parent.verticalCenter
0105 anchors.right: searchButton.visible ? searchButton.left : parent.right
0106 anchors.rightMargin: 10
0107 height: 0.7 * field.height
0108 width: height
0109 visible: field.text !== ""
0110 imageSource: "qrc:///clear.png"
0111
0112 MouseArea {
0113 anchors.fill: parent
0114 onClicked: {
0115 app.selectedPlacemark = null;
0116 app.state = "none"
0117 routingManager.clearSearchResultPlacemarks();
0118 field.text = "";
0119 field.focus = true;
0120 cleared();
0121 }
0122 }
0123 }
0124
0125 FlatButton {
0126 id: searchButton
0127 anchors.verticalCenter: parent.verticalCenter
0128 anchors.right: parent.right
0129 anchors.rightMargin: 10
0130 height: 0.7 * field.height
0131 width: height
0132 visible: !root.busy
0133 enabled: field.text !== ""
0134 imageSource: "qrc:///search.png"
0135 onClicked: root.search(field.text)
0136 }
0137 }
0138
0139 Completion {
0140 id: completion
0141 anchors {
0142 top: parent.bottom
0143 left: parent.left
0144 right: parent.right
0145 }
0146 height: delegateHeight * Math.min(2,count)
0147 visible: count > 0 && field.activeFocus
0148 onItemSelected: {
0149 field.text = name;
0150 search(name);
0151 }
0152 }
0153 }