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-2026 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>
20
21// Sword includes:
22#ifdef __GNUC__
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wextra-semi"
25#pragma GCC diagnostic ignored "-Wsuggest-override"
26#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
27#endif
28#ifdef __clang__
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wsuggest-destructor-override"
31#endif
32#include <listkey.h>
33#ifdef __clang__
34#pragma clang diagnostic pop
35#endif
36#ifdef __GNUC__
37#pragma GCC diagnostic pop
38#endif
39
40
42class QDataStream;
43namespace sword { class SWKey; }
44
45namespace CSwordModuleSearch {
46
47using ModuleResultList = std::vector<std::shared_ptr<sword::SWKey const>>;
48
53
54using Results = std::vector<ModuleSearchResult>;
55
56enum SearchType { /* Values provided for serialization */
58 OrType = 1,
59 FullType = 2
60};
61
62Results search(QString const & searchText,
63 BtConstModuleList const & modules,
64 sword::ListKey scope);
65
66/**
67* This function highlights the searched text in the content using the search type given by search flags
68*/
69QString highlightSearchedText(QString const & content,
70 QString const & searchedText,
71 bool plainSearchedText = false);
72
73/**
74 Prepares the search string given by user for a specific search type
75*/
76QString prepareSearchText(QString const & orig, SearchType const searchType);
77
78} // namespace CSwordModuleSearch
79
80QDataStream &operator<<(QDataStream &out, const CSwordModuleSearch::SearchType &searchType);
81QDataStream &operator>>(QDataStream &in, CSwordModuleSearch::SearchType &searchType);
82Q_DECLARE_METATYPE(CSwordModuleSearch::SearchType)
QList< CSwordModuleInfo const * > BtConstModuleList
QDataStream & operator>>(QDataStream &in, CSwordModuleSearch::SearchType &searchType)
QDataStream & operator<<(QDataStream &out, const 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
CSwordModuleInfo const *ModuleResultList results