Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
5
6#include <QtCore/qstringlist.h>
7
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 */
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*/
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*/
54void 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 */
73{
74 return std::any_of(m_members.cbegin(), m_members.cend(), [](const Node *member) {
75 return member->isClassNode() && member->isInAPI();
76 });
77}
78
79/*!
80 Returns \c true if this collection node contains at least
81 one class node.
82 */
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*/
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 */
124void 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
147QT_END_NAMESPACE
A class for holding the members of a collection of doc pages.
QString logicalModuleVersion() const override
Returns the logical module version.
bool hasClasses() const override
Returns true if this collection node contains at least one class node.
bool hasNamespaces() const override
Returns true if this collection node contains at least one namespace node.
bool wasSeen() const override
Returns the seen flag data member of this node if it is a NamespaceNode or a CollectionNode.
void setStatus(Status status) override
\reimp
void setLogicalModuleInfo(const QStringList &info) override
This function accepts the logical module info as a string list.
void addMember(Node *node) override
Appends node to the collection node's member list and updates the new member's status.
Status
Specifies the status of the QQmlIncubator.
Combined button and popup list for selecting options.
@ Active
Definition status.h:14
The Node class is the base class for all the nodes in QDoc's parse tree.
Genus genus() const override
Returns this node's Genus.
Definition node.h:85
virtual Status status() const
Returns the node's status value.
Definition node.h:239
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:917
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
Definition node.h:143
virtual void setStatus(Status t)
Sets the node's status to t.
Definition node.cpp:570