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 | #ifndef SECTIONS_H |
5 | #define SECTIONS_H |
6 | |
7 | #include "node.h" |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | class Aggregate; |
12 | |
13 | typedef std::pair<const QmlTypeNode *, NodeVector> ClassNodes; |
14 | typedef QList<ClassNodes> ClassNodesList; |
15 | |
16 | class Section |
17 | { |
18 | public: |
19 | enum Style { Summary, Details, AllMembers, Accessors }; |
20 | |
21 | public: |
22 | Section( |
23 | QString title, QString singular, QString plural, |
24 | QString divclass, Style style |
25 | ) : m_title{title}, m_singular{singular}, m_plural{plural}, |
26 | m_divClass{divclass}, m_style{style} |
27 | {} |
28 | |
29 | ~Section(); |
30 | |
31 | void insert(Node *node); |
32 | bool insertReimplementedMember(Node *node); |
33 | |
34 | void appendMember(Node *node) { m_members.append(t: node); } |
35 | |
36 | void clear(); |
37 | void reduce(); |
38 | [[nodiscard]] bool isEmpty() const |
39 | { |
40 | return (m_members.isEmpty() && m_inheritedMembers.isEmpty() |
41 | && m_reimplementedMemberMap.isEmpty() && m_classNodesList.isEmpty()); |
42 | } |
43 | |
44 | [[nodiscard]] Style style() const { return m_style; } |
45 | [[nodiscard]] const QString &title() const { return m_title; } |
46 | [[nodiscard]] const QString &divClass() const { return m_divClass; } |
47 | [[nodiscard]] const QString &singular() const { return m_singular; } |
48 | [[nodiscard]] const QString &plural() const { return m_plural; } |
49 | [[nodiscard]] const NodeVector &members() const { return m_members; } |
50 | [[nodiscard]] const NodeVector &reimplementedMembers() const { return m_reimplementedMembers; } |
51 | [[nodiscard]] const QList<std::pair<Aggregate *, int>> &inheritedMembers() const |
52 | { |
53 | return m_inheritedMembers; |
54 | } |
55 | ClassNodesList &classNodesList() { return m_classNodesList; } |
56 | [[nodiscard]] const NodeVector &obsoleteMembers() const { return m_obsoleteMembers; } |
57 | void appendMembers(const NodeVector &nv) { m_members.append(l: nv); } |
58 | [[nodiscard]] const Aggregate *aggregate() const { return m_aggregate; } |
59 | void setAggregate(Aggregate *t) { m_aggregate = t; } |
60 | |
61 | private: |
62 | QString m_title {}; |
63 | QString m_singular {}; |
64 | QString m_plural {}; |
65 | QString m_divClass {}; |
66 | Style m_style {}; |
67 | |
68 | Aggregate *m_aggregate { nullptr }; |
69 | NodeVector m_members {}; |
70 | NodeVector m_obsoleteMembers {}; |
71 | NodeVector m_reimplementedMembers {}; |
72 | QList<std::pair<Aggregate *, int>> m_inheritedMembers {}; |
73 | ClassNodesList m_classNodesList {}; |
74 | |
75 | QMultiMap<QString, Node *> m_reimplementedMemberMap {}; |
76 | }; |
77 | |
78 | typedef QList<Section> SectionVector; |
79 | typedef QList<const Section *> SectionPtrVector; |
80 | |
81 | class Sections |
82 | { |
83 | public: |
84 | enum VectorIndex { |
85 | PublicTypes = 0, |
86 | DetailsMemberTypes = 0, |
87 | SinceNamespaces = 0, |
88 | StdNamespaces = 0, |
89 | QmlProperties = 0, |
90 | Properties = 1, |
91 | DetailsProperties = 1, |
92 | SinceClasses = 1, |
93 | StdClasses = 1, |
94 | QmlAttachedProperties = 1, |
95 | PublicFunctions = 2, |
96 | DetailsMemberFunctions = 2, |
97 | SinceMemberFunctions = 2, |
98 | StdTypes = 2, |
99 | QmlSignals = 2, |
100 | PublicSlots = 3, |
101 | DetailsMemberVariables = 3, |
102 | SinceNamespaceFunctions = 3, |
103 | StdVariables = 3, |
104 | QmlSignalHandlers = 3, |
105 | Signals = 4, |
106 | SinceGlobalFunctions = 4, |
107 | DetailsRelatedNonmembers = 4, |
108 | StdStaticVariables = 4, |
109 | QmlAttachedSignals = 4, |
110 | PublicVariables = 5, |
111 | SinceMacros = 5, |
112 | DetailsMacros = 5, |
113 | StdFunctions = 5, |
114 | QmlMethods = 5, |
115 | StaticPublicMembers = 6, |
116 | SinceEnumTypes = 6, |
117 | StdMacros = 6, |
118 | QmlAttachedMethods = 6, |
119 | SinceEnumValues = 7, |
120 | ProtectedTypes = 7, |
121 | SinceTypeAliases = 8, |
122 | ProtectedFunctions = 8, |
123 | SinceProperties = 9, |
124 | ProtectedSlots = 9, |
125 | SinceVariables = 10, |
126 | ProtectedVariables = 10, |
127 | SinceQmlTypes = 11, |
128 | StaticProtectedMembers = 11, |
129 | SinceQmlProperties = 12, |
130 | PrivateTypes = 12, |
131 | SinceQmlSignals = 13, |
132 | PrivateFunctions = 13, |
133 | SinceQmlSignalHandlers = 14, |
134 | PrivateSlots = 14, |
135 | SinceQmlMethods = 15, |
136 | StaticPrivateMembers = 15, |
137 | RelatedNonmembers = 16, |
138 | Macros = 17 |
139 | }; |
140 | |
141 | explicit Sections(Aggregate *aggregate); |
142 | explicit Sections(const NodeMultiMap &nsmap); |
143 | ~Sections(); |
144 | |
145 | void clear(SectionVector &v); |
146 | void reduce(SectionVector &v); |
147 | void buildStdRefPageSections(); |
148 | void buildStdCppClassRefPageSections(); |
149 | void buildStdQmlTypeRefPageSections(); |
150 | |
151 | bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const; |
152 | |
153 | static Section &() { return s_allMembers[0]; } |
154 | SectionVector &sinceSections() { return s_sinceSections; } |
155 | SectionVector &stdSummarySections() { return s_stdSummarySections; } |
156 | SectionVector &stdDetailsSections() { return s_stdDetailsSections; } |
157 | SectionVector &stdCppClassSummarySections() { return s_stdCppClassSummarySections; } |
158 | SectionVector &stdCppClassDetailsSections() { return s_stdCppClassDetailsSections; } |
159 | SectionVector &stdQmlTypeSummarySections() { return s_stdQmlTypeSummarySections; } |
160 | SectionVector &stdQmlTypeDetailsSections() { return s_stdQmlTypeDetailsSections; } |
161 | |
162 | [[nodiscard]] const SectionVector &stdSummarySections() const { return s_stdSummarySections; } |
163 | [[nodiscard]] const SectionVector &stdDetailsSections() const { return s_stdDetailsSections; } |
164 | [[nodiscard]] const SectionVector &stdCppClassSummarySections() const |
165 | { |
166 | return s_stdCppClassSummarySections; |
167 | } |
168 | [[nodiscard]] const SectionVector &stdCppClassDetailsSections() const |
169 | { |
170 | return s_stdCppClassDetailsSections; |
171 | } |
172 | [[nodiscard]] const SectionVector &stdQmlTypeSummarySections() const |
173 | { |
174 | return s_stdQmlTypeSummarySections; |
175 | } |
176 | [[nodiscard]] const SectionVector &stdQmlTypeDetailsSections() const |
177 | { |
178 | return s_stdQmlTypeDetailsSections; |
179 | } |
180 | |
181 | [[nodiscard]] Aggregate *aggregate() const { return m_aggregate; } |
182 | |
183 | private: |
184 | void stdRefPageSwitch(SectionVector &v, Node *n, Node *t = nullptr); |
185 | void distributeNodeInSummaryVector(SectionVector &sv, Node *n); |
186 | void distributeNodeInDetailsVector(SectionVector &dv, Node *n); |
187 | void distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n); |
188 | void distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool sharing = false); |
189 | void initAggregate(SectionVector &v, Aggregate *aggregate); |
190 | |
191 | private: |
192 | Aggregate *m_aggregate { nullptr }; |
193 | |
194 | static SectionVector s_stdSummarySections; |
195 | static SectionVector s_stdDetailsSections; |
196 | static SectionVector s_stdCppClassSummarySections; |
197 | static SectionVector s_stdCppClassDetailsSections; |
198 | static SectionVector s_stdQmlTypeSummarySections; |
199 | static SectionVector s_stdQmlTypeDetailsSections; |
200 | static SectionVector s_sinceSections; |
201 | static SectionVector s_allMembers; |
202 | }; |
203 | |
204 | QT_END_NAMESPACE |
205 | |
206 | #endif |
207 | |