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#ifndef QHELPSEARCHINDEXWRITERDEFAULT_H
5#define QHELPSEARCHINDEXWRITERDEFAULT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the help generator tools. This header file may change from version
13// to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QMutex>
19#include <QtCore/QThread>
20
21QT_FORWARD_DECLARE_CLASS(QSqlDatabase)
22
23QT_BEGIN_NAMESPACE
24
25namespace fulltextsearch {
26namespace qt {
27
28class Writer
29{
30public:
31 Q_DISABLE_COPY_MOVE(Writer);
32
33 Writer(const QString &path);
34 ~Writer();
35
36 bool tryInit(bool reindex);
37 void flush();
38
39 void removeNamespace(const QString &namespaceName);
40 bool hasNamespace(const QString &namespaceName);
41 void insertDoc(const QString &namespaceName,
42 const QString &attributes,
43 const QString &url,
44 const QString &title,
45 const QString &contents);
46 void startTransaction();
47 void endTransaction();
48private:
49 void init(bool reindex);
50 bool hasDB();
51 void clearLegacyIndex();
52
53 const QString m_dbDir;
54 QString m_uniqueId;
55
56 bool m_needOptimize = false;
57 QSqlDatabase *m_db = nullptr;
58 QVariantList m_namespaces;
59 QVariantList m_attributes;
60 QVariantList m_urls;
61 QVariantList m_titles;
62 QVariantList m_contents;
63};
64
65
66class QHelpSearchIndexWriter : public QThread
67{
68 Q_OBJECT
69
70public:
71 QHelpSearchIndexWriter();
72 ~QHelpSearchIndexWriter() override;
73
74 void cancelIndexing();
75 void updateIndex(const QString &collectionFile,
76 const QString &indexFilesFolder, bool reindex);
77
78signals:
79 void indexingStarted();
80 void indexingFinished();
81
82private:
83 void run() override;
84
85private:
86 QMutex m_mutex;
87
88 bool m_cancel;
89 bool m_reindex;
90 QString m_collectionFile;
91 QString m_indexFilesFolder;
92};
93
94} // namespace std
95} // namespace fulltextsearch
96
97QT_END_NAMESPACE
98
99#endif // QHELPSEARCHINDEXWRITERDEFAULT_H
100

source code of qttools/src/assistant/help/qhelpsearchindexwriter_default_p.h