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, if |
17 | and only if it isn't already in the member list. |
18 | */ |
19 | void CollectionNode::addMember(Node *node) |
20 | { |
21 | if (!m_members.contains(t: node)) |
22 | m_members.append(t: node); |
23 | } |
24 | |
25 | /*! |
26 | Returns \c true if this collection node contains at least |
27 | one namespace node. |
28 | */ |
29 | bool CollectionNode::hasNamespaces() const |
30 | { |
31 | return std::any_of(first: m_members.cbegin(), last: m_members.cend(), pred: [](const Node *member) { |
32 | return member->isClassNode() && member->isInAPI(); |
33 | }); |
34 | } |
35 | |
36 | /*! |
37 | Returns \c true if this collection node contains at least |
38 | one class node. |
39 | */ |
40 | bool CollectionNode::hasClasses() const |
41 | { |
42 | return std::any_of(first: m_members.cbegin(), last: m_members.cend(), pred: [](const Node *member) { |
43 | return member->isClassNode() && member->isInAPI(); |
44 | }); |
45 | } |
46 | |
47 | /*! |
48 | Loads \a out with all this collection node's members that |
49 | are namespace nodes. |
50 | */ |
51 | void CollectionNode::getMemberNamespaces(NodeMap &out) |
52 | { |
53 | out.clear(); |
54 | for (const auto &member : std::as_const(t&: m_members)) { |
55 | if (member->isNamespace() && member->isInAPI()) |
56 | out.insert(key: member->name(), value: member); |
57 | } |
58 | } |
59 | |
60 | /*! |
61 | Loads \a out with all this collection node's members that |
62 | are class nodes. |
63 | */ |
64 | void CollectionNode::getMemberClasses(NodeMap &out) const |
65 | { |
66 | out.clear(); |
67 | for (const auto &member : std::as_const(t: m_members)) { |
68 | if (member->isClassNode() && member->isInAPI()) |
69 | out.insert(key: member->name(), value: member); |
70 | } |
71 | } |
72 | |
73 | /*! |
74 | Returns the logical module version. |
75 | */ |
76 | QString CollectionNode::logicalModuleVersion() const |
77 | { |
78 | QStringList version; |
79 | version << m_logicalModuleVersionMajor << m_logicalModuleVersionMinor; |
80 | version.removeAll(t: QString()); |
81 | return version.join(sep: "." ); |
82 | } |
83 | |
84 | /*! |
85 | This function accepts the logical module \a info as a string |
86 | list. If the logical module info contains the version number, |
87 | it splits the version number on the '.' character to get the |
88 | major and minor version numbers. Both major and minor version |
89 | numbers should be provided, but the minor version number is |
90 | not strictly necessary. |
91 | */ |
92 | void CollectionNode::setLogicalModuleInfo(const QStringList &info) |
93 | { |
94 | m_logicalModuleName = info[0]; |
95 | if (info.size() > 1) { |
96 | QStringList dotSplit = info[1].split(sep: QLatin1Char('.')); |
97 | m_logicalModuleVersionMajor = dotSplit[0]; |
98 | if (dotSplit.size() > 1) |
99 | m_logicalModuleVersionMinor = dotSplit[1]; |
100 | else |
101 | m_logicalModuleVersionMinor = "0" ; |
102 | } |
103 | } |
104 | |
105 | /*! |
106 | \fn void CollectionNode::setState(const QString &state) |
107 | \fn QString CollectionNode::state() |
108 | |
109 | Sets or gets a description of this module's state. For example, |
110 | \e {"Technical Preview"}. This string is used when generating the |
111 | module's documentation page and reference pages of the module's |
112 | members. |
113 | */ |
114 | |
115 | QT_END_NAMESPACE |
116 | |