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
collectionnode.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
#
include
"collectionnode.h"
5
6
#
include
<
QtCore
/
qstringlist
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\class CollectionNode
12
\brief A class for holding the members of a collection of doc pages.
13
*/
14
15
/*!
16
Appends \a node to the collection node's member list and
17
updates the new member's status.
18
19
\sa setMemberStatus()
20
*/
21
void
CollectionNode
::
addMember
(
Node
*node)
22
{
23
if
(!m_members.contains(node))
24
m_members.append(node);
25
setMemberStatus(node);
26
}
27
28
/*!
29
\reimp
30
31
Sets this collection node's \a status and propagates it to
32
the collection's members.
33
*/
34
void
CollectionNode
::
setStatus
(
Status
status)
35
{
36
Node
::
setStatus
(status);
37
std
::for_each(m_members.begin(), m_members.end(),
38
[
this
](
Node
*m) {
this
->setMemberStatus(m); });
39
}
40
41
/*!
42
Propagates the collection's status to \a member node.
43
44
To avoid unexpected results, this propagation is done only if:
45
46
\list
47
\li Both the member and the collection are part of an API
48
(that is, this collection is a module),
49
\li the module was \e seen (documented in the current
50
project), and
51
\li the member node has not set a custom status.
52
\endlist
53
*/
54
void
CollectionNode
::setMemberStatus(
Node
*member)
55
{
56
if
(!
wasSeen
(
)
)
57
return
;
58
59
if
(!isApiGenus(
this
->
genus
()) || !isApiGenus(member
->
genus
(
)
))
60
return
;
61
62
if
(member
->
status
(
)
!=
Status
::
Active
)
63
return
;
64
65
member
->
setStatus
(
this
->
status
()
)
;
66
}
67
68
/*!
69
Returns \c true if this collection node contains at least
70
one namespace node.
71
*/
72
bool
CollectionNode
::
hasNamespaces
()
const
73
{
74
return
std
::any_of(m_members.cbegin(), m_members.cend(), [](
const
Node
*member) {
75
return
member
->
isNamespace
(
)
&& member
->
isInAPI
(
)
;
76
});
77
}
78
79
/*!
80
Returns \c true if this collection node contains at least
81
one class node.
82
*/
83
bool
CollectionNode
::
hasClasses
()
const
84
{
85
return
std
::any_of(m_members.cbegin(), m_members.cend(), [](
const
Node
*member) {
86
return
member
->
isClassNode
(
)
&& member
->
isInAPI
(
)
;
87
});
88
}
89
90
/*!
91
\fn template <typename F> NodeMap CollectionNode::getMembers(const F &&predicate) const
92
93
Returns a map containing this collection node's member nodes for which \c
94
predicate(node) returns \c true. The \a predicate is a function or a
95
lambda that takes a const Node pointer as an argument and returns a bool.
96
*/
97
98
/*!
99
\fn NodeMap CollectionNode::getMembers(Node::NodeType type) const
100
101
Returns a map containing this collection node's member nodes with
102
a specified node \a type.
103
*/
104
105
/*!
106
Returns the logical module version.
107
*/
108
QString
CollectionNode
::
logicalModuleVersion
()
const
109
{
110
QStringList version;
111
version << m_logicalModuleVersionMajor << m_logicalModuleVersionMinor;
112
version.removeAll(QString());
113
return
version.join(
"."
);
114
}
115
116
/*!
117
This function accepts the logical module \a info as a string
118
list. If the logical module info contains the version number,
119
it splits the version number on the '.' character to get the
120
major and minor version numbers. Both major and minor version
121
numbers should be provided, but the minor version number is
122
not strictly necessary.
123
*/
124
void
CollectionNode
::
setLogicalModuleInfo
(
const
QStringList &info)
125
{
126
m_logicalModuleName = info[0];
127
if
(info.size() > 1) {
128
QStringList dotSplit = info[1].split(QLatin1Char(
'.'
));
129
m_logicalModuleVersionMajor = dotSplit[0];
130
if
(dotSplit.size() > 1)
131
m_logicalModuleVersionMinor = dotSplit[1];
132
else
133
m_logicalModuleVersionMinor =
"0"
;
134
}
135
}
136
137
/*!
138
\fn void CollectionNode::setState(const QString &state)
139
\fn QString CollectionNode::state()
140
141
Sets or gets a description of this module's state. For example,
142
\e {"Technology Preview"}. This string is used when generating the
143
module's documentation page and reference pages of the module's
144
members.
145
*/
146
147
/*!
148
\variable CollectionNode::m_resolvedPhysicalModuleName
149
150
\internal
151
152
Records the physical module name of the upstream Tree whose content
153
this CollectionNode mirrors. The field is set during
154
QDocDatabase::mergeCollections when a placeholder absorbs title and
155
url from an authoritative version in another Tree, and stays empty
156
when the collection node is itself the source-of-truth.
157
158
HrefResolver consults this in preference to tree()->physicalModuleName()
159
so that cross-module group, module, and qmlmodule references emit
160
layout-aware hrefs based on the content origin rather than the
161
placeholder's location.
162
*/
163
164
QT_END_NAMESPACE
CollectionNode
A class for holding the members of a collection of doc pages.
Definition
collectionnode.h:17
CollectionNode::logicalModuleVersion
QString logicalModuleVersion() const override
Returns the logical module version.
Definition
collectionnode.cpp:108
CollectionNode::hasClasses
bool hasClasses() const override
Returns true if this collection node contains at least one class node.
Definition
collectionnode.cpp:83
CollectionNode::hasNamespaces
bool hasNamespaces() const override
Returns true if this collection node contains at least one namespace node.
Definition
collectionnode.cpp:72
CollectionNode::wasSeen
bool wasSeen() const override
Returns the seen flag data member of this node if it is a NamespaceNode or a CollectionNode.
Definition
collectionnode.h:37
CollectionNode::setStatus
void setStatus(Status status) override
\reimp
Definition
collectionnode.cpp:34
CollectionNode::setLogicalModuleInfo
void setLogicalModuleInfo(const QStringList &info) override
This function accepts the logical module info as a string list.
Definition
collectionnode.cpp:124
CollectionNode::addMember
void addMember(Node *node) override
Appends node to the collection node's member list and updates the new member's status.
Definition
collectionnode.cpp:21
QQmlIncubator::Status
Status
Specifies the status of the QQmlIncubator.
Definition
qqmlincubator.h:29
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
Status::Active
@ Active
Definition
status.h:14
Node
The Node class is the base class for all the nodes in QDoc's parse tree.
Definition
src_corelib_text_qstring.cpp:10
Node::isNamespace
bool isNamespace() const
Returns true if the node type is Namespace.
Definition
node.h:110
Node::genus
Genus genus() const override
Returns this node's Genus.
Definition
node.h:85
Node::status
virtual Status status() const
Returns the node's status value.
Definition
node.h:243
Node::isInAPI
virtual bool isInAPI() const
Returns true if this node is considered to be part of the API as per the InclusionPolicy retrieved fr...
Definition
node.cpp:927
Node::isClassNode
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
Definition
node.h:145
Node::setStatus
virtual void setStatus(Status t)
Sets the node's status to t.
Definition
node.cpp:574
qttools
src
qdoc
qdoc
src
qdoc
collectionnode.cpp
Generated on
for Qt by
1.18.0