Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qhelpengine.cpp
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
#
include
"qhelpengine.h"
6
#
include
"qhelpcontentwidget.h"
7
#
include
"qhelpfilterengine.h"
8
#
include
"qhelpindexwidget.h"
9
#
include
"qhelpsearchengine.h"
10
11
#
include
<
QtCore
/
qtimer
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
class
QHelpEnginePrivate
16
{
17
public
:
18
QHelpEnginePrivate
(QHelpEngineCore *helpEngineCore);
19
20
QHelpContentModel *
contentModel
=
nullptr
;
21
QHelpContentWidget *
contentWidget
=
nullptr
;
22
23
QHelpIndexModel *
indexModel
=
nullptr
;
24
QHelpIndexWidget *
indexWidget
=
nullptr
;
25
26
QHelpSearchEngine *
searchEngine
=
nullptr
;
27
28
bool
m_isApplyCurrentFilterScheduled
=
false
;
29
QHelpEngineCore *
m_helpEngineCore
=
nullptr
;
30
};
31
32
QHelpEnginePrivate
::
QHelpEnginePrivate
(QHelpEngineCore *helpEngineCore)
33
:
m_helpEngineCore
(helpEngineCore)
34
{
35
if
(!
contentModel
)
36
contentModel
=
new
QHelpContentModel(helpEngineCore);
37
if
(!
indexModel
)
38
indexModel
=
new
QHelpIndexModel(m_helpEngineCore);
39
40
const
auto
applyCurrentFilter = [
this
] {
41
m_isApplyCurrentFilterScheduled
=
false
;
42
contentModel
->createContentsForCurrentFilter();
43
indexModel
->createIndexForCurrentFilter();
44
};
45
46
const
auto
scheduleApplyCurrentFilter = [
this
, applyCurrentFilter] {
47
if
(!
m_helpEngineCore
->error().isEmpty())
48
return
;
49
50
if
(
m_isApplyCurrentFilterScheduled
)
51
return
;
52
53
m_isApplyCurrentFilterScheduled
=
true
;
54
QTimer::singleShot(0, m_helpEngineCore, applyCurrentFilter);
55
};
56
57
QObject::connect(m_helpEngineCore, &QHelpEngineCore::setupFinished,
58
m_helpEngineCore, scheduleApplyCurrentFilter);
59
QObject::connect(m_helpEngineCore, &QHelpEngineCore::currentFilterChanged,
60
m_helpEngineCore, scheduleApplyCurrentFilter);
61
QObject::connect(m_helpEngineCore->filterEngine(), &QHelpFilterEngine::filterActivated,
62
m_helpEngineCore, scheduleApplyCurrentFilter);
63
}
64
65
/*!
66
\class QHelpEngine
67
\since 4.4
68
\inmodule QtHelp
69
\brief The QHelpEngine class provides access to contents and
70
indices of the help engine.
71
*/
72
73
/*!
74
Constructs a new help engine with the given \a parent. The help
75
engine uses the information stored in the \a collectionFile for
76
providing help. If the collection file does not already exist,
77
it will be created.
78
*/
79
QHelpEngine::QHelpEngine(
const
QString &collectionFile, QObject *parent)
80
: QHelpEngineCore(collectionFile, parent)
81
, d(
new
QHelpEnginePrivate(
this
))
82
{}
83
84
/*!
85
Destroys the help engine object.
86
*/
87
QHelpEngine::~QHelpEngine()
88
{
89
delete
d;
90
}
91
92
/*!
93
Returns the content model.
94
*/
95
QHelpContentModel *QHelpEngine::contentModel()
const
96
{
97
return
d->contentModel;
98
}
99
100
/*!
101
Returns the index model.
102
*/
103
QHelpIndexModel *QHelpEngine::indexModel()
const
104
{
105
return
d->indexModel;
106
}
107
108
/*!
109
Returns the content widget.
110
*/
111
QHelpContentWidget *QHelpEngine::contentWidget()
112
{
113
if
(!d->contentWidget) {
114
d->contentWidget =
new
QHelpContentWidget;
115
d->contentWidget->setModel(d->contentModel);
116
#
if
QT_CONFIG
(
cursor
)
117
connect(d->contentModel, &QHelpContentModel::contentsCreationStarted,
this
, [
this
] {
118
d->contentWidget->setCursor(Qt::WaitCursor);
119
});
120
connect(d->contentModel, &QHelpContentModel::contentsCreated,
this
, [
this
] {
121
d->contentWidget->unsetCursor();
122
});
123
#
endif
124
}
125
return
d->contentWidget;
126
}
127
128
/*!
129
Returns the index widget.
130
*/
131
QHelpIndexWidget *QHelpEngine::indexWidget()
132
{
133
if
(!d->indexWidget) {
134
d->indexWidget =
new
QHelpIndexWidget;
135
d->indexWidget->setModel(d->indexModel);
136
#
if
QT_CONFIG
(
cursor
)
137
connect(d->indexModel, &QHelpIndexModel::indexCreationStarted,
this
, [
this
] {
138
d->indexWidget->setCursor(Qt::WaitCursor);
139
});
140
connect(d->indexModel, &QHelpIndexModel::indexCreated,
this
, [
this
] {
141
d->indexWidget->unsetCursor();
142
});
143
#
endif
144
}
145
return
d->indexWidget;
146
}
147
148
/*!
149
Returns the default search engine.
150
*/
151
QHelpSearchEngine* QHelpEngine::searchEngine()
152
{
153
if
(!d->searchEngine)
154
d->searchEngine =
new
QHelpSearchEngine(
this
,
this
);
155
return
d->searchEngine;
156
}
157
158
QT_END_NAMESPACE
QHelpEnginePrivate
Definition
qhelpengine.cpp:16
QHelpEnginePrivate::searchEngine
QHelpSearchEngine * searchEngine
Definition
qhelpengine.cpp:26
QHelpEnginePrivate::indexWidget
QHelpIndexWidget * indexWidget
Definition
qhelpengine.cpp:24
QHelpEnginePrivate::contentModel
QHelpContentModel * contentModel
Definition
qhelpengine.cpp:20
QHelpEnginePrivate::QHelpEnginePrivate
QHelpEnginePrivate(QHelpEngineCore *helpEngineCore)
Definition
qhelpengine.cpp:32
QHelpEnginePrivate::m_helpEngineCore
QHelpEngineCore * m_helpEngineCore
Definition
qhelpengine.cpp:29
QHelpEnginePrivate::m_isApplyCurrentFilterScheduled
bool m_isApplyCurrentFilterScheduled
Definition
qhelpengine.cpp:28
QHelpEnginePrivate::indexModel
QHelpIndexModel * indexModel
Definition
qhelpengine.cpp:23
QHelpEnginePrivate::contentWidget
QHelpContentWidget * contentWidget
Definition
qhelpengine.cpp:21
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qttools
src
assistant
help
qhelpengine.cpp
Generated on
for Qt by
1.18.0