From 71b8213a10587569c8d378b155e342f24d89bc38 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 16 Apr 2010 10:48:45 +0200 Subject: qdoc: Improved TOC for class ref pages. (cherry picked from commit 8c942f6d2998ffcd024437e408f92d38750dd025) --- tools/qdoc3/htmlgenerator.cpp | 45 ++++++++++++++++++++++++++++++++++--------- tools/qdoc3/htmlgenerator.h | 4 +++- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 8beedb0..6922ef8 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1256,7 +1256,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, } generateHeader(title, inner, marker, true); - generateTableOfContents(inner,marker); + sections = marker->sections(inner, CodeMarker::Summary, CodeMarker::Okay); + generateTableOfContents(inner,marker,§ions); generateTitle(title, subtitleText, SmallSubTitle, inner, marker); #ifdef QDOC_QML @@ -1300,7 +1301,9 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, bool needOtherSection = false; - sections = marker->sections(inner, CodeMarker::Summary, CodeMarker::Okay); + /* + sections is built above for the call to generateTableOfContents(). + */ s = sections.begin(); while (s != sections.end()) { if (s->members.isEmpty() && s->reimpMembers.isEmpty()) { @@ -2026,7 +2029,9 @@ void HtmlGenerator::generateTableOfContents(const Node *node, Revised for the new doc format. Generates a table of contents begining at \a node. */ -void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker) +void HtmlGenerator::generateTableOfContents(const Node *node, + CodeMarker *marker, + QList
* sections) { if (!node->doc().hasTableOfContents()) { if (node->subType() != Node::Module) @@ -2038,14 +2043,15 @@ void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker return; } - Doc::SectioningUnit sectioningUnit = Doc::Section4; QStringList sectionNumber; + int detailsBase = 0; // disable nested links in table of contents inContents = true; inLink = true; out() << "
\n"; + out() << "

Table of Contents

\n"; sectionNumber.append("1"); out() << "
    \n"; @@ -2057,15 +2063,36 @@ void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker out() << "
  • Classes
  • \n"; } out() << "
  • Detailed Description
  • \n"; + for (int i = 0; i < toc.size(); ++i) { + if (toc.at(i)->string().toInt() == 1) { + detailsBase = 1; + break; + } + } + } + else if (sections && (node->type() == Node::Class)) { + QList
    ::ConstIterator s = sections->begin(); + while (s != sections->end()) { + if (!s->members.isEmpty() || !s->reimpMembers.isEmpty()) { + out() << "
  • " << (*s).name + << "
  • \n"; + } + ++s; + } + out() << "
  • Detailed Description
  • \n"; + for (int i = 0; i < toc.size(); ++i) { + if (toc.at(i)->string().toInt() == 1) { + detailsBase = 1; + break; + } + } } for (int i = 0; i < toc.size(); ++i) { Atom *atom = toc.at(i); - - int nextLevel = atom->string().toInt(); - if (nextLevel > (int)sectioningUnit) - continue; - + int nextLevel = atom->string().toInt() + detailsBase; if (sectionNumber.size() < nextLevel) { do { sectionNumber.append("1"); diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index ec96c34..559c968 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -153,7 +153,9 @@ class HtmlGenerator : public PageGenerator Doc::SectioningUnit sectioningUnit, int numColumns, const Node *relative = 0); - void generateTableOfContents(const Node *node, CodeMarker *marker); + void generateTableOfContents(const Node *node, + CodeMarker *marker, + QList
    * sections = 0); QString generateListOfAllMemberFile(const InnerNode *inner, CodeMarker *marker); QString generateLowStatusMemberFile(const InnerNode *inner, CodeMarker *marker, -- cgit v0.12