summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2024-04-16 13:16:08 +0200
committerPaul Wicking <paul.wicking@qt.io>2024-04-18 09:42:04 +0200
commitec2cb0b4d0e18ae234ec5c138ae62a43a280a7b7 (patch)
treec920e05a34a70194ba7027bf363a7a645771b702
parent25f2bb922188e759cd6beb11b3b80d8772105574 (diff)
QDoc: Refactor Tree::refForAtom
Turn the conditional into a switch statement, to prepare for upcoming changes to the method. Add an assertion on the Node* argument. Update method documentation. Task-number: QTBUG-122261 Change-Id: I63952e59eef43d0c62669f6e84d8a9a900457474 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/qdoc/src/qdoc/tree.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/qdoc/qdoc/src/qdoc/tree.cpp b/src/qdoc/qdoc/src/qdoc/tree.cpp
index d1b518fd2..55573f1f5 100644
--- a/src/qdoc/qdoc/src/qdoc/tree.cpp
+++ b/src/qdoc/qdoc/src/qdoc/tree.cpp
@@ -927,17 +927,22 @@ const PageNode *Tree::findPageNodeByTitle(const QString &title) const
/*!
Returns a canonical title for the \a atom, if the \a atom
- is a SectionLeft or a Target.
+ is a SectionLeft, Keyword, or Target.
*/
QString Tree::refForAtom(const Atom *atom)
{
- if (atom) {
- if (atom->type() == Atom::SectionLeft)
- return Utilities::asAsciiPrintable(Text::sectionHeading(atom).toString());
- if ((atom->type() == Atom::Target) || (atom->type() == Atom::Keyword))
- return Utilities::asAsciiPrintable(atom->string());
+ Q_ASSERT(atom);
+
+ switch (atom->type()) {
+ case Atom::SectionLeft:
+ return Utilities::asAsciiPrintable(Text::sectionHeading(atom).toString());
+ case Atom::Target:
+ [[fallthrough]];
+ case Atom::Keyword:
+ return Utilities::asAsciiPrintable(atom->string());
+ default:
+ return {};
}
- return QString();
}
/*!