summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/helpprojectwriter.cpp
diff options
context:
space:
mode:
authorMartin Smith <[email protected]>2012-09-13 11:38:45 +0200
committerQt by Nokia <[email protected]>2012-09-14 15:23:15 +0200
commit14f7eb86ca2275d91f284279af5f77205d4ae3c0 (patch)
treeed4e91d6422dd814ac3e81739ad4a3b55bf050c7 /src/tools/qdoc/helpprojectwriter.cpp
parent817a4474676b30a964de476d26bd70ddba3d379a (diff)
qdoc: Refactoring of qdoc data structures
This commit is the beginning of a significant overhaul of qdoc. A new class, QDocDatabase, is added, which will eventually encapsulate all the data structures used by qdoc. In this commit, the Tree class is made private and only accessible from QDocDatabase. Several maps structures are also moved into QDocDatabase from other classes. Much dead code and unused parameters were removed. Further simplification will follow. Change-Id: I237411c50f3ced0d2fc8d3b0fbfdf4e55880f8e9 Reviewed-by: Qt Doc Bot <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Jerome Pasion <[email protected]>
Diffstat (limited to 'src/tools/qdoc/helpprojectwriter.cpp')
-rw-r--r--src/tools/qdoc/helpprojectwriter.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/tools/qdoc/helpprojectwriter.cpp b/src/tools/qdoc/helpprojectwriter.cpp
index 98ebcd81c24..0a61bd62e4a 100644
--- a/src/tools/qdoc/helpprojectwriter.cpp
+++ b/src/tools/qdoc/helpprojectwriter.cpp
@@ -49,7 +49,8 @@
#include "htmlgenerator.h"
#include "config.h"
#include "node.h"
-#include "tree.h"
+#include "qdocdatabase.h"
+#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -58,6 +59,13 @@ HelpProjectWriter::HelpProjectWriter(const Config &config,
Generator* g)
: gen_(g)
{
+ /*
+ Get the pointer to the singleton for the qdoc database and
+ store it locally. This replaces all the local accesses to
+ the node tree, which are now private.
+ */
+ qdb_ = QDocDatabase::qdocDB();
+
// The output directory should already have been checked by the calling
// generator.
outputDir = config.getOutputDir();
@@ -455,9 +463,8 @@ void HelpProjectWriter::generateSections(HelpProject &project,
}
}
-void HelpProjectWriter::generate(const Tree *t)
+void HelpProjectWriter::generate()
{
- this->tree = t;
for (int i = 0; i < projects.size(); ++i)
generateProject(projects[i]);
}
@@ -581,9 +588,9 @@ void HelpProjectWriter::generateProject(HelpProject &project)
{
const Node *rootNode;
if (!project.indexRoot.isEmpty())
- rootNode = tree->findDocNodeByTitle(project.indexRoot);
+ rootNode = qdb_->findDocNodeByTitle(project.indexRoot);
else
- rootNode = tree->root();
+ rootNode = qdb_->treeRoot();
if (!rootNode)
return;
@@ -624,9 +631,9 @@ void HelpProjectWriter::generateProject(HelpProject &project)
writer.writeStartElement("toc");
writer.writeStartElement("section");
- const Node* node = tree->findDocNodeByTitle(project.indexTitle);
+ const Node* node = qdb_->findDocNodeByTitle(project.indexTitle);
if (node == 0)
- node = tree->findNode(QStringList("index.html"));
+ node = qdb_->findNode(QStringList("index.html"));
QString indexPath;
if (node)
indexPath = gen_->fullDocumentLocation(node,true);
@@ -643,7 +650,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
if (subproject.type == QLatin1String("manual")) {
- const DocNode *indexPage = tree->findDocNodeByTitle(subproject.indexTitle);
+ const DocNode *indexPage = qdb_->findDocNodeByTitle(subproject.indexTitle);
if (indexPage) {
Text indexBody = indexPage->doc().body();
const Atom *atom = indexBody.firstAtom();
@@ -670,7 +677,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
if (sectionStack.top() > 0)
writer.writeEndElement(); // section
- const DocNode *page = tree->findDocNodeByTitle(atom->string());
+ const DocNode *page = qdb_->findDocNodeByTitle(atom->string());
writer.writeStartElement("section");
QString indexPath = gen_->fullDocumentLocation(page,true);
writer.writeAttribute("ref", indexPath);
@@ -697,7 +704,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
if (!name.isEmpty()) {
writer.writeStartElement("section");
- QString indexPath = gen_->fullDocumentLocation(tree->findDocNodeByTitle(subproject.indexTitle),true);
+ QString indexPath = gen_->fullDocumentLocation(qdb_->findDocNodeByTitle(subproject.indexTitle),true);
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", subproject.title);
project.files.insert(indexPath);
@@ -717,7 +724,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
if (!nextTitle.isEmpty() &&
node->links().value(Node::ContentsLink).first.isEmpty()) {
- DocNode *nextPage = const_cast<DocNode *>(tree->findDocNodeByTitle(nextTitle));
+ DocNode *nextPage = const_cast<DocNode *>(qdb_->findDocNodeByTitle(nextTitle));
// Write the contents node.
writeNode(project, writer, node);
@@ -727,7 +734,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
nextTitle = nextPage->links().value(Node::NextLink).first;
if (nextTitle.isEmpty() || visited.contains(nextTitle))
break;
- nextPage = const_cast<DocNode *>(tree->findDocNodeByTitle(nextTitle));
+ nextPage = const_cast<DocNode *>(qdb_->findDocNodeByTitle(nextTitle));
visited.insert(nextTitle);
}
break;