| 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 | QmlEnumTypes = 0, |
| 90 | QmlProperties = 1, |
| 91 | Properties = 1, |
| 92 | DetailsProperties = 1, |
| 93 | SinceClasses = 1, |
| 94 | StdClasses = 1, |
| 95 | QmlAttachedProperties = 2, |
| 96 | PublicFunctions = 2, |
| 97 | DetailsMemberFunctions = 2, |
| 98 | SinceMemberFunctions = 2, |
| 99 | StdTypes = 2, |
| 100 | QmlSignals = 3, |
| 101 | PublicSlots = 3, |
| 102 | DetailsMemberVariables = 3, |
| 103 | SinceNamespaceFunctions = 3, |
| 104 | StdVariables = 3, |
| 105 | QmlSignalHandlers = 4, |
| 106 | Signals = 4, |
| 107 | SinceGlobalFunctions = 4, |
| 108 | DetailsRelatedNonmembers = 4, |
| 109 | StdStaticVariables = 4, |
| 110 | QmlAttachedSignals = 5, |
| 111 | PublicVariables = 5, |
| 112 | SinceMacros = 5, |
| 113 | DetailsMacros = 5, |
| 114 | StdFunctions = 5, |
| 115 | QmlMethods = 6, |
| 116 | StaticPublicMembers = 6, |
| 117 | SinceEnumTypes = 6, |
| 118 | StdMacros = 6, |
| 119 | QmlAttachedMethods = 7, |
| 120 | SinceEnumValues = 7, |
| 121 | ProtectedTypes = 7, |
| 122 | SinceTypeAliases = 8, |
| 123 | ProtectedFunctions = 8, |
| 124 | SinceProperties = 9, |
| 125 | ProtectedSlots = 9, |
| 126 | SinceVariables = 10, |
| 127 | ProtectedVariables = 10, |
| 128 | SinceQmlTypes = 11, |
| 129 | StaticProtectedMembers = 11, |
| 130 | PrivateTypes = 12, |
| 131 | SinceQmlEnumTypes = 12, |
| 132 | SinceQmlProperties = 13, |
| 133 | PrivateFunctions = 13, |
| 134 | SinceQmlSignals = 14, |
| 135 | PrivateSlots = 14, |
| 136 | SinceQmlSignalHandlers = 15, |
| 137 | StaticPrivateMembers = 15, |
| 138 | SinceQmlMethods = 16, |
| 139 | RelatedNonmembers = 16, |
| 140 | Macros = 17 |
| 141 | }; |
| 142 | |
| 143 | explicit Sections(Aggregate *aggregate); |
| 144 | explicit Sections(const NodeMultiMap &nsmap); |
| 145 | ~Sections(); |
| 146 | |
| 147 | void clear(SectionVector &v); |
| 148 | void reduce(SectionVector &v); |
| 149 | void buildStdRefPageSections(); |
| 150 | void buildStdCppClassRefPageSections(); |
| 151 | void buildStdQmlTypeRefPageSections(); |
| 152 | |
| 153 | bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const; |
| 154 | |
| 155 | static Section &() { return s_allMembers[0]; } |
| 156 | SectionVector &sinceSections() { return s_sinceSections; } |
| 157 | SectionVector &stdSummarySections() { return s_stdSummarySections; } |
| 158 | SectionVector &stdDetailsSections() { return s_stdDetailsSections; } |
| 159 | SectionVector &stdCppClassSummarySections() { return s_stdCppClassSummarySections; } |
| 160 | SectionVector &stdCppClassDetailsSections() { return s_stdCppClassDetailsSections; } |
| 161 | SectionVector &stdQmlTypeSummarySections() { return s_stdQmlTypeSummarySections; } |
| 162 | SectionVector &stdQmlTypeDetailsSections() { return s_stdQmlTypeDetailsSections; } |
| 163 | |
| 164 | [[nodiscard]] const SectionVector &stdSummarySections() const { return s_stdSummarySections; } |
| 165 | [[nodiscard]] const SectionVector &stdDetailsSections() const { return s_stdDetailsSections; } |
| 166 | [[nodiscard]] const SectionVector &stdCppClassSummarySections() const |
| 167 | { |
| 168 | return s_stdCppClassSummarySections; |
| 169 | } |
| 170 | [[nodiscard]] const SectionVector &stdCppClassDetailsSections() const |
| 171 | { |
| 172 | return s_stdCppClassDetailsSections; |
| 173 | } |
| 174 | [[nodiscard]] const SectionVector &stdQmlTypeSummarySections() const |
| 175 | { |
| 176 | return s_stdQmlTypeSummarySections; |
| 177 | } |
| 178 | [[nodiscard]] const SectionVector &stdQmlTypeDetailsSections() const |
| 179 | { |
| 180 | return s_stdQmlTypeDetailsSections; |
| 181 | } |
| 182 | |
| 183 | [[nodiscard]] Aggregate *aggregate() const { return m_aggregate; } |
| 184 | |
| 185 | private: |
| 186 | void stdRefPageSwitch(SectionVector &v, Node *n); |
| 187 | void distributeNodeInSummaryVector(SectionVector &sv, Node *n); |
| 188 | void distributeNodeInDetailsVector(SectionVector &dv, Node *n); |
| 189 | void distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n); |
| 190 | void distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool sharing = false); |
| 191 | void initAggregate(SectionVector &v, Aggregate *aggregate); |
| 192 | |
| 193 | private: |
| 194 | Aggregate *m_aggregate { nullptr }; |
| 195 | |
| 196 | static SectionVector s_stdSummarySections; |
| 197 | static SectionVector s_stdDetailsSections; |
| 198 | static SectionVector s_stdCppClassSummarySections; |
| 199 | static SectionVector s_stdCppClassDetailsSections; |
| 200 | static SectionVector s_stdQmlTypeSummarySections; |
| 201 | static SectionVector s_stdQmlTypeDetailsSections; |
| 202 | static SectionVector s_sinceSections; |
| 203 | static SectionVector s_allMembers; |
| 204 | }; |
| 205 | |
| 206 | QT_END_NAMESPACE |
| 207 | |
| 208 | #endif |
| 209 | |