Kstars

FindDialog.qml
1// SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4import QtQuick 2.6
5import QtQuick.Window 2.2
6import QtQuick.Layouts 1.1
7import QtQuick.Controls 2.0
8import QtQuick.Controls.Material 2.0
9import QtQuick.Controls.Universal 2.0
10import "../constants" 1.0
11import "../modules"
12
13KSPage {
14 title: xi18n("Find an Object")
15 onVisibleChanged: {
16 if(visible) {
17 typeChoose.currentIndex = 0
18 searchQuery.text = ""
19 }
20 }
21
22 ColumnLayout {
23 id: findColumn
24 anchors.fill: parent
25 spacing: 5 * Num.dp
26 anchors{
27 bottom: parent.bottom
28 bottomMargin: 15 * Num.dp
29 }
30
31 RowLayout {
32 anchors {
33 left: parent.left
34 right: parent.right
35 }
36 KSLabel {
37 text: xi18n("Filter by name: ")
38 }
39 KSTextField {
40 id: searchQuery
41 Layout.fillWidth: true
42 onTextChanged: {
44 }
45 }
46 }
47
48 RowLayout {
49 anchors {
50 left: parent.left
51 right: parent.right
52 }
53 KSLabel {
54 text: xi18n("Filter by type: ")
55 }
56
57 Item {
58 //Spacer
59 Layout.minimumWidth: 30 * Num.dp
60 Layout.fillWidth: true
61 }
62
63 ComboBox {
64 id: typeChoose
65 model: FindDialogLite.filterModel
66 Layout.fillWidth: true
67
68 //Init list with objects when everything is loaded
69 Connections {
70 target: window
71 onLoaded: {
72 if(isLoaded) FindDialogLite.filterByType(typeChoose.currentIndex)
73 }
74 }
75
76 onCurrentIndexChanged: {
77 if(isLoaded) FindDialogLite.filterByType(currentIndex)
78 }
79 }
80 }
81
82 KSListView {
83 model: SortModel
84 textRole: "name"
85
86 Layout.fillWidth: true
87 Layout.fillHeight: true
88
89 onClicked: {
90 stackView.replace(null, initPage)
92 }
93 }
94
95 RowLayout {
96 KSButton {
97 id: searchInInternet
98 enabled: searchQuery.text.length > 0 && FindDialogLite.isResolveEnabled
99
100 text: xi18n("Search in internet")
101 onClicked: {
102 FindDialogLite.resolveInInternet(searchQuery.text)
103 }
104 }
105
106 KSButton {
107 text: xi18n("Cancel")
108 onClicked: {
109 stackView.pop()
110 }
111 }
112 }
113 }
114}
115
Backend for "Find Object" dialog in QML The way we are searching for the object is as follows: Each S...
Q_INVOKABLE void filterByType(uint typeIndex)
pre-filter the list of objects according to the selected object type.
Q_INVOKABLE void selectObject(int index)
Open context menu for object with given index from m_sortModel.
Q_INVOKABLE void filterList(QString searchQuery)
When Text is entered in the QLineEdit, filter the List of objects so that only objects which start wi...
Q_INVOKABLE void resolveInInternet(QString searchQuery)
searches for the object in internet (adopted to KStars Lite version of FindDialog::finishProcessing()
QString xi18n(const char *text, const TYPE &arg...)
QWidget * window(QObject *job)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.