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 | |
9 | #include <QtCore/QQueue> |
10 | #include <QtCore/QString> |
11 | #include <QtWidgets/QTreeView> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | |
16 | class QHelpEnginePrivate; |
17 | class QHelpContentItemPrivate; |
18 | class QHelpContentModelPrivate; |
19 | class QHelpEngine; |
20 | class QHelpContentProvider; |
21 | |
22 | class QHELP_EXPORT QHelpContentItem |
23 | { |
24 | public: |
25 | ~QHelpContentItem(); |
26 | |
27 | QHelpContentItem *child(int row) const; |
28 | int childCount() const; |
29 | QString title() const; |
30 | QUrl url() const; |
31 | int row() const; |
32 | QHelpContentItem *parent() const; |
33 | int childPosition(QHelpContentItem *child) const; |
34 | |
35 | private: |
36 | QHelpContentItem(const QString &name, const QUrl &link, |
37 | QHelpContentItem *parent = nullptr); |
38 | |
39 | QHelpContentItemPrivate *d; |
40 | friend class QHelpContentProvider; |
41 | }; |
42 | |
43 | class QHELP_EXPORT QHelpContentModel : public QAbstractItemModel |
44 | { |
45 | Q_OBJECT |
46 | |
47 | public: |
48 | ~QHelpContentModel() override; |
49 | |
50 | void createContents(const QString &customFilterName); |
51 | QHelpContentItem *contentItemAt(const QModelIndex &index) const; |
52 | |
53 | QVariant data(const QModelIndex &index, int role) const override; |
54 | QModelIndex index(int row, int column, |
55 | const QModelIndex &parent = QModelIndex()) const override; |
56 | QModelIndex parent(const QModelIndex &index) const override; |
57 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
58 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; |
59 | bool isCreatingContents() const; |
60 | |
61 | Q_SIGNALS: |
62 | void contentsCreationStarted(); |
63 | void contentsCreated(); |
64 | |
65 | private Q_SLOTS: |
66 | void insertContents(); |
67 | |
68 | private: |
69 | QHelpContentModel(QHelpEnginePrivate *helpEngine); |
70 | QHelpContentModelPrivate *d; |
71 | friend class QHelpEnginePrivate; |
72 | }; |
73 | |
74 | class QHELP_EXPORT QHelpContentWidget : public QTreeView |
75 | { |
76 | Q_OBJECT |
77 | |
78 | public: |
79 | QModelIndex indexOf(const QUrl &link); |
80 | |
81 | Q_SIGNALS: |
82 | void linkActivated(const QUrl &link); |
83 | |
84 | private Q_SLOTS: |
85 | void showLink(const QModelIndex &index); |
86 | |
87 | private: |
88 | bool searchContentItem(QHelpContentModel *model, |
89 | const QModelIndex &parent, const QString &path); |
90 | QModelIndex m_syncIndex; |
91 | |
92 | private: |
93 | QHelpContentWidget(); |
94 | friend class QHelpEngine; |
95 | }; |
96 | |
97 | QT_END_NAMESPACE |
98 | |
99 | #endif |
100 | |
101 |