BibleTime
cswordmodulesearch.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include <memory>
16 #include <QMetaType>
17 #include <QString>
18 #include <vector>
19 #include "drivers/btmodulelist.h"
20 
21 // Sword includes:
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wextra-semi"
24 #pragma GCC diagnostic ignored "-Wsuggest-override"
25 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
26 #ifdef __clang__
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored "-Wsuggest-destructor-override"
29 #endif
30 #include <listkey.h>
31 #ifdef __clang__
32 #pragma clang diagnostic pop
33 #endif
34 #pragma GCC diagnostic pop
35 
36 
37 class CSwordModuleInfo;
38 class QDataStream;
39 namespace sword { class SWKey; }
40 
41 namespace CSwordModuleSearch {
42 
43 using ModuleResultList = std::vector<std::shared_ptr<sword::SWKey const>>;
44 
48 };
49 
50 using Results = std::vector<ModuleSearchResult>;
51 
52 enum SearchType { /* Values provided for serialization */
53  AndType = 0,
54  OrType = 1,
55  FullType = 2
56 };
57 
58 Results search(QString const & searchText,
59  BtConstModuleList const & modules,
60  sword::ListKey scope);
61 
62 /**
63 * This function highlights the searched text in the content using the search type given by search flags
64 */
65 QString highlightSearchedText(QString const & content,
66  QString const & searchedText,
67  bool plainSearchedText = false);
68 
69 /**
70  Prepares the search string given by user for a specific search type
71 */
72 QString prepareSearchText(QString const & orig, SearchType const searchType);
73 
74 } // namespace CSwordModuleSearch
75 
76 QDataStream &operator<<(QDataStream &out, const CSwordModuleSearch::SearchType &searchType);
77 QDataStream &operator>>(QDataStream &in, CSwordModuleSearch::SearchType &searchType);
78 Q_DECLARE_METATYPE(CSwordModuleSearch::SearchType)
QList< CSwordModuleInfo const * > BtConstModuleList
Definition: btmodulelist.h:21
QDataStream & operator<<(QDataStream &out, const CSwordModuleSearch::SearchType &searchType)
QDataStream & operator>>(QDataStream &in, CSwordModuleSearch::SearchType &searchType)
QString prepareSearchText(QString const &orig, SearchType const searchType)
QString highlightSearchedText(QString const &content, QString const &searchedText, bool plainSearchedText)
std::vector< std::shared_ptr< sword::SWKey const > > ModuleResultList
Results search(QString const &searchText, BtConstModuleList const &modules, sword::ListKey scope)
std::vector< ModuleSearchResult > Results