| 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 QHELPCONTENTWIDGET_H |
| 5 | #define QHELPCONTENTWIDGET_H |
| 6 | |
| 7 | #include <QtHelp/qhelp_global.h> |
| 8 | #include <QtHelp/qhelpcontentitem.h> |
| 9 | #include <QtWidgets/qtreeview.h> |
| 10 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | class QHelpContentModelPrivate; |
| 14 | class QHelpEngine; |
| 15 | class QHelpEngineCore; |
| 16 | class QUrl; |
| 17 | |
| 18 | class QHELP_EXPORT QHelpContentModel : public QAbstractItemModel |
| 19 | { |
| 20 | Q_OBJECT |
| 21 | |
| 22 | public: |
| 23 | ~QHelpContentModel() override; |
| 24 | |
| 25 | void createContentsForCurrentFilter(); |
| 26 | void createContents(const QString &customFilterName); |
| 27 | QHelpContentItem *contentItemAt(const QModelIndex &index) const; |
| 28 | |
| 29 | QVariant data(const QModelIndex &index, int role) const override; |
| 30 | QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; |
| 31 | QModelIndex parent(const QModelIndex &index) const override; |
| 32 | int rowCount(const QModelIndex &parent = {}) const override; |
| 33 | int columnCount(const QModelIndex &parent = {}) const override; |
| 34 | bool isCreatingContents() const; |
| 35 | |
| 36 | Q_SIGNALS: |
| 37 | void contentsCreationStarted(); |
| 38 | void contentsCreated(); |
| 39 | |
| 40 | private Q_SLOTS: |
| 41 | void insertContents(); |
| 42 | |
| 43 | private: |
| 44 | QHelpContentModel(QHelpEngineCore *helpEngine); |
| 45 | QHelpContentModelPrivate *d; |
| 46 | friend class QHelpEnginePrivate; |
| 47 | friend class QHelpContentModelPrivate; |
| 48 | }; |
| 49 | |
| 50 | class QHELP_EXPORT QHelpContentWidget : public QTreeView |
| 51 | { |
| 52 | Q_OBJECT |
| 53 | |
| 54 | public: |
| 55 | QModelIndex indexOf(const QUrl &link); |
| 56 | |
| 57 | Q_SIGNALS: |
| 58 | void linkActivated(const QUrl &link); |
| 59 | |
| 60 | private Q_SLOTS: |
| 61 | void showLink(const QModelIndex &index); |
| 62 | |
| 63 | private: |
| 64 | bool searchContentItem(QHelpContentModel *model, const QModelIndex &parent, |
| 65 | const QString &path); |
| 66 | QModelIndex m_syncIndex; |
| 67 | |
| 68 | private: |
| 69 | QHelpContentWidget(); |
| 70 | friend class QHelpEngine; |
| 71 | }; |
| 72 | |
| 73 | QT_END_NAMESPACE |
| 74 | |
| 75 | #endif // QHELPCONTENTWIDGET_H |
| 76 |
