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-2025 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#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
38class QDataStream;
39namespace sword { class SWKey; }
40
41namespace CSwordModuleSearch {
42
43using ModuleResultList = std::vector<std::shared_ptr<sword::SWKey const>>;
44
49
50using Results = std::vector<ModuleSearchResult>;
51
52enum SearchType { /* Values provided for serialization */
54 OrType = 1,
55 FullType = 2
56};
57
58Results 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*/
65QString 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*/
72QString prepareSearchText(QString const & orig, SearchType const searchType);
73
74} // namespace CSwordModuleSearch
75
76QDataStream &operator<<(QDataStream &out, const CSwordModuleSearch::SearchType &searchType);
77QDataStream &operator>>(QDataStream &in, CSwordModuleSearch::SearchType &searchType);
78Q_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