1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef NODE_H
#define NODE_H
#include <qdir.h>
#include <qmap.h>
#include <qpair.h>
#include <qstringlist.h>
#include "codechunk.h"
#include "doc.h"
QT_BEGIN_NAMESPACE
class Node;
class Tree;
class EnumNode;
class ClassNode;
class InnerNode;
class ExampleNode;
class TypedefNode;
class QmlTypeNode;
class QDocDatabase;
class FunctionNode;
class PropertyNode;
class QmlModuleNode;
class CollectionNode;
class QmlPropertyNode;
typedef QList<Node*> NodeList;
typedef QMap<QString, Node*> NodeMap;
typedef QMultiMap<QString, Node*> NodeMultiMap;
typedef QPair<int, int> NodeTypePair;
typedef QList<NodeTypePair> NodeTypeList;
typedef QMap<QString, CollectionNode*> CNMap;
typedef QMultiMap<QString, CollectionNode*> CNMultiMap;
class Node
{
Q_DECLARE_TR_FUNCTIONS(QDoc::Node)
public:
enum Type {
NoType,
Namespace,
Class,
Document,
Enum,
Typedef,
Function,
Property,
Variable,
Group,
Module,
QmlType,
QmlModule,
QmlPropertyGroup,
QmlProperty,
QmlSignal,
QmlSignalHandler,
QmlMethod,
QmlBasicType,
LastType
};
enum SubType {
NoSubType,
Example,
HeaderFile,
File,
Image,
Page,
ExternalPage,
DitaMap,
LastSubtype
};
enum Genus { DontCare, CPP, JS, QML, DOC };
enum Access { Public, Protected, Private };
enum Status {
Compat,
Obsolete,
Deprecated,
Preliminary,
Commendable,
Main,
Internal
}; // don't reorder this enum
enum ThreadSafeness {
UnspecifiedSafeness,
NonReentrant,
Reentrant,
ThreadSafe
};
enum LinkType {
StartLink,
NextLink,
PreviousLink,
ContentsLink,
IndexLink /*,
GlossaryLink,
CopyrightLink,
ChapterLink,
SectionLink,
SubsectionLink,
AppendixLink */
};
enum PageType {
NoPageType,
ApiPage,
ArticlePage,
ExamplePage,
HowToPage,
OverviewPage,
TutorialPage,
FAQPage,
DitaMapPage,
OnBeyondZebra
};
enum FlagValue {
FlagValueDefault = -1,
FlagValueFalse = 0,
FlagValueTrue = 1
};
virtual ~Node();
QString plainName() const;
QString plainFullName(const Node* relative = 0) const;
QString fullName(const Node* relative=0) const;
const QString& fileNameBase() const { return fileNameBase_; }
bool hasFileNameBase() const { return !fileNameBase_.isEmpty(); }
void setFileNameBase(const QString& t) { fileNameBase_ = t; }
void setAccess(Access access) { access_ = access; }
void setLocation(const Location& location) { loc_ = location; }
void setDoc(const Doc& doc, bool replace = false);
void setStatus(Status status) {
if (status_ == Obsolete && status == Deprecated)
return;
status_ = status;
}
void setThreadSafeness(ThreadSafeness safeness) { safeness_ = safeness; }
void setSince(const QString &since);
void setRelates(InnerNode* pseudoParent);
void setPhysicalModuleName(const QString &name) { physicalModuleName_ = name; }
void setUrl(const QString& url) { url_ = url; }
void setTemplateStuff(const QString &templateStuff) { templateStuff_ = templateStuff; }
void setReconstitutedBrief(const QString &t) { reconstitutedBrief_ = t; }
void setPageType(PageType t) { pageType_ = t; }
void setPageType(const QString& t);
void setParent(InnerNode* n) { parent_ = n; }
void setIndexNodeFlag() { indexNodeFlag_ = true; }
virtual void setOutputFileName(const QString& ) { }
virtual bool isInnerNode() const = 0;
virtual bool isDocNode() const { return false; }
virtual bool isCollectionNode() const { return false; }
virtual bool isGroup() const { return false; }
virtual bool isModule() const { return false; }
virtual bool isQmlModule() const { return false; }
virtual bool isQmlType() const { return false; }
virtual bool isQmlBasicType() const { return false; }
virtual bool isExample() const { return false; }
virtual bool isExampleFile() const { return false; }
virtual bool isHeaderFile() const { return false; }
virtual bool isLeaf() const { return false; }
virtual bool isReimp() const { return false; }
virtual bool isFunction() const { return false; }
virtual bool isNamespace() const { return false; }
virtual bool isClass() const { return false; }
virtual bool isQmlNode() const { return false; }
virtual bool isCppNode() const { return false; }
virtual bool isQtQuickNode() const { return false; }
virtual bool isAbstract() const { return false; }
virtual bool isQmlPropertyGroup() const { return false; }
virtual bool isAttached() const { return false; }
virtual bool isAlias() const { return false; }
virtual bool isWrapper() const;
virtual bool isReadOnly() const { return false; }
virtual bool isDefault() const { return false; }
virtual bool isExternalPage() const { return false; }
virtual void addMember(Node* ) { }
virtual bool hasMembers() const { return false; }
virtual bool hasNamespaces() const { return false; }
virtual bool hasClasses() const { return false; }
virtual void setAbstract(bool ) { }
virtual void setWrapper() { }
virtual Node::Genus genus() const { return DontCare; }
virtual QString title() const { return name(); }
virtual QString fullTitle() const { return name(); }
virtual QString subTitle() const { return QString(); }
virtual void setTitle(const QString& ) { }
virtual void setSubTitle(const QString& ) { }
virtual QmlPropertyNode* hasQmlProperty(const QString& ) const { return 0; }
virtual QmlPropertyNode* hasQmlProperty(const QString&, bool ) const { return 0; }
virtual void getMemberNamespaces(NodeMap& ) { }
virtual void getMemberClasses(NodeMap& ) { }
virtual bool isInternal() const;
virtual void setDataType(const QString& ) { }
virtual void setReadOnly(bool ) { }
virtual Node* disambiguate(Type , SubType ) { return this; }
virtual bool wasSeen() const { return false; }
virtual void appendGroupName(const QString& ) { }
virtual QString element() const { return QString(); }
virtual Tree* tree() const;
virtual void findChildren(const QString& , NodeList& nodes) const { nodes.clear(); }
bool isIndexNode() const { return indexNodeFlag_; }
Type type() const { return nodeType_; }
virtual SubType subType() const { return NoSubType; }
bool match(const NodeTypeList& types) const;
InnerNode* parent() const { return parent_; }
const Node* root() const;
InnerNode* relates() const { return relatesTo_; }
const QString& name() const { return name_; }
QString physicalModuleName() const;
QString url() const { return url_; }
virtual QString nameForLists() const { return name_; }
virtual QString outputFileName() const { return QString(); }
virtual QString obsoleteLink() const { return QString(); }
virtual void setObsoleteLink(const QString& ) { };
virtual void setQtVariable(const QString& ) { }
virtual QString qtVariable() const { return QString(); }
const QMap<LinkType, QPair<QString,QString> >& links() const { return linkMap_; }
void setLink(LinkType linkType, const QString &link, const QString &desc);
Access access() const { return access_; }
bool isPrivate() const { return access_ == Private; }
QString accessString() const;
const Location& location() const { return loc_; }
const Doc& doc() const { return doc_; }
bool hasDoc() const { return !doc_.isEmpty(); }
Status status() const { return status_; }
Status inheritedStatus() const;
bool isObsolete() const { return (status_ == Obsolete); }
ThreadSafeness threadSafeness() const;
ThreadSafeness inheritedThreadSafeness() const;
QString since() const { return since_; }
QString templateStuff() const { return templateStuff_; }
const QString& reconstitutedBrief() const { return reconstitutedBrief_; }
PageType pageType() const { return pageType_; }
QString pageTypeString() const;
QString nodeTypeString() const;
QString nodeSubtypeString() const;
virtual void addPageKeywords(const QString& ) { }
void clearRelated() { relatesTo_ = 0; }
QString guid() const;
QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
virtual QString qmlFullBaseName() const { return QString(); }
virtual QString logicalModuleName() const { return QString(); }
virtual QString logicalModuleVersion() const { return QString(); }
virtual QString logicalModuleIdentifier() const { return QString(); }
virtual void setQmlModuleInfo(const QString& ) { }
virtual QmlModuleNode* logicalModule() const { return 0; }
virtual void setQmlModule(QmlModuleNode* ) { }
virtual ClassNode* classNode() { return 0; }
virtual void setClassNode(ClassNode* ) { }
virtual const Node* applyModuleName(const Node* ) const { return 0; }
virtual QString idNumber() { return "0"; }
QmlTypeNode* qmlTypeNode();
ClassNode* declarativeCppNode();
const QString& outputSubdirectory() const { return outSubDir_; }
void setOutputSubdirectory(const QString& t) { outSubDir_ = t; }
QString fullDocumentName() const;
static QString cleanId(QString str);
QString idForNode() const;
static FlagValue toFlagValue(bool b);
static bool fromFlagValue(FlagValue fv, bool defaultValue);
static QString pageTypeString(unsigned t);
static QString nodeTypeString(unsigned t);
static QString nodeSubtypeString(unsigned t);
static int incPropertyGroupCount();
static void clearPropertyGroupCount();
static void initialize();
static Type goal(const QString& t) { return goals_.value(t); }
protected:
Node(Type type, InnerNode* parent, const QString& name);
private:
Type nodeType_;
Access access_;
ThreadSafeness safeness_;
PageType pageType_;
Status status_;
bool indexNodeFlag_;
InnerNode* parent_;
InnerNode* relatesTo_;
QString name_;
Location loc_;
Doc doc_;
QMap<LinkType, QPair<QString, QString> > linkMap_;
QString fileNameBase_;
QString physicalModuleName_;
QString url_;
QString since_;
QString templateStuff_;
QString reconstitutedBrief_;
mutable QString uuid_;
QString outSubDir_;
static QStringMap operators_;
static int propertyGroupCount_;
static QMap<QString,Node::Type> goals_;
};
class InnerNode : public Node
{
public:
virtual ~InnerNode();
Node* findChildNode(const QString& name, Node::Genus genus) const;
//Node* findChildNode(const QString& name, bool qml) const;
Node* findChildNode(const QString& name, Type type);
//void findNodes(const QString& name, NodeList& n);
virtual void findChildren(const QString& name, NodeList& nodes) const Q_DECL_OVERRIDE;
FunctionNode* findFunctionNode(const QString& name) const;
FunctionNode* findFunctionNode(const FunctionNode* clone);
void addInclude(const QString &include);
void setIncludes(const QStringList &includes);
void setOverload(const FunctionNode* func, bool overlode);
void normalizeOverloads();
void makeUndocumentedChildrenInternal();
void deleteChildren();
void removeFromRelated();
virtual bool isInnerNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isLeaf() const Q_DECL_OVERRIDE { return false; }
const EnumNode* findEnumNodeForValue(const QString &enumValue) const;
const NodeList & childNodes() const { return children_; }
const NodeList & relatedNodes() const { return related_; }
int count() const { return children_.size(); }
int overloadNumber(const FunctionNode* func) const;
NodeList overloads(const QString &funcName) const;
const QStringList& includes() const { return includes_; }
QStringList primaryKeys();
QStringList secondaryKeys();
const QStringList& pageKeywords() const { return pageKeywds; }
virtual void addPageKeywords(const QString& t) Q_DECL_OVERRIDE { pageKeywds << t; }
virtual void setOutputFileName(const QString& f) Q_DECL_OVERRIDE { outputFileName_ = f; }
virtual QString outputFileName() const Q_DECL_OVERRIDE { return outputFileName_; }
virtual QmlPropertyNode* hasQmlProperty(const QString& ) const Q_DECL_OVERRIDE;
virtual QmlPropertyNode* hasQmlProperty(const QString&, bool attached) const Q_DECL_OVERRIDE;
void addChild(Node* child, const QString& title);
const QStringList& groupNames() const { return groupNames_; }
virtual void appendGroupName(const QString& t) Q_DECL_OVERRIDE { groupNames_.append(t); }
void printChildren(const QString& title);
protected:
InnerNode(Type type, InnerNode* parent, const QString& name);
private:
friend class Node;
static bool isSameSignature(const FunctionNode* f1, const FunctionNode* f2);
void addChild(Node* child);
void removeRelated(Node* pseudoChild);
void removeChild(Node* child);
QString outputFileName_;
QStringList pageKeywds;
QStringList includes_;
QStringList groupNames_;
NodeList children_;
NodeList enumChildren_;
NodeList related_;
QMap<QString, Node*> childMap;
QMap<QString, Node*> primaryFunctionMap;
QMap<QString, NodeList> secondaryFunctionMap;
};
class LeafNode : public Node
{
public:
LeafNode();
virtual ~LeafNode() { }
virtual bool isInnerNode() const Q_DECL_OVERRIDE { return false; }
virtual bool isLeaf() const Q_DECL_OVERRIDE { return true; }
protected:
LeafNode(Type type, InnerNode* parent, const QString& name);
LeafNode(InnerNode* parent, Type type, const QString& name);
};
class NamespaceNode : public InnerNode
{
public:
NamespaceNode(InnerNode* parent, const QString& name);
virtual ~NamespaceNode() { }
virtual bool isNamespace() const Q_DECL_OVERRIDE { return true; }
virtual Tree* tree() const Q_DECL_OVERRIDE { return (parent() ? parent()->tree() : tree_); }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
void setTree(Tree* t) { tree_ = t; }
private:
Tree* tree_;
};
struct RelatedClass
{
RelatedClass() { }
// constructor for resolved base class
RelatedClass(Node::Access access, ClassNode* node)
: access_(access), node_(node) { }
// constructor for unresolved base class
RelatedClass(Node::Access access, const QStringList& path, const QString& signature)
: access_(access), node_(0), path_(path), signature_(signature) { }
QString accessString() const;
bool isPrivate() const { return (access_ == Node::Private); }
Node::Access access_;
ClassNode* node_;
QStringList path_;
QString signature_;
};
class ClassNode : public InnerNode
{
public:
ClassNode(InnerNode* parent, const QString& name);
virtual ~ClassNode() { }
virtual bool isClass() const Q_DECL_OVERRIDE { return true; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isWrapper() const Q_DECL_OVERRIDE { return wrapper_; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
virtual QString obsoleteLink() const Q_DECL_OVERRIDE { return obsoleteLink_; }
virtual void setObsoleteLink(const QString& t) Q_DECL_OVERRIDE { obsoleteLink_ = t; }
virtual void setWrapper() Q_DECL_OVERRIDE { wrapper_ = true; }
void addResolvedBaseClass(Access access, ClassNode* node);
void addDerivedClass(Access access, ClassNode* node);
void addUnresolvedBaseClass(Access access, const QStringList& path, const QString& signature);
void fixBaseClasses();
void fixPropertyUsingBaseClasses(PropertyNode* pn);
QList<RelatedClass>& baseClasses() { return bases_; }
QList<RelatedClass>& derivedClasses() { return derived_; }
QList<RelatedClass>& ignoredBaseClasses() { return ignoredBases_; }
const QList<RelatedClass> &baseClasses() const { return bases_; }
const QList<RelatedClass> &derivedClasses() const { return derived_; }
const QList<RelatedClass> &ignoredBaseClasses() const { return ignoredBases_; }
QString serviceName() const { return sname; }
void setServiceName(const QString& value) { sname = value; }
QmlTypeNode* qmlElement() { return qmlelement; }
void setQmlElement(QmlTypeNode* qcn) { qmlelement = qcn; }
virtual bool isAbstract() const Q_DECL_OVERRIDE { return abstract_; }
virtual void setAbstract(bool b) Q_DECL_OVERRIDE { abstract_ = b; }
PropertyNode* findPropertyNode(const QString& name);
QmlTypeNode* findQmlBaseNode();
private:
QList<RelatedClass> bases_;
QList<RelatedClass> derived_;
QList<RelatedClass> ignoredBases_;
bool abstract_;
bool wrapper_;
QString sname;
QString obsoleteLink_;
QmlTypeNode* qmlelement;
};
class DocNode : public InnerNode
{
public:
DocNode(InnerNode* parent,
const QString& name,
SubType subType,
PageType ptype);
virtual ~DocNode() { }
virtual void setTitle(const QString &title) Q_DECL_OVERRIDE;
virtual void setSubTitle(const QString &subTitle) Q_DECL_OVERRIDE { subtitle_ = subTitle; }
SubType subType() const Q_DECL_OVERRIDE { return nodeSubtype_; }
virtual QString title() const Q_DECL_OVERRIDE { return title_; }
virtual QString fullTitle() const Q_DECL_OVERRIDE;
virtual QString subTitle() const Q_DECL_OVERRIDE;
virtual QString imageFileName() const { return QString(); }
virtual QString nameForLists() const Q_DECL_OVERRIDE { return title(); }
virtual void setImageFileName(const QString& ) { }
virtual bool isHeaderFile() const Q_DECL_OVERRIDE { return (subType() == Node::HeaderFile); }
virtual bool isExample() const Q_DECL_OVERRIDE { return (subType() == Node::Example); }
virtual bool isExampleFile() const Q_DECL_OVERRIDE { return (parent() && parent()->isExample()); }
virtual bool isExternalPage() const Q_DECL_OVERRIDE { return nodeSubtype_ == ExternalPage; }
virtual bool isDocNode() const Q_DECL_OVERRIDE { return true; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::DOC; }
protected:
SubType nodeSubtype_;
QString title_;
QString subtitle_;
};
class ExampleNode : public DocNode
{
public:
ExampleNode(InnerNode* parent, const QString& name)
: DocNode(parent, name, Node::Example, Node::ExamplePage) { }
virtual ~ExampleNode() { }
virtual QString imageFileName() const Q_DECL_OVERRIDE { return imageFileName_; }
virtual void setImageFileName(const QString& ifn) Q_DECL_OVERRIDE { imageFileName_ = ifn; }
private:
QString imageFileName_;
};
struct ImportRec {
QString name_; // module name
QString version_; // <major> . <minor>
QString importId_; // "as" name
QString importUri_; // subdirectory of module directory
ImportRec(const QString& name,
const QString& version,
const QString& importId,
const QString& importUri)
: name_(name), version_(version), importId_(importId), importUri_(importUri) { }
QString& name() { return name_; }
QString& version() { return version_; }
QString& importId() { return importId_; }
QString& importUri() { return importUri_; }
bool isEmpty() const { return name_.isEmpty(); }
};
typedef QList<ImportRec> ImportList;
class QmlTypeNode : public InnerNode
{
public:
QmlTypeNode(InnerNode* parent, const QString& name);
virtual ~QmlTypeNode();
virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isQmlType() const Q_DECL_OVERRIDE { return true; }
virtual bool isQtQuickNode() const Q_DECL_OVERRIDE {
return (logicalModuleName() == QLatin1String("QtQuick"));
}
virtual ClassNode* classNode() Q_DECL_OVERRIDE { return cnode_; }
virtual void setClassNode(ClassNode* cn) Q_DECL_OVERRIDE { cnode_ = cn; }
virtual bool isAbstract() const Q_DECL_OVERRIDE { return abstract_; }
virtual bool isWrapper() const Q_DECL_OVERRIDE { return wrapper_; }
virtual void setAbstract(bool b) Q_DECL_OVERRIDE { abstract_ = b; }
virtual void setWrapper() Q_DECL_OVERRIDE { wrapper_ = true; }
virtual bool isInternal() const Q_DECL_OVERRIDE { return (status() == Internal); }
virtual QString qmlFullBaseName() const Q_DECL_OVERRIDE;
virtual QString obsoleteLink() const Q_DECL_OVERRIDE { return obsoleteLink_; }
virtual void setObsoleteLink(const QString& t) Q_DECL_OVERRIDE { obsoleteLink_ = t; };
virtual QString logicalModuleName() const Q_DECL_OVERRIDE;
virtual QString logicalModuleVersion() const Q_DECL_OVERRIDE;
virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE;
virtual QmlModuleNode* logicalModule() const Q_DECL_OVERRIDE { return logicalModule_; }
virtual void setQmlModule(QmlModuleNode* t) Q_DECL_OVERRIDE { logicalModule_ = t; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; }
const ImportList& importList() const { return importList_; }
void setImportList(const ImportList& il) { importList_ = il; }
const QString& qmlBaseName() const { return qmlBaseName_; }
void setQmlBaseName(const QString& name) { qmlBaseName_ = name; }
bool qmlBaseNodeNotSet() const { return (qmlBaseNode_ == 0); }
QmlTypeNode* qmlBaseNode();
void setQmlBaseNode(QmlTypeNode* b) { qmlBaseNode_ = b; }
void requireCppClass() { cnodeRequired_ = true; }
bool cppClassRequired() const { return cnodeRequired_; }
static void addInheritedBy(const QString& base, Node* sub);
static void subclasses(const QString& base, NodeList& subs);
static void terminate();
public:
static bool qmlOnly;
static QMultiMap<QString,Node*> inheritedBy;
private:
bool abstract_;
bool cnodeRequired_;
bool wrapper_;
ClassNode* cnode_;
QString qmlBaseName_;
QString obsoleteLink_;
QmlModuleNode* logicalModule_;
QmlTypeNode* qmlBaseNode_;
ImportList importList_;
};
class QmlBasicTypeNode : public InnerNode
{
public:
QmlBasicTypeNode(InnerNode* parent,
const QString& name);
virtual ~QmlBasicTypeNode() { }
virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isQmlBasicType() const Q_DECL_OVERRIDE { return true; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; }
};
class QmlPropertyGroupNode : public InnerNode
{
public:
QmlPropertyGroupNode(QmlTypeNode* parent, const QString& name);
virtual ~QmlPropertyGroupNode() { }
virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isQtQuickNode() const Q_DECL_OVERRIDE { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const Q_DECL_OVERRIDE { return parent()->qmlTypeName(); }
virtual QString logicalModuleName() const Q_DECL_OVERRIDE {
return parent()->logicalModuleName();
}
virtual QString logicalModuleVersion() const Q_DECL_OVERRIDE {
return parent()->logicalModuleVersion();
}
virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE {
return parent()->logicalModuleIdentifier();
}
virtual QString idNumber() Q_DECL_OVERRIDE;
virtual bool isQmlPropertyGroup() const Q_DECL_OVERRIDE { return true; }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; }
virtual QString element() const Q_DECL_OVERRIDE { return parent()->name(); }
private:
int idNumber_;
};
class QmlPropertyNode : public LeafNode
{
Q_DECLARE_TR_FUNCTIONS(QDoc::QmlPropertyNode)
public:
QmlPropertyNode(InnerNode *parent,
const QString& name,
const QString& type,
bool attached);
virtual ~QmlPropertyNode() { }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::QML; }
virtual void setDataType(const QString& dataType) Q_DECL_OVERRIDE { type_ = dataType; }
void setStored(bool stored) { stored_ = toFlagValue(stored); }
void setDesignable(bool designable) { designable_ = toFlagValue(designable); }
virtual void setReadOnly(bool ro) Q_DECL_OVERRIDE { readOnly_ = toFlagValue(ro); }
void setDefault() { isdefault_ = true; }
const QString &dataType() const { return type_; }
QString qualifiedDataType() const { return type_; }
bool isReadOnlySet() const { return (readOnly_ != FlagValueDefault); }
bool isStored() const { return fromFlagValue(stored_,true); }
bool isDesignable() const { return fromFlagValue(designable_,false); }
bool isWritable();
virtual bool isDefault() const Q_DECL_OVERRIDE { return isdefault_; }
virtual bool isReadOnly() const Q_DECL_OVERRIDE { return fromFlagValue(readOnly_,false); }
virtual bool isAlias() const Q_DECL_OVERRIDE { return isAlias_; }
virtual bool isAttached() const Q_DECL_OVERRIDE { return attached_; }
virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isQtQuickNode() const Q_DECL_OVERRIDE { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const Q_DECL_OVERRIDE { return parent()->qmlTypeName(); }
virtual QString logicalModuleName() const Q_DECL_OVERRIDE {
return parent()->logicalModuleName();
}
virtual QString logicalModuleVersion() const Q_DECL_OVERRIDE {
return parent()->logicalModuleVersion();
}
virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE {
return parent()->logicalModuleIdentifier();
}
virtual QString element() const Q_DECL_OVERRIDE;
private:
PropertyNode* findCorrespondingCppProperty();
private:
QString type_;
FlagValue stored_;
FlagValue designable_;
bool isAlias_;
bool isdefault_;
bool attached_;
FlagValue readOnly_;
};
class EnumItem
{
public:
EnumItem() { }
EnumItem(const QString& name, const QString& value)
: nam(name), val(value) { }
const QString& name() const { return nam; }
const QString& value() const { return val; }
private:
QString nam;
QString val;
};
class EnumNode : public LeafNode
{
public:
EnumNode(InnerNode* parent, const QString& name);
virtual ~EnumNode() { }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
void addItem(const EnumItem& item);
void setFlagsType(TypedefNode* typedeff);
bool hasItem(const QString &name) const { return names.contains(name); }
const QList<EnumItem>& items() const { return itms; }
Access itemAccess(const QString& name) const;
const TypedefNode* flagsType() const { return ft; }
QString itemValue(const QString &name) const;
private:
QList<EnumItem> itms;
QSet<QString> names;
const TypedefNode* ft;
};
class TypedefNode : public LeafNode
{
public:
TypedefNode(InnerNode* parent, const QString& name);
virtual ~TypedefNode() { }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
const EnumNode* associatedEnum() const { return ae; }
private:
void setAssociatedEnum(const EnumNode* enume);
friend class EnumNode;
const EnumNode* ae;
};
inline void EnumNode::setFlagsType(TypedefNode* typedeff)
{
ft = typedeff;
typedeff->setAssociatedEnum(this);
}
class Parameter
{
public:
Parameter() {}
Parameter(const QString& leftType,
const QString& rightType = QString(),
const QString& name = QString(),
const QString& defaultValue = QString());
Parameter(const Parameter& p);
Parameter& operator=(const Parameter& p);
void setName(const QString& name) { nam = name; }
bool hasType() const { return lef.length() + rig.length() > 0; }
const QString& leftType() const { return lef; }
const QString& rightType() const { return rig; }
const QString& name() const { return nam; }
const QString& defaultValue() const { return def; }
QString reconstruct(bool value = false) const;
private:
QString lef;
QString rig;
QString nam;
QString def;
};
class FunctionNode : public LeafNode
{
public:
enum Metaness {
Plain,
Signal,
Slot,
Ctor,
Dtor,
MacroWithParams,
MacroWithoutParams,
Native };
enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual };
FunctionNode(InnerNode* parent, const QString &name);
FunctionNode(Type type, InnerNode* parent, const QString &name, bool attached);
virtual ~FunctionNode() { }
void setReturnType(const QString& returnType) { rt = returnType; }
void setParentPath(const QStringList& parentPath) { pp = parentPath; }
void setMetaness(Metaness metaness) { met = metaness; }
void setVirtualness(Virtualness virtualness);
void setConst(bool conste) { con = conste; }
void setStatic(bool statique) { sta = statique; }
void setOverload(bool overlode);
void setReimp(bool r);
void addParameter(const Parameter& parameter);
inline void setParameters(const QList<Parameter>& parameters);
void borrowParameterNames(const FunctionNode* source);
void setReimplementedFrom(FunctionNode* from);
const QString& returnType() const { return rt; }
Metaness metaness() const { return met; }
bool isMacro() const {
return met == MacroWithParams || met == MacroWithoutParams;
}
Virtualness virtualness() const { return vir; }
bool isConst() const { return con; }
bool isStatic() const { return sta; }
bool isOverload() const { return ove; }
bool isReimp() const Q_DECL_OVERRIDE { return reimp; }
bool isFunction() const Q_DECL_OVERRIDE { return true; }
int overloadNumber() const;
const QList<Parameter>& parameters() const { return params; }
QStringList parameterNames() const;
QString rawParameters(bool names = false, bool values = false) const;
const FunctionNode* reimplementedFrom() const { return rf; }
const QList<FunctionNode*> &reimplementedBy() const { return rb; }
const PropertyNode* associatedProperty() const { return ap; }
const QStringList& parentPath() const { return pp; }
QStringList reconstructParams(bool values = false) const;
QString signature(bool values = false) const;
virtual QString element() const Q_DECL_OVERRIDE { return parent()->name(); }
virtual bool isAttached() const Q_DECL_OVERRIDE { return attached_; }
virtual bool isQmlNode() const Q_DECL_OVERRIDE {
return ((type() == QmlSignal) ||
(type() == QmlMethod) ||
(type() == QmlSignalHandler));
}
virtual bool isCppNode() const Q_DECL_OVERRIDE { return !isQmlNode(); }
virtual Node::Genus genus() const Q_DECL_OVERRIDE {
return (isQmlNode() ? Node::QML : Node::CPP);
}
virtual bool isQtQuickNode() const Q_DECL_OVERRIDE { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const Q_DECL_OVERRIDE { return parent()->qmlTypeName(); }
virtual QString logicalModuleName() const Q_DECL_OVERRIDE {
return parent()->logicalModuleName();
}
virtual QString logicalModuleVersion() const Q_DECL_OVERRIDE {
return parent()->logicalModuleVersion();
}
virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE {
return parent()->logicalModuleIdentifier();
}
void debug() const;
private:
void setAssociatedProperty(PropertyNode* property);
friend class InnerNode;
friend class PropertyNode;
QString rt;
QStringList pp;
Metaness met;
Virtualness vir;
bool con : 1;
bool sta : 1;
bool ove : 1;
bool reimp: 1;
bool attached_: 1;
QList<Parameter> params;
const FunctionNode* rf;
const PropertyNode* ap;
QList<FunctionNode*> rb;
};
class PropertyNode : public LeafNode
{
public:
enum FunctionRole { Getter, Setter, Resetter, Notifier };
enum { NumFunctionRoles = Notifier + 1 };
PropertyNode(InnerNode* parent, const QString& name);
virtual ~PropertyNode() { }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
virtual void setDataType(const QString& dataType) Q_DECL_OVERRIDE { type_ = dataType; }
void addFunction(FunctionNode* function, FunctionRole role);
void addSignal(FunctionNode* function, FunctionRole role);
void setStored(bool stored) { stored_ = toFlagValue(stored); }
void setDesignable(bool designable) { designable_ = toFlagValue(designable); }
void setScriptable(bool scriptable) { scriptable_ = toFlagValue(scriptable); }
void setWritable(bool writable) { writable_ = toFlagValue(writable); }
void setUser(bool user) { user_ = toFlagValue(user); }
void setOverriddenFrom(const PropertyNode* baseProperty);
void setRuntimeDesFunc(const QString& rdf) { runtimeDesFunc = rdf; }
void setRuntimeScrFunc(const QString& scrf) { runtimeScrFunc = scrf; }
void setConstant() { cst = true; }
void setFinal() { fnl = true; }
void setRevision(int revision) { rev = revision; }
const QString &dataType() const { return type_; }
QString qualifiedDataType() const;
NodeList functions() const;
NodeList functions(FunctionRole role) const { return funcs[(int)role]; }
NodeList getters() const { return functions(Getter); }
NodeList setters() const { return functions(Setter); }
NodeList resetters() const { return functions(Resetter); }
NodeList notifiers() const { return functions(Notifier); }
bool isStored() const { return fromFlagValue(stored_, storedDefault()); }
bool isDesignable() const { return fromFlagValue(designable_, designableDefault()); }
bool isScriptable() const { return fromFlagValue(scriptable_, scriptableDefault()); }
const QString& runtimeDesignabilityFunction() const { return runtimeDesFunc; }
const QString& runtimeScriptabilityFunction() const { return runtimeScrFunc; }
bool isWritable() const { return fromFlagValue(writable_, writableDefault()); }
bool isUser() const { return fromFlagValue(user_, userDefault()); }
bool isConstant() const { return cst; }
bool isFinal() const { return fnl; }
const PropertyNode* overriddenFrom() const { return overrides; }
bool storedDefault() const { return true; }
bool userDefault() const { return false; }
bool designableDefault() const { return !setters().isEmpty(); }
bool scriptableDefault() const { return true; }
bool writableDefault() const { return !setters().isEmpty(); }
private:
QString type_;
QString runtimeDesFunc;
QString runtimeScrFunc;
NodeList funcs[NumFunctionRoles];
FlagValue stored_;
FlagValue designable_;
FlagValue scriptable_;
FlagValue writable_;
FlagValue user_;
bool cst;
bool fnl;
int rev;
const PropertyNode* overrides;
};
inline void FunctionNode::setParameters(const QList<Parameter> ¶meters)
{
params = parameters;
}
inline void PropertyNode::addFunction(FunctionNode* function, FunctionRole role)
{
funcs[(int)role].append(function);
function->setAssociatedProperty(this);
}
inline void PropertyNode::addSignal(FunctionNode* function, FunctionRole role)
{
funcs[(int)role].append(function);
function->setAssociatedProperty(this);
}
inline NodeList PropertyNode::functions() const
{
NodeList list;
for (int i = 0; i < NumFunctionRoles; ++i)
list += funcs[i];
return list;
}
class VariableNode : public LeafNode
{
public:
VariableNode(InnerNode* parent, const QString &name);
virtual ~VariableNode() { }
virtual Node::Genus genus() const Q_DECL_OVERRIDE { return Node::CPP; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
void setLeftType(const QString &leftType) { lt = leftType; }
void setRightType(const QString &rightType) { rt = rightType; }
void setStatic(bool statique) { sta = statique; }
const QString &leftType() const { return lt; }
const QString &rightType() const { return rt; }
QString dataType() const { return lt + rt; }
bool isStatic() const { return sta; }
private:
QString lt;
QString rt;
bool sta;
};
inline VariableNode::VariableNode(InnerNode* parent, const QString &name)
: LeafNode(Variable, parent, name), sta(false)
{
// nothing.
}
class DitaMapNode : public DocNode
{
public:
DitaMapNode(InnerNode* parent, const QString& name)
: DocNode(parent, name, Node::Page, Node::DitaMapPage) { }
virtual ~DitaMapNode() { }
const DitaRefList& map() const { return doc().ditamap(); }
};
class CollectionNode : public InnerNode
{
public:
CollectionNode(Type type, InnerNode* parent, const QString& name)
: InnerNode(type, parent, name), seen_(false) {
setPageType(Node::OverviewPage);
}
virtual ~CollectionNode() { }
virtual bool isCollectionNode() const Q_DECL_OVERRIDE { return true; }
virtual void addMember(Node* node) Q_DECL_OVERRIDE;
virtual bool hasMembers() const Q_DECL_OVERRIDE;
virtual bool hasNamespaces() const Q_DECL_OVERRIDE;
virtual bool hasClasses() const Q_DECL_OVERRIDE;
virtual void getMemberNamespaces(NodeMap& out) Q_DECL_OVERRIDE;
virtual void getMemberClasses(NodeMap& out) Q_DECL_OVERRIDE;
virtual bool wasSeen() const Q_DECL_OVERRIDE { return seen_; }
virtual QString title() const Q_DECL_OVERRIDE { return title_; }
virtual QString subTitle() const Q_DECL_OVERRIDE { return subtitle_; }
virtual QString fullTitle() const Q_DECL_OVERRIDE { return title_; }
virtual QString nameForLists() const Q_DECL_OVERRIDE { return title_; }
virtual void setTitle(const QString &title) Q_DECL_OVERRIDE;
virtual void setSubTitle(const QString &subTitle) Q_DECL_OVERRIDE { subtitle_ = subTitle; }
const NodeList& members() const { return members_; }
void printMembers(const QString& title);
void markSeen() { seen_ = true; }
void markNotSeen() { seen_ = false; }
private:
bool seen_;
QString title_;
QString subtitle_;
NodeList members_;
};
class GroupNode : public CollectionNode
{
public:
GroupNode(InnerNode* parent, const QString& name)
: CollectionNode(Node::Group, parent, name) { }
virtual ~GroupNode() { }
virtual bool isGroup() const Q_DECL_OVERRIDE { return true; }
};
class ModuleNode : public CollectionNode
{
public:
ModuleNode(InnerNode* parent, const QString& name)
: CollectionNode(Node::Module, parent, name) { }
virtual ~ModuleNode() { }
virtual bool isModule() const Q_DECL_OVERRIDE { return true; }
virtual bool isCppNode() const Q_DECL_OVERRIDE { return true; }
virtual void setQtVariable(const QString& v) Q_DECL_OVERRIDE { qtVariable_ = v; }
virtual QString qtVariable() const Q_DECL_OVERRIDE { return qtVariable_; }
private:
QString qtVariable_;
};
class QmlModuleNode : public CollectionNode
{
public:
QmlModuleNode(InnerNode* parent, const QString& name)
: CollectionNode(Node::QmlModule, parent, name) { }
virtual ~QmlModuleNode() { }
virtual bool isQmlNode() const Q_DECL_OVERRIDE { return true; }
virtual bool isQmlModule() const Q_DECL_OVERRIDE { return true; }
virtual QString logicalModuleName() const Q_DECL_OVERRIDE { return logicalModuleName_; }
virtual QString logicalModuleVersion() const Q_DECL_OVERRIDE {
return logicalModuleVersionMajor_ + "." + logicalModuleVersionMinor_;
}
virtual QString logicalModuleIdentifier() const Q_DECL_OVERRIDE {
return logicalModuleName_ + logicalModuleVersionMajor_;
}
virtual void setQmlModuleInfo(const QString& ) Q_DECL_OVERRIDE;
virtual void setQtVariable(const QString& v) Q_DECL_OVERRIDE { qtVariable_ = v; }
virtual QString qtVariable() const Q_DECL_OVERRIDE { return qtVariable_; }
private:
QString logicalModuleName_;
QString logicalModuleVersionMajor_;
QString logicalModuleVersionMinor_;
QString qtVariable_;
};
QT_END_NAMESPACE
#endif
|