Kstars

finddialoglite.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QObject>
10#include <QStringList>
11
14class QTimer;
15
17
18/**
19 * @class FindDialogLite
20 * @short Backend for "Find Object" dialog in QML
21 * The way we are searching for the object is as follows:
22 * Each SkyComponent in addition to QStringList of names holds QVector<QPair<QString, const SkyObject *>>.
23 * SkyObjectListModel is a class that holds SkyObjects together with their names (name and longname).
24 * Whenever user searches for an object we sort list of SkyObjects through QSortFilterProxyModel. The reason
25 * for this way of searching is that we don't need to search for an object again, as it was done previously.
26 * Instead of this, user directly selects the object in search results.
27 *
28 * @author Artem Fedoskin, Jason Harris
29 * @version 1.0
30 */
31class FindDialogLite : public QObject
32{
34
35 Q_PROPERTY(QStringList filterModel READ getFilterModel NOTIFY filterModelChanged)
36 //true if m_searchQuery is already in sorted list of object names
37 Q_PROPERTY(bool isResolveEnabled READ getIsResolveEnabled WRITE setIsResolveEnabled NOTIFY isResolveEnabledChanged)
38 public:
39 /**
40 * @short Constructor. Initialize m_filterModel with object types and
41 * initialize m_sortModel with instance of SkyObjectListModel
42 */
44 virtual ~FindDialogLite();
45
46 /** Open context menu for object with given index from m_sortModel */
47 Q_INVOKABLE void selectObject(int index);
48
49 /**
50 * @return list of object types
51 */
52 QStringList getFilterModel() { return m_filterModel; }
53
54 /**
55 * @short pre-filter the list of objects according to the selected object type.
56 */
58
59 /**
60 * @short searches for the object in internet (adopted to KStars Lite version of
61 * FindDialog::finishProcessing()
62 */
63 Q_INVOKABLE void resolveInInternet(QString searchQuery);
64
65 /**
66 * @return true it at least one entry in fModel is an exact match with searchQuery
67 */
68 Q_INVOKABLE bool isInList(QString searchQuery);
69
70 /** Getter for isResolveEnabled **/
71 bool getIsResolveEnabled() { return m_isResolveEnabled; }
72
73 /** Setter for isResolveEnabled **/
74 void setIsResolveEnabled(bool isResolveEnabled);
75 signals:
76 void filterModelChanged();
77 void notifyMessage(QString message);
78 void isResolveEnabledChanged(bool);
79
80 public slots:
81 /**
82 * When Text is entered in the QLineEdit, filter the List of objects
83 * so that only objects which start with the filter text are shown.
84 */
85 Q_INVOKABLE void filterList(QString searchQuery);
86
87 private:
88 /**
89 * @short Do some post processing on the search text to interpret what the user meant
90 * This could include replacing text like "m93" with "m 93"
91 */
92 QString processSearchText(QString text);
93
94 QStringList m_filterModel;
95 SkyObjectListModel *fModel { nullptr };
96 QSortFilterProxyModel *m_sortModel { nullptr };
97 QTimer *timer { nullptr };
98 bool listFiltered { false };
99
100 /** Current query that is used to sort fModel **/
101 QString m_searchQuery;
102 bool m_isResolveEnabled { false };
103 uint m_typeIndex { 0 };
104};
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.
QStringList getFilterModel()
Q_INVOKABLE bool isInList(QString searchQuery)
bool getIsResolveEnabled()
Getter for isResolveEnabled.
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()
FindDialogLite()
Constructor.
void setIsResolveEnabled(bool isResolveEnabled)
Setter for isResolveEnabled.
A model used in Find Object Dialog in QML.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.