1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhelpsearchindexreader_p.h"
5
6QT_BEGIN_NAMESPACE
7
8namespace fulltextsearch {
9
10QHelpSearchIndexReader::~QHelpSearchIndexReader()
11{
12 cancelSearching();
13 wait();
14}
15
16void QHelpSearchIndexReader::cancelSearching()
17{
18 QMutexLocker lock(&m_mutex);
19 m_cancel = true;
20}
21
22void QHelpSearchIndexReader::search(const QString &collectionFile, const QString &indexFilesFolder,
23 const QString &searchInput, bool usesFilterEngine)
24{
25 wait();
26
27 m_searchResults.clear();
28 m_cancel = false;
29 m_searchInput = searchInput;
30 m_collectionFile = collectionFile;
31 m_indexFilesFolder = indexFilesFolder;
32 m_usesFilterEngine = usesFilterEngine;
33
34 start(QThread::NormalPriority);
35}
36
37int QHelpSearchIndexReader::searchResultCount() const
38{
39 QMutexLocker lock(&m_mutex);
40 return m_searchResults.size();
41}
42
43QList<QHelpSearchResult> QHelpSearchIndexReader::searchResults(int start,
44 int end) const
45{
46 QMutexLocker lock(&m_mutex);
47 return m_searchResults.mid(pos: start, len: end - start);
48}
49
50
51} // namespace fulltextsearch
52
53QT_END_NAMESPACE
54

source code of qttools/src/assistant/help/qhelpsearchindexreader.cpp