tools/qdoc3/node.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   216         }
   216         }
   217     }
   217     }
   218 }
   218 }
   219 
   219 
   220 /*!
   220 /*!
       
   221   Find the function node in this node for the function named \a name.
   221  */
   222  */
   222 FunctionNode *InnerNode::findFunctionNode(const QString& name)
   223 FunctionNode *InnerNode::findFunctionNode(const QString& name)
   223 {
   224 {
   224     return static_cast<FunctionNode *>(primaryFunctionMap.value(name));
   225     return static_cast<FunctionNode *>(primaryFunctionMap.value(name));
   225 }
   226 }
   226 
   227 
   227 /*!
   228 /*!
       
   229   Find the function node in this node that has the same name as \a clone.
   228  */
   230  */
   229 FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone)
   231 FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone)
   230 {
   232 {
   231     QMap<QString, Node *>::ConstIterator c =
   233     QMap<QString, Node *>::ConstIterator c =
   232 	    primaryFunctionMap.find(clone->name());
   234 	    primaryFunctionMap.find(clone->name());
   243 		++s;
   245 		++s;
   244 	    }
   246 	    }
   245 	}
   247 	}
   246     }
   248     }
   247     return 0;
   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;
   248 }
   278 }
   249 
   279 
   250 /*!
   280 /*!
   251  */
   281  */
   252 void InnerNode::setOverload(const FunctionNode *func, bool overlode)
   282 void InnerNode::setOverload(const FunctionNode *func, bool overlode)
   390     InnerNode *that = (InnerNode *) this;
   420     InnerNode *that = (InnerNode *) this;
   391     return that->findNode(name, type);
   421     return that->findNode(name, type);
   392 }
   422 }
   393 
   423 
   394 /*!
   424 /*!
       
   425   Find the function node in this node that has the given \a name. 
   395  */
   426  */
   396 const FunctionNode *InnerNode::findFunctionNode(const QString& name) const
   427 const FunctionNode *InnerNode::findFunctionNode(const QString& name) const
   397 {
   428 {
   398     InnerNode *that = (InnerNode *) this;
   429     InnerNode *that = (InnerNode *) this;
   399     return that->findFunctionNode(name);
   430     return that->findFunctionNode(name);
   400 }
   431 }
   401 
   432 
   402 /*!
   433 /*!
   403  */
   434   Find the function node in this node that has the same name as \a clone.
   404 const FunctionNode *InnerNode::findFunctionNode(
   435  */
   405 	const FunctionNode *clone) const
   436 const FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) const
   406 {
   437 {
   407     InnerNode *that = (InnerNode *) this;
   438     InnerNode *that = (InnerNode *) this;
   408     return that->findFunctionNode(clone);
   439     return that->findFunctionNode(clone);
   409 }
   440 }
   410 
   441 
   518 /*!
   549 /*!
   519  */
   550  */
   520 void InnerNode::addChild(Node *child)
   551 void InnerNode::addChild(Node *child)
   521 {
   552 {
   522     children.append(child);
   553     children.append(child);
   523     if (child->type() == Function) {
   554     if ((child->type() == Function) || (child->type() == QmlMethod)) {
   524         FunctionNode *func = (FunctionNode *) child;
   555         FunctionNode *func = (FunctionNode *) child;
   525         if (!primaryFunctionMap.contains(func->name())) {
   556         if (!primaryFunctionMap.contains(func->name())) {
   526             primaryFunctionMap.insert(func->name(), func);
   557             primaryFunctionMap.insert(func->name(), func);
   527 	}
   558 	}
   528         else {
   559         else {
   734     : InnerNode(Fake, parent, name), sub(subtype)
   765     : InnerNode(Fake, parent, name), sub(subtype)
   735 {
   766 {
   736 }
   767 }
   737 
   768 
   738 /*!
   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()
   739  */
   773  */
   740 QString FakeNode::fullTitle() const
   774 QString FakeNode::fullTitle() const
   741 {
   775 {
   742     if (sub == File) {
   776     if (sub == File) {
   743         if (title().isEmpty())
   777         if (title().isEmpty())
   744             return name().mid(name().lastIndexOf('/') + 1) + " Example File";
   778             return name().mid(name().lastIndexOf('/') + 1) + " Example File";
   745         else
   779         else
   746             return title();
   780             return title();
   747     }
   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     }
   748     else if (sub == HeaderFile) {
   788     else if (sub == HeaderFile) {
   749         if (title().isEmpty())
   789         if (title().isEmpty())
   750             return name();
   790             return name();
   751         else
   791         else
   752             return name() + " - " + title();
   792             return name() + " - " + title();
   755         return title();
   795         return title();
   756     }
   796     }
   757 }
   797 }
   758 
   798 
   759 /*!
   799 /*!
       
   800   Returns the subtitle.
   760  */
   801  */
   761 QString FakeNode::subTitle() const
   802 QString FakeNode::subTitle() const
   762 {
   803 {
   763     if (!stle.isEmpty())
   804     if (!stle.isEmpty())
   764         return stle;
   805         return stle;
   765 
   806 
   766     if (sub == File) {
   807     if ((sub == File) || (sub == Image)) {
   767         if (title().isEmpty() && name().contains("/"))
   808         if (title().isEmpty() && name().contains("/"))
   768             return name();
   809             return name();
   769     }
   810     }
   770     return QString();
   811     return QString();
   771 }
   812 }
   894 /*!
   935 /*!
   895   \class FunctionNode
   936   \class FunctionNode
   896  */
   937  */
   897 
   938 
   898 /*!
   939 /*!
       
   940   Construct a function node for a C++ function. It's parent
       
   941   is \a parent, and it's name is \a name.
   899  */
   942  */
   900 FunctionNode::FunctionNode(InnerNode *parent, const QString& name)
   943 FunctionNode::FunctionNode(InnerNode *parent, const QString& name)
   901     : LeafNode(Function, parent, name), met(Plain), vir(NonVirtual),
   944     : LeafNode(Function, parent, name),
   902       con(false), sta(false), ove(false), rf(0), ap(0)
   945       met(Plain),
   903 {
   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.
   904 }
   974 }
   905 
   975 
   906 /*!
   976 /*!
   907  */
   977  */
   908 void FunctionNode::setOverload(bool overlode)
   978 void FunctionNode::setOverload(bool overlode)
  1032     }
  1102     }
  1033     s += ")";
  1103     s += ")";
  1034     return s;
  1104     return s;
  1035 }
  1105 }
  1036 
  1106 
       
  1107 /*!
       
  1108   Print some debugging stuff.
       
  1109  */
       
  1110 void FunctionNode::debug() const
       
  1111 {
       
  1112     qDebug() << "QML METHOD" << name() << "rt" << rt << "pp" << pp;
       
  1113 }
  1037 
  1114 
  1038 /*!
  1115 /*!
  1039   \class PropertyNode
  1116   \class PropertyNode
  1040  */
  1117  */
  1041 
  1118 
  1125 {
  1202 {
  1126     return false;
  1203     return false;
  1127 }
  1204 }
  1128 
  1205 
  1129 #ifdef QDOC_QML
  1206 #ifdef QDOC_QML
       
  1207 bool QmlClassNode::qmlOnly = false;
       
  1208 
  1130 /*!
  1209 /*!
  1131   Constructor for the Qml class node.
  1210   Constructor for the Qml class node.
  1132  */
  1211  */
  1133 QmlClassNode::QmlClassNode(InnerNode *parent,
  1212 QmlClassNode::QmlClassNode(InnerNode *parent,
  1134                            const QString& name,
  1213                            const QString& name,
  1135                            const ClassNode* cn)
  1214                            const ClassNode* cn)
  1136     : FakeNode(parent, name, QmlClass), cnode(cn)
  1215     : FakeNode(parent, name, QmlClass), cnode(cn)
  1137 {
  1216 {
  1138     setTitle("QML " + name + " Element Reference");
  1217     setTitle((qmlOnly ? "" : "QML ") + name + " Element Reference");
  1139 }
  1218 }
  1140 
  1219 
  1141 /*!
  1220 /*!
  1142   The base file name for this kind of node has "qml_"
  1221   The base file name for this kind of node has "qml_"
  1143   prepended to it.
  1222   prepended to it.
  1204         return false;
  1283         return false;
  1205     default:
  1284     default:
  1206         return defaultValue;
  1285         return defaultValue;
  1207     }
  1286     }
  1208 }
  1287 }
  1209 
       
  1210 /*!
       
  1211   Constructor for the QML signal node.
       
  1212  */
       
  1213 QmlSignalNode::QmlSignalNode(QmlClassNode *parent, const QString& name)
       
  1214     : LeafNode(QmlSignal, parent, name)
       
  1215 {
       
  1216     // nothing.
       
  1217 }
       
  1218 
       
  1219 /*!
       
  1220   Constructor for the QML method node.
       
  1221  */
       
  1222 QmlMethodNode::QmlMethodNode(QmlClassNode *parent, const QString& name)
       
  1223     : LeafNode(QmlMethod, parent, name)
       
  1224 {
       
  1225     // nothing.
       
  1226 }
       
  1227 #endif
  1288 #endif
  1228 
  1289 
  1229 QT_END_NAMESPACE
  1290 QT_END_NAMESPACE