diff options
Diffstat (limited to 'src/tools/qdoc/tree.cpp')
-rw-r--r-- | src/tools/qdoc/tree.cpp | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index 2e327a5ac8..a4b8d8cd8a 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -66,10 +66,19 @@ QT_BEGIN_NAMESPACE be necessary, and it might be removed later. */ Tree::Tree(const QString& module, QDocDatabase* qdb) - : module_(module), qdb_(qdb), root_(0, QString()) + : treeHasBeenAnalyzed_(false), + docsHaveBeenGenerated_(false), + linkCount_(0), + module_(module), + qdb_(qdb), + root_(0, QString()), + targetListMap_(0) { root_.setModuleName(module_); root_.setTree(this); + if (Generator::writeQaPages()) { + targetListMap_ = new TargetListMap; + } } /*! @@ -95,6 +104,18 @@ Tree::~Tree() } nodesByTargetRef_.clear(); nodesByTargetTitle_.clear(); + if (Generator::writeQaPages() && targetListMap_) { + TargetListMap::iterator i = targetListMap_->begin(); + while (i != targetListMap_->end()) { + TargetList* tlist = i.value(); + if (tlist) { + foreach (TargetLoc* tloc, *tlist) + delete tloc; + } + delete tlist; + ++i; + } + } } /* API members */ @@ -1114,7 +1135,7 @@ QString Tree::refForAtom(const Atom* atom) if (atom) { if (atom->type() == Atom::SectionLeft) return Doc::canonicalTitle(Text::sectionHeading(atom).toString()); - if (atom->type() == Atom::Target) + if ((atom->type() == Atom::Target) || (atom->type() == Atom::Keyword)) return Doc::canonicalTitle(atom->string()); } return QString(); @@ -1394,4 +1415,51 @@ const Node* Tree::checkForCollision(const QString& name) return findNode(QStringList(name), 0, 0, Node::DontCare); } +/*! + Generate a target of the form link-nnn, where the nnn is + the current link count for this tree. This target string + is returned. It will be output as an HTML anchor just before + an HTML link to the node \a t. + + The node \a t + */ +QString Tree::getNewLinkTarget(const Node* locNode, + const Node* t, + const QString& fileName, + QString& text, + bool broken) +{ + QString moduleName; + if (t && !broken) { + Tree* tree = t->tree(); + if (tree != this) + tree->incrementLinkCount(); + moduleName = tree->moduleName(); + } + else + moduleName = "broken"; + incrementLinkCount(); + QString target = QString("qa-target-%1").arg(-(linkCount())); + TargetLoc* tloc = new TargetLoc(locNode, target, fileName, text, broken); + TargetList* tList = 0; + TargetListMap::iterator i = targetListMap_->find(moduleName); + if (i == targetListMap_->end()) { + tList = new TargetList; + i = targetListMap_->insert(moduleName, tList); + } + else + tList = i.value(); + tList->append(tloc); + return target; +} + +/*! + Look up the target list for the specified \a module + and return a pointer to it. + */ +TargetList* Tree::getTargetList(const QString& module) +{ + return targetListMap_->value(module); +} + QT_END_NAMESPACE |