summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2019-12-02 13:53:03 +0100
committerTopi Reinio <topi.reinio@qt.io>2019-12-03 12:53:57 +0100
commit8f2673ad587c47d52b203f71927808a686405710 (patch)
tree42b63c3031bfd768f816c74181b56b50884b05c0
parent286927b27c2df066a590bd8f442ad0439fd9133f (diff)
downloadqttools-8f2673ad587c47d52b203f71927808a686405710.tar.gz
qdoc: Restore alphabetical ordering of generated type lists
The comparison function used for sorting compares fullTitle() strings for PageNode items. When the class hierarchy was refactored, this had the unintended effect where this comparison was applied to lists of C++ and QML types as well - the full title is empty for these, so we ended up comparing the physical location of the type declarations instead. Fix this by preferring the fullName() over fullTitle() when comparing, as the former is what the visible list item names are generated from. Make the comparison function easier to read and maintain by introducing a preprocessor macro. Fixes: QTBUG-80259 Change-Id: I3f35aa80f1a90a6817f836146976d73b857df820 Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/node.cpp58
1 files changed, 13 insertions, 45 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index 839dd1336..bba1bd582 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -158,49 +158,27 @@ bool Node::changeType(NodeType from, NodeType to)
*/
bool Node::nodeNameLessThan(const Node *n1, const Node *n2)
{
+#define LT_RETURN_IF_NOT_EQUAL(a, b) \
+ if ((a) != (b)) \
+ return (a) < (b);
+
if (n1->isPageNode() && n2->isPageNode()) {
- const PageNode *f1 = static_cast<const PageNode *>(n1);
- const PageNode *f2 = static_cast<const PageNode *>(n2);
- if (f1->fullTitle() < f2->fullTitle())
- return true;
- else if (f1->fullTitle() > f2->fullTitle())
- return false;
+ LT_RETURN_IF_NOT_EQUAL(n1->fullName(), n2->fullName());
+ LT_RETURN_IF_NOT_EQUAL(n1->fullTitle(), n2->fullTitle());
}
if (n1->isFunction() && n2->isFunction()) {
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(false, false) < f2->signature(false, false))
- return true;
- else if (f1->signature(false, false) > f2->signature(false, false))
- return false;
+ LT_RETURN_IF_NOT_EQUAL(f1->isConst(), f2->isConst());
+ LT_RETURN_IF_NOT_EQUAL(f1->signature(false, false), f2->signature(false, false));
}
- if (n1->location().filePath() < n2->location().filePath())
- return true;
- else if (n1->location().filePath() > n2->location().filePath())
- return false;
-
- if (n1->nodeType() < n2->nodeType())
- return true;
- else if (n1->nodeType() > n2->nodeType())
- 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;
+ LT_RETURN_IF_NOT_EQUAL(n1->location().filePath(), n2->location().filePath());
+ LT_RETURN_IF_NOT_EQUAL(n1->nodeType(), n2->nodeType());
+ LT_RETURN_IF_NOT_EQUAL(n1->name(), n2->name());
+ LT_RETURN_IF_NOT_EQUAL(n1->access(), n2->access());
return false;
}
@@ -3611,17 +3589,7 @@ bool HeaderNode::hasDocumentedChildren() const
*/
/*!
- Returns the node's full title, which is usually whatever
- title() returns, but for some cases the full title migth
- be different from title(), so this might require changing,
- because currently it just returns the title().
-
- mws 13/07/2018. This function used to test the node subtype
- for File or Image and append text to the title(), but there
- are no node subtypes now, so it can't do that. There are no
- node type values for File and Image either. Files and images
- are used in examples, but the ExampleNode's example files
- and example images are stored as lists of path strings.
+ Returns the node's full title.
*/
QString PageNode::fullTitle() const
{