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 QHELPDBREADER_H |
5 | #define QHELPDBREADER_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/QObject> |
19 | #include <QtCore/QStringList> |
20 | #include <QtCore/QUrl> |
21 | #include <QtCore/QByteArray> |
22 | #include <QtCore/QSet> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QSqlQuery; |
27 | |
28 | class QHelpDBReader : public QObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | class IndexItem |
34 | { |
35 | public: |
36 | IndexItem() = default; |
37 | QString name; |
38 | QString identifier; |
39 | int fileId = 0; |
40 | QString anchor; |
41 | QStringList filterAttributes; |
42 | }; |
43 | |
44 | class FileItem |
45 | { |
46 | public: |
47 | FileItem() = default; |
48 | QString name; |
49 | QString title; |
50 | QStringList filterAttributes; |
51 | }; |
52 | |
53 | class ContentsItem |
54 | { |
55 | public: |
56 | ContentsItem() = default; |
57 | QByteArray data; |
58 | QStringList filterAttributes; |
59 | }; |
60 | |
61 | class IndexTable |
62 | { |
63 | public: |
64 | QList<IndexItem> indexItems; |
65 | QList<FileItem> fileItems; |
66 | QList<ContentsItem> contentsItems; |
67 | QStringList usedFilterAttributes; |
68 | }; |
69 | |
70 | QHelpDBReader(const QString &dbName); |
71 | QHelpDBReader(const QString &dbName, const QString &uniqueId, |
72 | QObject *parent); |
73 | ~QHelpDBReader(); |
74 | |
75 | bool init(); |
76 | |
77 | QString namespaceName() const; |
78 | QString virtualFolder() const; |
79 | QString version() const; |
80 | IndexTable indexTable() const; |
81 | QList<QStringList> filterAttributeSets() const; |
82 | QMultiMap<QString, QByteArray> filesData(const QStringList &filterAttributes, |
83 | const QString &extensionFilter = QString()) const; |
84 | QByteArray fileData(const QString &virtualFolder, |
85 | const QString &filePath) const; |
86 | |
87 | QStringList customFilters() const; |
88 | QStringList filterAttributes(const QString &filterName = QString()) const; |
89 | |
90 | QVariant metaData(const QString &name) const; |
91 | |
92 | private: |
93 | QString quote(const QString &string) const; |
94 | bool initDB(); |
95 | QString qtVersionHeuristic() const; |
96 | |
97 | bool m_initDone = false; |
98 | QString m_dbName; |
99 | QString m_uniqueId; |
100 | QString m_error; |
101 | QSqlQuery *m_query = nullptr; |
102 | mutable QString m_namespace; |
103 | }; |
104 | |
105 | QT_END_NAMESPACE |
106 | |
107 | #endif |
108 | |