| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Assistant of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QHELPCONTENTWIDGET_H |
| 41 | #define QHELPCONTENTWIDGET_H |
| 42 | |
| 43 | #include <QtHelp/qhelp_global.h> |
| 44 | |
| 45 | #include <QtCore/QQueue> |
| 46 | #include <QtCore/QString> |
| 47 | #include <QtWidgets/QTreeView> |
| 48 | |
| 49 | QT_BEGIN_NAMESPACE |
| 50 | |
| 51 | |
| 52 | class QHelpEnginePrivate; |
| 53 | class QHelpContentItemPrivate; |
| 54 | class QHelpContentModelPrivate; |
| 55 | class QHelpEngine; |
| 56 | class QHelpContentProvider; |
| 57 | |
| 58 | class QHELP_EXPORT QHelpContentItem |
| 59 | { |
| 60 | public: |
| 61 | ~QHelpContentItem(); |
| 62 | |
| 63 | QHelpContentItem *child(int row) const; |
| 64 | int childCount() const; |
| 65 | QString title() const; |
| 66 | QUrl url() const; |
| 67 | int row() const; |
| 68 | QHelpContentItem *parent() const; |
| 69 | int childPosition(QHelpContentItem *child) const; |
| 70 | |
| 71 | private: |
| 72 | QHelpContentItem(const QString &name, const QUrl &link, |
| 73 | QHelpContentItem *parent = nullptr); |
| 74 | |
| 75 | QHelpContentItemPrivate *d; |
| 76 | friend class QHelpContentProvider; |
| 77 | }; |
| 78 | |
| 79 | class QHELP_EXPORT QHelpContentModel : public QAbstractItemModel |
| 80 | { |
| 81 | Q_OBJECT |
| 82 | |
| 83 | public: |
| 84 | ~QHelpContentModel() override; |
| 85 | |
| 86 | void createContents(const QString &customFilterName); |
| 87 | QHelpContentItem *contentItemAt(const QModelIndex &index) const; |
| 88 | |
| 89 | QVariant data(const QModelIndex &index, int role) const override; |
| 90 | QModelIndex index(int row, int column, |
| 91 | const QModelIndex &parent = QModelIndex()) const override; |
| 92 | QModelIndex parent(const QModelIndex &index) const override; |
| 93 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 94 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; |
| 95 | bool isCreatingContents() const; |
| 96 | |
| 97 | Q_SIGNALS: |
| 98 | void contentsCreationStarted(); |
| 99 | void contentsCreated(); |
| 100 | |
| 101 | private Q_SLOTS: |
| 102 | void insertContents(); |
| 103 | |
| 104 | private: |
| 105 | QHelpContentModel(QHelpEnginePrivate *helpEngine); |
| 106 | QHelpContentModelPrivate *d; |
| 107 | friend class QHelpEnginePrivate; |
| 108 | }; |
| 109 | |
| 110 | class QHELP_EXPORT QHelpContentWidget : public QTreeView |
| 111 | { |
| 112 | Q_OBJECT |
| 113 | |
| 114 | public: |
| 115 | QModelIndex indexOf(const QUrl &link); |
| 116 | |
| 117 | Q_SIGNALS: |
| 118 | void linkActivated(const QUrl &link); |
| 119 | |
| 120 | private Q_SLOTS: |
| 121 | void showLink(const QModelIndex &index); |
| 122 | |
| 123 | private: |
| 124 | bool searchContentItem(QHelpContentModel *model, |
| 125 | const QModelIndex &parent, const QString &path); |
| 126 | QModelIndex m_syncIndex; |
| 127 | |
| 128 | private: |
| 129 | QHelpContentWidget(); |
| 130 | friend class QHelpEngine; |
| 131 | }; |
| 132 | |
| 133 | QT_END_NAMESPACE |
| 134 | |
| 135 | #endif |
| 136 | |
| 137 | |