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
13QT_BEGIN_NAMESPACE
14
15
16class QHelpEnginePrivate;
17class QHelpContentItemPrivate;
18class QHelpContentModelPrivate;
19class QHelpEngine;
20class QHelpContentProvider;
21
22class QHELP_EXPORT QHelpContentItem
23{
24public:
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
35private:
36 QHelpContentItem(const QString &name, const QUrl &link,
37 QHelpContentItem *parent = nullptr);
38
39 QHelpContentItemPrivate *d;
40 friend class QHelpContentProvider;
41};
42
43class QHELP_EXPORT QHelpContentModel : public QAbstractItemModel
44{
45 Q_OBJECT
46
47public:
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
61Q_SIGNALS:
62 void contentsCreationStarted();
63 void contentsCreated();
64
65private Q_SLOTS:
66 void insertContents();
67
68private:
69 QHelpContentModel(QHelpEnginePrivate *helpEngine);
70 QHelpContentModelPrivate *d;
71 friend class QHelpEnginePrivate;
72};
73
74class QHELP_EXPORT QHelpContentWidget : public QTreeView
75{
76 Q_OBJECT
77
78public:
79 QModelIndex indexOf(const QUrl &link);
80
81Q_SIGNALS:
82 void linkActivated(const QUrl &link);
83
84private Q_SLOTS:
85 void showLink(const QModelIndex &index);
86
87private:
88 bool searchContentItem(QHelpContentModel *model,
89 const QModelIndex &parent, const QString &path);
90 QModelIndex m_syncIndex;
91
92private:
93 QHelpContentWidget();
94 friend class QHelpEngine;
95};
96
97QT_END_NAMESPACE
98
99#endif
100
101

source code of qttools/src/assistant/help/qhelpcontentwidget.h