summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-11-08 17:04:39 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-11-08 17:04:39 (GMT)
commit8127f10569092cf87298d961aea0bf50c9c59bd6 (patch)
treecbad6552b85bdc7473fd1b3944ead78405bdee78 /tools/qdoc3
parent27e77b7ceeeffe9227b5b96fdd63e3433e0eb63e (diff)
downloadQt-8127f10569092cf87298d961aea0bf50c9c59bd6.zip
Qt-8127f10569092cf87298d961aea0bf50c9c59bd6.tar.gz
Qt-8127f10569092cf87298d961aea0bf50c9c59bd6.tar.bz2
Ensured that the document nodes are sorted in the generated index.
Task-number: QTBUG-13828
Diffstat (limited to 'tools/qdoc3')
-rw-r--r--tools/qdoc3/tree.cpp71
1 files changed, 69 insertions, 2 deletions
diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp
index 540ffa9..d1e2c60 100644
--- a/tools/qdoc3/tree.cpp
+++ b/tools/qdoc3/tree.cpp
@@ -1543,8 +1543,72 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer,
return true;
}
+
/*!
- */
+ Returns true if the node \a n1 is less than node \a n2.
+ The comparison is performed by comparing properties of the nodes in order
+ of increasing complexity.
+*/
+bool compareNodes(const Node *n1, const Node *n2)
+{
+ // Private nodes can occur in any order since they won't normally be
+ // written to the index.
+ if (n1->access() == Node::Private && n2->access() == Node::Private)
+ return true;
+
+ if (n1->location().filePath() < n2->location().filePath())
+ return true;
+ else if (n1->location().filePath() > n2->location().filePath())
+ return false;
+
+ if (n1->type() < n2->type())
+ return true;
+ else if (n1->type() > n2->type())
+ return false;
+
+ if (n1->name() < n2->name())
+ return true;
+ else if (n1->name() > n2->name())
+ return false;
+
+ if (n1->access() < n2->access())
+ return true;
+ else if (n1->access() > n2->access())
+ return false;
+
+ if (n1->type() == Node::Function && n2->type() == Node::Function) {
+ const FunctionNode *f1 = static_cast<const FunctionNode *>(n1);
+ const FunctionNode *f2 = static_cast<const FunctionNode *>(n2);
+
+ if (f1->isConst() < f2->isConst())
+ return true;
+ else if (f1->isConst() > f2->isConst())
+ return false;
+
+ if (f1->signature() < f2->signature())
+ return true;
+ else if (f1->signature() > f2->signature())
+ return false;
+ }
+
+ if (n1->type() == Node::Fake && n2->type() == Node::Fake) {
+ const FakeNode *f1 = static_cast<const FakeNode *>(n1);
+ const FakeNode *f2 = static_cast<const FakeNode *>(n2);
+ if (f1->fullTitle() < f2->fullTitle())
+ return true;
+ else if (f1->fullTitle() > f2->fullTitle())
+ return false;
+ }
+
+ return false;
+}
+
+/*!
+ Generate index sections for the child nodes of the given \a node
+ using the \a writer specified. If \a generateInternalNodes is true,
+ nodes marked as internal will be included in the index; otherwise,
+ they will be omitted.
+*/
void Tree::generateIndexSections(QXmlStreamWriter &writer,
const Node *node,
bool generateInternalNodes) const
@@ -1554,7 +1618,10 @@ void Tree::generateIndexSections(QXmlStreamWriter &writer,
if (node->isInnerNode()) {
const InnerNode *inner = static_cast<const InnerNode *>(node);
- foreach (const Node *child, inner->childNodes()) {
+ NodeList cnodes = inner->childNodes();
+ qSort(cnodes.begin(), cnodes.end(), compareNodes);
+
+ foreach (const Node *child, cnodes) {
/*
Don't generate anything for a QML property group node.
It is just a place holder for a collection of QML property