diff options
author | Martin Smith <[email protected]> | 2014-07-28 14:21:37 +0200 |
---|---|---|
committer | Martin Smith <[email protected]> | 2014-08-20 21:59:23 +0200 |
commit | a2c432e97818ec16ead9be0d0aee3e43cf10929e (patch) | |
tree | 200d7aab7de7bda12ae46303a131920d6fe325dd /src/tools/qdoc/node.cpp | |
parent | 0da4ddfcc59a639b014296a4544c8aff5d91f3f9 (diff) |
qdoc: Allow choice of linking to QML or CPP
This update enables using QML or CPP as the parameter
in square brackets for the \l command. You will use this
when, for example, there exist both a C++ class named
QWidget and a QML type named QWidget and your \l {QWidget}
links to the wrong one.
Suppose you write \l {QWidget} expecting it to link
to the QML type named QWidget, but it links to the C++
class named QWidget. Then write this instead:
\l [QML] {QWidget}
Or if you wrote \l {QWidget} expecting it to link to
the C++ class, but it links to the QML type, write this
instead:
\l [CPP] {QWidget}
A qdoc warning is printed if qdoc can not recognize the
parameter in square brackets.
There will be a further update to complete this task for
implementing the other type of parameter that can be in
the square brackets.
Task-number: QTBUG-39221
Change-Id: I5dd85478f968025ecbe337a8aabcc31d8b12a86d
Reviewed-by: Topi Reiniƶ <[email protected]>
Diffstat (limited to 'src/tools/qdoc/node.cpp')
-rw-r--r-- | src/tools/qdoc/node.cpp | 89 |
1 files changed, 71 insertions, 18 deletions
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 87a055ae0fb..fa91d67f1c4 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -46,6 +46,7 @@ #include <quuid.h> #include "qdocdatabase.h" #include <qdebug.h> +#include "generator.h" QT_BEGIN_NAMESPACE @@ -717,22 +718,38 @@ InnerNode::~InnerNode() } /*! - 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. + If \a genus is \c{Node::DontCare}, find the first node in + this node's child list that has the given \a name. If this + node is a QML type, be sure to also look in the children + of its property group nodes. Return the matching node or 0. + + If \a genus is either \c{Node::CPP} or \c {Node::QML}, then + find all this node's children that have the given \a name, + and return the one that satisfies the \a genus requirement. */ -Node *InnerNode::findChildNode(const QString& name) const +Node *InnerNode::findChildNode(const QString& name, Node::Genus genus) const { - Node *node = childMap.value(name); - if (node && !node->isQmlPropertyGroup()) - return node; - if (isQmlType()) { - for (int i=0; i<children_.size(); ++i) { - Node* n = children_.at(i); - if (n->isQmlPropertyGroup()) { - node = static_cast<InnerNode*>(n)->findChildNode(name); - if (node) + if (genus == Node::DontCare) { + Node *node = childMap.value(name); + if (node && !node->isQmlPropertyGroup()) // mws asks: Why not property group? + return node; + if (isQmlType()) { + for (int i=0; i<children_.size(); ++i) { + Node* n = children_.at(i); + if (n->isQmlPropertyGroup()) { + node = static_cast<InnerNode*>(n)->findChildNode(name, genus); + if (node) + return node; + } + } + } + } + else { + NodeList nodes = childMap.values(name); + if (!nodes.isEmpty()) { + for (int i=0; i<nodes.size(); ++i) { + Node* node = nodes.at(i); + if (genus == node->genus() || genus == Node::DontCare) return node; } } @@ -741,6 +758,39 @@ Node *InnerNode::findChildNode(const QString& name) const } /*! + Find all the child nodes of this node that are named + \a name and return them in \a nodes. + */ +void InnerNode::findChildren(const QString& name, NodeList& nodes) const +{ + nodes = childMap.values(name); + Node* n = primaryFunctionMap.value(name); + if (n) { + nodes.append(n); + NodeList t = secondaryFunctionMap.value(name); + if (!t.isEmpty()) + nodes.append(t); + } + if (!nodes.isEmpty() || !isQmlNode()) + return; + int i = name.indexOf(QChar('.')); + if (i < 0) + return; + QString qmlPropGroup = name.left(i); + NodeList t = childMap.values(qmlPropGroup); + if (t.isEmpty()) + return; + foreach (Node* n, t) { + if (n->isQmlPropertyGroup()) { + n->findChildren(name, nodes); + if (!nodes.isEmpty()) + break; + } + } +} + +#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 @@ -752,7 +802,7 @@ Node *InnerNode::findChildNode(const QString& name) const */ Node* InnerNode::findChildNode(const QString& name, bool qml) const { - QList<Node*> nodes = childMap.values(name); + NodeList nodes = childMap.values(name); if (!nodes.isEmpty()) { for (int i=0; i<nodes.size(); ++i) { Node* node = nodes.at(i); @@ -776,6 +826,7 @@ Node* InnerNode::findChildNode(const QString& name, bool qml) const } return primaryFunctionMap.value(name); } +#endif /*! This function is like findChildNode(), but if a node @@ -793,7 +844,7 @@ Node* InnerNode::findChildNode(const QString& name, Type type) if (type == Function) return primaryFunctionMap.value(name); else { - QList<Node*> nodes = childMap.values(name); + NodeList nodes = childMap.values(name); for (int i=0; i<nodes.size(); ++i) { Node* node = nodes.at(i); if (node->type() == type) @@ -803,13 +854,14 @@ Node* InnerNode::findChildNode(const QString& name, Type type) return 0; } +#if 0 /*! */ -void InnerNode::findNodes(const QString& name, QList<Node*>& n) +void InnerNode::findNodes(const QString& name, NodeList& n) { n.clear(); Node* node = 0; - QList<Node*> nodes = childMap.values(name); + 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 @@ -857,6 +909,7 @@ void InnerNode::findNodes(const QString& name, QList<Node*>& n) if (node) n.append(node); } +#endif /*! Find a function node that is a child of this nose, such |