Changeset 561 for trunk/tools/qdoc3/node.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/qdoc3/node.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the tools applications of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 */ 45 45 46 #include <QtCore> 46 47 #include "node.h" 47 48 … … 50 51 /*! 51 52 \class Node 52 \brief A node in a Tree. 53 */ 54 55 /*! 53 \brief The Node class is a node in the Tree. 54 55 A Node represents a class or function or something else 56 from the source code.. 57 */ 58 59 /*! 60 When this Node is destroyed, if it has a parent Node, it 61 removes itself from the parent node's child list. 56 62 */ 57 63 Node::~Node() … … 64 70 65 71 /*! 72 Sets this Node's Doc to \a doc. If \a replace is false and 73 this Node already has a Doc, a warning is reported that the 74 Doc is being overridden, and it reports where the previous 75 Doc was found. If \a replace is true, the Doc is replaced 76 silently. 66 77 */ 67 78 void Node::setDoc(const Doc& doc, bool replace) … … 114 125 115 126 /*! 127 This function creates a pair that describes a link. 128 The pair is composed from \a link and \a desc. The 129 \a linkType is the map index the pair is filed under. 116 130 */ 117 131 void Node::setLink(LinkType linkType, const QString &link, const QString &desc) … … 205 219 206 220 /*! 221 Find the function node in this node for the function named \a name. 207 222 */ 208 223 FunctionNode *InnerNode::findFunctionNode(const QString& name) … … 212 227 213 228 /*! 229 Find the function node in this node that has the same name as \a clone. 214 230 */ 215 231 FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) … … 232 248 } 233 249 return 0; 250 } 251 252 /*! 253 Returns the list of keys from the primary function map. 254 */ 255 QStringList InnerNode::primaryKeys() 256 { 257 QStringList t; 258 QMap<QString, Node*>::iterator i = primaryFunctionMap.begin(); 259 while (i != primaryFunctionMap.end()) { 260 t.append(i.key()); 261 ++i; 262 } 263 return t; 264 } 265 266 /*! 267 Returns the list of keys from the secondary function map. 268 */ 269 QStringList InnerNode::secondaryKeys() 270 { 271 QStringList t; 272 QMap<QString, NodeList>::iterator i = secondaryFunctionMap.begin(); 273 while (i != secondaryFunctionMap.end()) { 274 t.append(i.key()); 275 ++i; 276 } 277 return t; 234 278 } 235 279 … … 379 423 380 424 /*! 425 Find the function node in this node that has the given \a name. 381 426 */ 382 427 const FunctionNode *InnerNode::findFunctionNode(const QString& name) const … … 387 432 388 433 /*! 389 */390 const FunctionNode *InnerNode::findFunctionNode( 391 434 Find the function node in this node that has the same name as \a clone. 435 */ 436 const FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) const 392 437 { 393 438 InnerNode *that = (InnerNode *) this; … … 507 552 { 508 553 children.append(child); 509 if ( child->type() == Function) {554 if ((child->type() == Function) || (child->type() == QmlMethod)) { 510 555 FunctionNode *func = (FunctionNode *) child; 511 556 if (!primaryFunctionMap.contains(func->name())) { … … 624 669 625 670 /*! 626 Returns false because this is a n InnerNode.671 Returns false because this is a LeafNode. 627 672 */ 628 673 bool LeafNode::isInnerNode() const … … 714 759 715 760 /*! 716 */ 717 FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subType) 718 : InnerNode(Fake, parent, name), sub(subType) 719 { 720 } 721 722 /*! 761 The type of a FakeNode is Fake, and it has a \a subtype, 762 which specifies the type of FakeNode. 763 */ 764 FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subtype) 765 : InnerNode(Fake, parent, name), sub(subtype) 766 { 767 } 768 769 /*! 770 Returns the fake node's full title, which is usually 771 just title(), but for some SubType values is different 772 from title() 723 773 */ 724 774 QString FakeNode::fullTitle() const … … 730 780 return title(); 731 781 } 782 else if (sub == Image) { 783 if (title().isEmpty()) 784 return name().mid(name().lastIndexOf('/') + 1) + " Image File"; 785 else 786 return title(); 787 } 732 788 else if (sub == HeaderFile) { 733 789 if (title().isEmpty()) … … 742 798 743 799 /*! 800 Returns the subtitle. 744 801 */ 745 802 QString FakeNode::subTitle() const … … 748 805 return stle; 749 806 750 if ( sub == File) {807 if ((sub == File) || (sub == Image)) { 751 808 if (title().isEmpty() && name().contains("/")) 752 809 return name(); … … 818 875 /*! 819 876 \class Parameter 820 */ 821 822 /*! 877 \brief The class Parameter contains one parameter. 878 879 A parameter can be a function parameter or a macro 880 parameter. 881 */ 882 883 /*! 884 Constructs this parameter from the left and right types 885 \a leftType and rightType, the parameter \a name, and the 886 \a defaultValue. In practice, \a rightType is not used, 887 and I don't know what is was meant for. 823 888 */ 824 889 Parameter::Parameter(const QString& leftType, … … 831 896 832 897 /*! 898 The standard copy constructor copies the strings from \a p. 833 899 */ 834 900 Parameter::Parameter(const Parameter& p) … … 838 904 839 905 /*! 906 Assigning Parameter \a p to this Parameter copies the 907 strings across. 840 908 */ 841 909 Parameter& Parameter::operator=(const Parameter& p) … … 849 917 850 918 /*! 919 Reconstructs the text describing the parameter and 920 returns it. If \a value is true, the default value 921 will be included, if there is one. 922 */ 923 QString Parameter::reconstruct(bool value) const 924 { 925 QString p = lef + rig; 926 if (!p.endsWith(QChar('*')) && !p.endsWith(QChar('&')) && !p.endsWith(QChar(' '))) 927 p += " "; 928 p += nam; 929 if (value) 930 p += def; 931 return p; 932 } 933 934 935 /*! 851 936 \class FunctionNode 852 937 */ 853 938 854 939 /*! 940 Construct a function node for a C++ function. It's parent 941 is \a parent, and it's name is \a name. 855 942 */ 856 943 FunctionNode::FunctionNode(InnerNode *parent, const QString& name) 857 : LeafNode(Function, parent, name), met(Plain), vir(NonVirtual), 858 con(false), sta(false), ove(false), rf(0), ap(0) 859 { 944 : LeafNode(Function, parent, name), 945 met(Plain), 946 vir(NonVirtual), 947 con(false), 948 sta(false), 949 ove(false), 950 att(false), 951 rf(0), 952 ap(0) 953 { 954 // nothing. 955 } 956 957 /*! 958 Construct a function node for a QML method or signal, specified 959 by \a type. It's parent is \a parent, and it's name is \a name. 960 If \a attached is true, it is an attached method or signal. 961 */ 962 FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bool attached) 963 : LeafNode(type, parent, name), 964 met(Plain), 965 vir(NonVirtual), 966 con(false), 967 sta(false), 968 ove(false), 969 att(attached), 970 rf(0), 971 ap(0) 972 { 973 // nothing. 860 974 } 861 975 … … 866 980 parent()->setOverload(this, overlode); 867 981 ove = overlode; 982 } 983 984 /*! 985 Sets the function node's reimplementation flag to \a r. 986 When \a r is true, it is supposed to mean that this function 987 is a reimplementation of a virtual function in a base class, 988 but it really just means the \e reimp command was seen in the 989 qdoc comment. 990 */ 991 void FunctionNode::setReimp(bool r) 992 { 993 reimp = r; 868 994 } 869 995 … … 890 1016 891 1017 /*! 1018 If this function is a reimplementation, \a from points 1019 to the FunctionNode of the function being reimplemented. 892 1020 */ 893 1021 void FunctionNode::setReimplementedFrom(FunctionNode *from) … … 898 1026 899 1027 /*! 1028 Sets the "associated" property to \a property. The function 1029 might be the setter or getter for a property, for example. 900 1030 */ 901 1031 void FunctionNode::setAssociatedProperty(PropertyNode *property) … … 905 1035 906 1036 /*! 1037 Returns the overload number for this function obtained 1038 from the parent. 907 1039 */ 908 1040 int FunctionNode::overloadNumber() const … … 912 1044 913 1045 /*! 1046 Returns the number of times this function name has been 1047 overloaded, obtained from the parent. 914 1048 */ 915 1049 int FunctionNode::numOverloads() const … … 919 1053 920 1054 /*! 1055 Returns the list of parameter names. 921 1056 */ 922 1057 QStringList FunctionNode::parameterNames() const … … 929 1064 } 930 1065 return names; 1066 } 1067 1068 /*! 1069 Returns the list of reconstructed parameters. If \a values 1070 is true, the default values are included, if any are present. 1071 */ 1072 QStringList FunctionNode::reconstructParams(bool values) const 1073 { 1074 QStringList params; 1075 QList<Parameter>::ConstIterator p = parameters().begin(); 1076 while (p != parameters().end()) { 1077 params << (*p).reconstruct(values); 1078 ++p; 1079 } 1080 return params; 1081 } 1082 1083 /*! 1084 Reconstructs and returns the function's signature. If \a values 1085 is true, the default values of the parameters are included, if 1086 present. 1087 */ 1088 QString FunctionNode::signature(bool values) const 1089 { 1090 QString s; 1091 if (!returnType().isEmpty()) 1092 s = returnType() + " "; 1093 s += name() + "("; 1094 QStringList params = reconstructParams(values); 1095 int p = params.size(); 1096 if (p > 0) { 1097 for (int i=0; i<p; i++) { 1098 s += params[i]; 1099 if (i < (p-1)) 1100 s += ", "; 1101 } 1102 } 1103 s += ")"; 1104 return s; 1105 } 1106 1107 /*! 1108 Print some debugging stuff. 1109 */ 1110 void FunctionNode::debug() const 1111 { 1112 qDebug() << "QML METHOD" << name() << "rt" << rt << "pp" << pp; 931 1113 } 932 1114 … … 1022 1204 } 1023 1205 1206 #ifdef QDOC_QML 1207 bool QmlClassNode::qmlOnly = false; 1208 1209 /*! 1210 Constructor for the Qml class node. 1211 */ 1212 QmlClassNode::QmlClassNode(InnerNode *parent, 1213 const QString& name, 1214 const ClassNode* cn) 1215 : FakeNode(parent, name, QmlClass), cnode(cn) 1216 { 1217 setTitle((qmlOnly ? "" : "QML ") + name + " Element Reference"); 1218 } 1219 1220 /*! 1221 The base file name for this kind of node has "qml_" 1222 prepended to it. 1223 1224 But not yet. Still testing. 1225 */ 1226 QString QmlClassNode::fileBase() const 1227 { 1228 #if 0 1229 if (Node::fileBase() == "item") 1230 qDebug() << "FILEBASE: qmlitem" << name(); 1231 return "qml_" + Node::fileBase(); 1232 #endif 1233 return Node::fileBase(); 1234 } 1235 1236 /*! 1237 Constructor for the Qml property group node. \a parent is 1238 always a QmlClassNode. 1239 */ 1240 QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent, 1241 const QString& name, 1242 bool attached) 1243 : FakeNode(parent, name, QmlPropertyGroup), 1244 isdefault(false), 1245 att(attached) 1246 { 1247 // nothing. 1248 } 1249 1250 /*! 1251 Constructor for the QML property node. 1252 */ 1253 QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent, 1254 const QString& name, 1255 const QString& type, 1256 bool attached) 1257 : LeafNode(QmlProperty, parent, name), 1258 dt(type), 1259 sto(Trool_Default), 1260 des(Trool_Default), 1261 att(attached) 1262 { 1263 // nothing. 1264 } 1265 1266 /*! 1267 I don't know what this is. 1268 */ 1269 QmlPropertyNode::Trool QmlPropertyNode::toTrool(bool boolean) 1270 { 1271 return boolean ? Trool_True : Trool_False; 1272 } 1273 1274 /*! 1275 I don't know what this is either. 1276 */ 1277 bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue) 1278 { 1279 switch (troolean) { 1280 case Trool_True: 1281 return true; 1282 case Trool_False: 1283 return false; 1284 default: 1285 return defaultValue; 1286 } 1287 } 1288 #endif 1289 1024 1290 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.