| 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 QHELPENGINECORE_H |
| 5 | #define QHELPENGINECORE_H |
| 6 | |
| 7 | #include <QtHelp/qhelp_global.h> |
| 8 | #include <QtHelp/qhelpcontentitem.h> |
| 9 | |
| 10 | #if QT_CONFIG(future) |
| 11 | #include <QtCore/qfuture.h> |
| 12 | #endif |
| 13 | |
| 14 | #include <QtCore/qobject.h> |
| 15 | #include <QtCore/qurl.h> |
| 16 | #include <QtCore/qvariant.h> |
| 17 | |
| 18 | QT_BEGIN_NAMESPACE |
| 19 | |
| 20 | class QHelpEngineCorePrivate; |
| 21 | class QHelpFilterEngine; |
| 22 | struct QHelpLink; |
| 23 | |
| 24 | class QHELP_EXPORT QHelpEngineCore : public QObject |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | Q_PROPERTY(bool autoSaveFilter READ autoSaveFilter WRITE setAutoSaveFilter) |
| 28 | Q_PROPERTY(QString collectionFile READ collectionFile WRITE setCollectionFile) |
| 29 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) |
| 30 | #if QT_DEPRECATED_SINCE(5, 15) |
| 31 | Q_PROPERTY(QString currentFilter READ currentFilter WRITE setCurrentFilter) |
| 32 | #endif |
| 33 | |
| 34 | public: |
| 35 | explicit QHelpEngineCore(const QString &collectionFile, QObject *parent = nullptr); |
| 36 | virtual ~QHelpEngineCore(); |
| 37 | |
| 38 | bool isReadOnly() const; |
| 39 | void setReadOnly(bool enable); |
| 40 | |
| 41 | QHelpFilterEngine *filterEngine() const; |
| 42 | |
| 43 | bool setupData(); |
| 44 | |
| 45 | QString collectionFile() const; |
| 46 | void setCollectionFile(const QString &fileName); |
| 47 | |
| 48 | bool copyCollectionFile(const QString &fileName); |
| 49 | |
| 50 | static QString namespaceName(const QString &documentationFileName); |
| 51 | bool registerDocumentation(const QString &documentationFileName); |
| 52 | bool unregisterDocumentation(const QString &namespaceName); |
| 53 | QString documentationFileName(const QString &namespaceName); |
| 54 | QStringList registeredDocumentations() const; |
| 55 | QByteArray fileData(const QUrl &url) const; |
| 56 | |
| 57 | // #if QT_DEPRECATED_SINCE(5,13) |
| 58 | QStringList customFilters() const; |
| 59 | bool removeCustomFilter(const QString &filterName); |
| 60 | bool addCustomFilter(const QString &filterName, |
| 61 | const QStringList &attributes); |
| 62 | |
| 63 | QStringList filterAttributes() const; |
| 64 | QStringList filterAttributes(const QString &filterName) const; |
| 65 | |
| 66 | QString currentFilter() const; |
| 67 | void setCurrentFilter(const QString &filterName); |
| 68 | |
| 69 | QList<QStringList> filterAttributeSets(const QString &namespaceName) const; |
| 70 | QList<QUrl> files(const QString namespaceName, const QStringList &filterAttributes, |
| 71 | const QString &extensionFilter = {}); |
| 72 | // #endif |
| 73 | |
| 74 | QList<QUrl> files(const QString namespaceName, const QString &filterName, |
| 75 | const QString &extensionFilter = {}); |
| 76 | QUrl findFile(const QUrl &url) const; |
| 77 | |
| 78 | QList<QHelpLink> documentsForIdentifier(const QString &id) const; |
| 79 | QList<QHelpLink> documentsForIdentifier(const QString &id, const QString &filterName) const; |
| 80 | QList<QHelpLink> documentsForKeyword(const QString &keyword) const; |
| 81 | QList<QHelpLink> documentsForKeyword(const QString &keyword, const QString &filterName) const; |
| 82 | |
| 83 | bool removeCustomValue(const QString &key); |
| 84 | QVariant customValue(const QString &key, const QVariant &defaultValue = {}) const; |
| 85 | bool setCustomValue(const QString &key, const QVariant &value); |
| 86 | |
| 87 | static QVariant metaData(const QString &documentationFileName, const QString &name); |
| 88 | |
| 89 | QString error() const; |
| 90 | |
| 91 | void setAutoSaveFilter(bool save); |
| 92 | bool autoSaveFilter() const; |
| 93 | |
| 94 | void setUsesFilterEngine(bool uses); |
| 95 | bool usesFilterEngine() const; |
| 96 | |
| 97 | #if QT_CONFIG(future) |
| 98 | QFuture<std::shared_ptr<QHelpContentItem>> requestContentForCurrentFilter() const; |
| 99 | QFuture<std::shared_ptr<QHelpContentItem>> requestContent(const QString &filter) const; |
| 100 | |
| 101 | QFuture<QStringList> requestIndexForCurrentFilter() const; |
| 102 | QFuture<QStringList> requestIndex(const QString &filter) const; |
| 103 | #endif |
| 104 | |
| 105 | Q_SIGNALS: |
| 106 | void setupStarted(); |
| 107 | void setupFinished(); |
| 108 | void warning(const QString &msg); |
| 109 | |
| 110 | // #if QT_DEPRECATED_SINCE(5,13) |
| 111 | void currentFilterChanged(const QString &newFilter); |
| 112 | void readersAboutToBeInvalidated(); |
| 113 | // #endif |
| 114 | |
| 115 | protected: |
| 116 | #if QT_DEPRECATED_SINCE(6, 8) |
| 117 | QHelpEngineCore(QHelpEngineCorePrivate *helpEngineCorePrivate, QObject *parent); |
| 118 | #endif |
| 119 | |
| 120 | private: |
| 121 | QHelpEngineCorePrivate *d; |
| 122 | }; |
| 123 | |
| 124 | QT_END_NAMESPACE |
| 125 | |
| 126 | #endif // QHELPENGINECORE_H |
| 127 | |