Warning, file /education/kalzium/src/search.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2006 Pino Toscano <toscano.pino@tiscali.it> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KALZIUMSEARCH_H 0008 #define KALZIUMSEARCH_H 0009 0010 #include <QList> 0011 #include <QObject> 0012 0013 #include "element.h" 0014 // class Element; 0015 0016 /** 0017 * Represent a search. 0018 * 0019 * @author Pino Toscano 0020 */ 0021 class Search : public QObject 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 /** 0027 * The kind of search we can perform 0028 */ 0029 enum SearchKind { SearchByName = 0x01, SearchBySymbol = 0x02, SearchAll = 0xFF }; 0030 0031 /** 0032 * Construct a new empty search. 0033 */ 0034 Search(); 0035 0036 /** 0037 * @return the search text 0038 */ 0039 QString searchText() const; 0040 0041 /** 0042 * @return the kind of search 0043 */ 0044 SearchKind searchKind() const; 0045 0046 /** 0047 * is the current Search active? 0048 * @return whether this search is active 0049 */ 0050 bool isActive() const; 0051 0052 /** 0053 * @return the found elements 0054 */ 0055 const QList<Element *> &foundElements() const; 0056 0057 /** 0058 * @return whether the element @p el matches the search 0059 */ 0060 bool matches(Element *el) const; 0061 0062 /** 0063 * @return whether the element @p el matches the search 0064 * overloaded function to use direct the element number. 0065 */ 0066 bool matches(int el) const; 0067 0068 public Q_SLOTS: 0069 /** 0070 * Search the @p text by looking at the element using the 0071 * specified @p kind 0072 */ 0073 void doSearch(const QString &text, SearchKind kind); 0074 /** 0075 * Reset the current search (and put it not active). 0076 */ 0077 void resetSearch(); 0078 0079 Q_SIGNALS: 0080 /** 0081 * The current search has changed (ie the found elements have 0082 * changed) 0083 */ 0084 void searchChanged(); 0085 /** 0086 * The current search has been reset. 0087 */ 0088 void searchReset(); 0089 0090 private: 0091 bool m_isActive = false; 0092 0093 QString m_searchText; 0094 SearchKind m_searchKind; 0095 0096 QList<Element *> m_foundElements; 0097 }; 0098 0099 #endif // KALZIUMSEARCH_H