diff options
Diffstat (limited to 'src/tools/qdoc/node.cpp')
-rw-r--r-- | src/tools/qdoc/node.cpp | 258 |
1 files changed, 106 insertions, 152 deletions
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 1ade3e2aca7..f65b4ec942b 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -149,7 +149,7 @@ QString Node::plainFullName(const Node* relative) const */ QString Node::fullName(const Node* relative) const { - if (isDocNode()) + if (isDocumentNode()) return title(); else if (isClass()) { const ClassNode* cn = static_cast<const ClassNode*>(this); @@ -624,17 +624,18 @@ QString Node::guid() const } /*! - If this node is a QML class node, return a pointer to it. - If it is a child of a QML class node, return a pointer to - the QML class node. Otherwise, return 0; + If this node is a QML or JS type node, return a pointer to + it. If it is a child of a QML or JS type node, return the + pointer to its parent QMLor JS type node. Otherwise return + 0; */ QmlTypeNode* Node::qmlTypeNode() { - if (isQmlNode()) { + if (isQmlNode() || isJsNode()) { Node* n = this; - while (n && !n->isQmlType()) + while (n && !(n->isQmlType() || n->isJsType())) n = n->parent(); - if (n && n->isQmlType()) + if (n && (n->isQmlType() || n->isJsType())) return static_cast<QmlTypeNode*>(n); } return 0; @@ -716,10 +717,10 @@ Node *InnerNode::findChildNode(const QString& name, Node::Genus genus) const Node *node = childMap.value(name); if (node && !node->isQmlPropertyGroup()) // mws asks: Why not property group? return node; - if (isQmlType()) { + if (isQmlType() || isJsType()) { for (int i=0; i<children_.size(); ++i) { Node* n = children_.at(i); - if (n->isQmlPropertyGroup()) { + if (n->isQmlPropertyGroup() || isJsPropertyGroup()) { node = static_cast<InnerNode*>(n)->findChildNode(name, genus); if (node) return node; @@ -754,7 +755,7 @@ void InnerNode::findChildren(const QString& name, NodeList& nodes) const if (!t.isEmpty()) nodes.append(t); } - if (!nodes.isEmpty() || !isQmlNode()) + if (!nodes.isEmpty() || !(isQmlNode() || isJsNode())) return; int i = name.indexOf(QChar('.')); if (i < 0) @@ -764,7 +765,7 @@ void InnerNode::findChildren(const QString& name, NodeList& nodes) const if (t.isEmpty()) return; foreach (Node* n, t) { - if (n->isQmlPropertyGroup()) { + if (n->isQmlPropertyGroup() || n->isJsPropertyGroup()) { n->findChildren(name, nodes); if (!nodes.isEmpty()) break; @@ -772,45 +773,6 @@ void InnerNode::findChildren(const QString& name, NodeList& nodes) const } } -#if 0 -/*! - Find the node in this node's children that has the given \a name. If - this node is a QML class node, be sure to also look in the children - of its property group nodes. Return the matching node or 0. This is - not a recearsive search. - - If \a qml is true, only match a node for which node->isQmlNode() - returns \c true. If \a qml is false, only match a node for which - node->isQmlNode() returns \c false. - */ -Node* InnerNode::findChildNode(const QString& name, bool qml) const -{ - NodeList nodes = childMap.values(name); - if (!nodes.isEmpty()) { - for (int i=0; i<nodes.size(); ++i) { - Node* node = nodes.at(i); - if (!qml) { - if (!node->isQmlNode()) - return node; - } - else if (node->isQmlNode()) - return node; - } - } - if (qml && isQmlType()) { - for (int i=0; i<children_.size(); ++i) { - Node* node = children_.at(i); - if (node->isQmlPropertyGroup()) { - node = static_cast<InnerNode*>(node)->findChildNode(name); - if (node) - return node; - } - } - } - return primaryFunctionMap.value(name); -} -#endif - /*! This function is like findChildNode(), but if a node with the specified \a name is found but it is not of the @@ -831,63 +793,6 @@ Node* InnerNode::findChildNode(const QString& name, Type type) return 0; } -#if 0 -/*! - */ -void InnerNode::findNodes(const QString& name, NodeList& n) -{ - n.clear(); - Node* node = 0; - NodeList nodes = childMap.values(name); - /* - <sigh> If this node's child map contains no nodes named - name, then if this node is a QML class, search each of its - property group nodes for a node named name. If a match is - found, append it to the output list and return immediately. - */ - if (nodes.isEmpty()) { - if (isQmlType()) { - for (int i=0; i<children_.size(); ++i) { - node = children_.at(i); - if (node->isQmlPropertyGroup()) { - node = static_cast<InnerNode*>(node)->findChildNode(name); - if (node) { - n.append(node); - return; - } - } - } - } - } - else { - /* - If the childMap does contain one or more nodes named - name, traverse the list of matching nodes. Append each - matching node that is not a property group node to the - output list. Search each property group node for a node - named name and append that node to the output list. - This is overkill, I think, but should produce a useful - list. - */ - for (int i=0; i<nodes.size(); ++i) { - node = nodes.at(i); - if (!node->isQmlPropertyGroup()) - n.append(node); - else { - node = static_cast<InnerNode*>(node)->findChildNode(name); - if (node) - n.append(node); - } - } - } - if (!n.isEmpty()) - return; - node = primaryFunctionMap.value(name); - if (node) - n.append(node); -} -#endif - /*! Find a function node that is a child of this nose, such that the function node has the specified \a name. @@ -1642,15 +1547,15 @@ QmlTypeNode* ClassNode::findQmlBaseNode() } /*! - \class DocNode + \class DocumentNode */ /*! - The type of a DocNode is Document, and it has a \a subtype, - which specifies the type of DocNode. The page type for + The type of a DocumentNode is Document, and it has a \a subtype, + which specifies the type of DocumentNode. The page type for the page index is set here. */ -DocNode::DocNode(InnerNode* parent, const QString& name, SubType subtype, Node::PageType ptype) +DocumentNode::DocumentNode(InnerNode* parent, const QString& name, SubType subtype, Node::PageType ptype) : InnerNode(Document, parent, name), nodeSubtype_(subtype) { setGenus(Node::DOC); @@ -1669,14 +1574,14 @@ DocNode::DocNode(InnerNode* parent, const QString& name, SubType subtype, Node:: } } -/*! \fn QString DocNode::title() const +/*! \fn QString DocumentNode::title() const Returns the document node's title. This is used for the page title. */ /*! Sets the document node's \a title. This is used for the page title. */ -void DocNode::setTitle(const QString &title) +void DocumentNode::setTitle(const QString &title) { title_ = title; parent()->addChild(this, title); @@ -1687,7 +1592,7 @@ void DocNode::setTitle(const QString &title) just title(), but for some SubType values is different from title() */ -QString DocNode::fullTitle() const +QString DocumentNode::fullTitle() const { if (nodeSubtype_ == File) { if (title().isEmpty()) @@ -1715,7 +1620,7 @@ QString DocNode::fullTitle() const /*! Returns the subtitle. */ -QString DocNode::subTitle() const +QString DocumentNode::subTitle() const { if (!subtitle_.isEmpty()) return subtitle_; @@ -2205,29 +2110,6 @@ void QmlTypeNode::subclasses(const QString& base, NodeList& subs) } } -/*! - This function splits \a arg on the blank character to get a - QML module name and version number. If the version number is - present, it spilts the version number on the '.' character to - get a major version number and a minor vrsion number. If the - version number is present, both the major and minor version - numbers should be there, but the minor version number is not - absolutely necessary. - */ -void QmlModuleNode::setQmlModuleInfo(const QString& arg) -{ - QStringList blankSplit = arg.split(QLatin1Char(' ')); - logicalModuleName_ = blankSplit[0]; - if (blankSplit.size() > 1) { - QStringList dotSplit = blankSplit[1].split(QLatin1Char('.')); - logicalModuleVersionMajor_ = dotSplit[0]; - if (dotSplit.size() > 1) - logicalModuleVersionMinor_ = dotSplit[1]; - else - logicalModuleVersionMinor_ = "0"; - } -} - QmlTypeNode* QmlTypeNode::qmlBaseNode() { if (!qmlBaseNode_ && !qmlBaseName_.isEmpty()) { @@ -2389,7 +2271,7 @@ PropertyNode* QmlPropertyNode::findCorrespondingCppProperty() { PropertyNode* pn; Node* n = parent(); - while (n && !n->isQmlType()) + while (n && !(n->isQmlType() || n->isJsType())) n = n->parent(); if (n) { QmlTypeNode* qcn = static_cast<QmlTypeNode*>(n); @@ -2454,12 +2336,12 @@ QString Node::fullDocumentName() const if (!n->name().isEmpty() && !n->isQmlPropertyGroup()) pieces.insert(0, n->name()); - if (n->isQmlType() && !n->logicalModuleName().isEmpty()) { + if ((n->isQmlType() || n->isJsType()) && !n->logicalModuleName().isEmpty()) { pieces.insert(0, n->logicalModuleName()); break; } - if (n->isDocNode()) + if (n->isDocumentNode()) break; // Examine the parent node if one exists. @@ -2471,10 +2353,10 @@ QString Node::fullDocumentName() const // Create a name based on the type of the ancestor node. QString concatenator = "::"; - if (n->isQmlType()) + if (n->isQmlType() || n->isJsType()) concatenator = QLatin1Char('.'); - if (n->isDocNode()) + if (n->isDocumentNode()) concatenator = QLatin1Char('#'); return pieces.join(concatenator); @@ -2655,6 +2537,8 @@ QString Node::idForNode() const str = "namespace-member-" + func->name(); else if (parent_->isQmlType()) str = "qml-method-" + parent_->name().toLower() + "-" + func->name(); + else if (parent_->isJsType()) + str = "js-method-" + parent_->name().toLower() + "-" + func->name(); else if (parent_->type() == Document) { qDebug() << "qdoc internal error: Node subtype not handled:" << parent_->subType() << func->name(); @@ -2669,10 +2553,16 @@ QString Node::idForNode() const } break; case Node::QmlType: - str = "qml-class-" + name(); + if (genus() == QML) + str = "qml-class-" + name(); + else + str = "js-type-" + name(); break; case Node::QmlBasicType: - str = "qml-basic-type-" + name(); + if (genus() == QML) + str = "qml-basic-type-" + name(); + else + str = "js-basic-type-" + name(); break; case Node::Document: { @@ -2713,32 +2603,52 @@ QString Node::idForNode() const str.replace(QLatin1Char('/'), QLatin1Char('-')); break; case Node::QmlModule: - str = "qml-module-" + name(); + if (genus() == QML) + str = "qml-module-" + name(); + else + str = "js-module-" + name(); break; case Node::QmlProperty: + if (genus() == QML) + str = "qml-"; + else + str = "js-"; if (isAttached()) - str = "qml-attached-property-" + name(); + str += "attached-property-" + name(); else - str = "qml-property-" + name(); + str += "property-" + name(); break; case Node::QmlPropertyGroup: { Node* n = const_cast<Node*>(this); - str = "qml-propertygroup-" + n->name(); + if (genus() == QML) + str = "qml-propertygroup-" + n->name(); + else + str = "js-propertygroup-" + n->name(); } break; case Node::Property: str = "property-" + name(); break; case Node::QmlSignal: - str = "qml-signal-" + name(); + if (genus() == QML) + str = "qml-signal-" + name(); + else + str = "js-signal-" + name(); break; case Node::QmlSignalHandler: - str = "qml-signal-handler-" + name(); + if (genus() == QML) + str = "qml-signal-handler-" + name(); + else + str = "js-signal-handler-" + name(); break; case Node::QmlMethod: func = static_cast<const FunctionNode*>(this); - str = "qml-method-" + parent_->name().toLower() + "-" + func->name(); + if (genus() == QML) + str = "qml-method-"; + else + str = "js-method-"; + str += parent_->name().toLower() + "-" + func->name(); if (func->overloadNumber() != 1) str += QLatin1Char('-') + QString::number(func->overloadNumber()); break; @@ -2884,4 +2794,48 @@ void CollectionNode::setTitle(const QString& title) parent()->addChild(this, title); } +/*! + This function splits \a arg on the blank character to get a + logical module name and version number. If the version number + is present, it spilts the version number on the '.' character + to get a major version number and a minor vrsion number. If + the version number is present, both the major and minor version + numbers should be there, but the minor version number is not + absolutely necessary. + */ +void CollectionNode::setLogicalModuleInfo(const QString& arg) +{ + QStringList blankSplit = arg.split(QLatin1Char(' ')); + logicalModuleName_ = blankSplit[0]; + if (blankSplit.size() > 1) { + QStringList dotSplit = blankSplit[1].split(QLatin1Char('.')); + logicalModuleVersionMajor_ = dotSplit[0]; + if (dotSplit.size() > 1) + logicalModuleVersionMinor_ = dotSplit[1]; + else + logicalModuleVersionMinor_ = "0"; + } +} + +/*! + This function accepts the logical module \a info as a string + list. If the logical module info contains the version number, + it spilts the version number on the '.' character to get the + major and minor vrsion numbers. Both major and minor version + numbers should be provided, but the minor version number is + not strictly necessary. + */ +void CollectionNode::setLogicalModuleInfo(const QStringList& info) +{ + logicalModuleName_ = info[0]; + if (info.size() > 1) { + QStringList dotSplit = info[1].split(QLatin1Char('.')); + logicalModuleVersionMajor_ = dotSplit[0]; + if (dotSplit.size() > 1) + logicalModuleVersionMinor_ = dotSplit[1]; + else + logicalModuleVersionMinor_ = "0"; + } +} + QT_END_NAMESPACE |