summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/qdoc/tree.cpp')
-rw-r--r--src/tools/qdoc/tree.cpp120
1 files changed, 95 insertions, 25 deletions
diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp
index 2e327a5ac8b..d25e1bc3450 100644
--- a/src/tools/qdoc/tree.cpp
+++ b/src/tools/qdoc/tree.cpp
@@ -65,11 +65,20 @@ QT_BEGIN_NAMESPACE
qdoc database that is constructing the tree. This might not
be necessary, and it might be removed later.
*/
-Tree::Tree(const QString& module, QDocDatabase* qdb)
- : module_(module), qdb_(qdb), root_(0, QString())
+Tree::Tree(const QString& physicalModuleName, QDocDatabase* qdb)
+ : treeHasBeenAnalyzed_(false),
+ docsHaveBeenGenerated_(false),
+ linkCount_(0),
+ physicalModuleName_(physicalModuleName),
+ qdb_(qdb),
+ root_(0, QString()),
+ targetListMap_(0)
{
- root_.setModuleName(module_);
+ root_.setPhysicalModuleName(physicalModuleName_);
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 */
@@ -167,7 +188,7 @@ FunctionNode* Tree::findFunctionNode(const QStringList& parentPath, const Functi
at the root of the tree. Only a Qml type node named <\a path is
acceptible. If one is not found, 0 is returned.
*/
-QmlClassNode* Tree::findQmlTypeNode(const QStringList& path)
+QmlTypeNode* Tree::findQmlTypeNode(const QStringList& path)
{
/*
If the path contains one or two double colons ("::"),
@@ -178,11 +199,11 @@ QmlClassNode* Tree::findQmlTypeNode(const QStringList& path)
class node.
*/
if (path.size() >= 2 && !path[0].isEmpty()) {
- QmlClassNode* qcn = qdb_->findQmlType(path[0], path[1]);
+ QmlTypeNode* qcn = qdb_->findQmlType(path[0], path[1]);
if (qcn)
return qcn;
}
- return static_cast<QmlClassNode*>(findNodeRecursive(path, 0, root(), Node::QmlType));
+ return static_cast<QmlTypeNode*>(findNodeRecursive(path, 0, root(), Node::QmlType));
}
/*!
@@ -198,13 +219,14 @@ const FunctionNode* Tree::findFunctionNode(const QStringList& path,
int findFlags,
Node::Genus genus) const
{
- if (path.size() == 3 && !path[0].isEmpty() && (genus != Node::CPP)) {
- QmlClassNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
+ if (path.size() == 3 && !path[0].isEmpty() &&
+ ((genus == Node::QML) || (genus == Node::DontCare))) {
+ QmlTypeNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (!qcn) {
QStringList p(path[1]);
Node* n = findNodeByNameAndType(p, Node::QmlType);
if (n && n->isQmlType())
- qcn = static_cast<QmlClassNode*>(n);
+ qcn = static_cast<QmlTypeNode*>(n);
}
if (qcn)
return static_cast<const FunctionNode*>(qcn->findFunctionNode(path[2]));
@@ -468,7 +490,7 @@ void Tree::resolveCppToQmlLinks()
foreach (Node* child, root_.childNodes()) {
if (child->isQmlType()) {
- QmlClassNode* qcn = static_cast<QmlClassNode*>(child);
+ QmlTypeNode* qcn = static_cast<QmlTypeNode*>(child);
ClassNode* cn = const_cast<ClassNode*>(qcn->classNode());
if (cn)
cn->setQmlElement(qcn);
@@ -670,7 +692,7 @@ const Node* Tree::findNodeForTarget(const QStringList& path,
QString p;
if (path.size() > 1)
p = path.join(QString("::"));
- else {
+ else if ((genus == Node::DontCare) || (genus == Node::DOC)) {
p = path.at(0);
node = findDocNodeByTitle(p);
if (node) {
@@ -707,8 +729,9 @@ const Node* Tree::findNodeForTarget(const QStringList& path,
type node.
*/
int path_idx = 0;
- if ((genus != Node::CPP) && (path.size() >= 2) && !path[0].isEmpty()) {
- QmlClassNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
+ if (((genus == Node::QML) || (genus == Node::DontCare)) &&
+ (path.size() >= 2) && !path[0].isEmpty()) {
+ QmlTypeNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (qcn) {
current = qcn;
if (path.size() == 2) {
@@ -716,8 +739,7 @@ const Node* Tree::findNodeForTarget(const QStringList& path,
ref = getRef(target, current);
if (!ref.isEmpty())
return current;
- else if (genus == Node::QML)
- return 0;
+ return 0;
}
else
return current;
@@ -803,7 +825,8 @@ const Node* Tree::matchPathAndTarget(const QStringList& path,
return t;
}
}
- if ((genus != Node::QML) && node->isClass() && (flags & SearchBaseClasses)) {
+ if (((genus == Node::CPP) || (genus == Node::DontCare)) &&
+ node->isClass() && (flags & SearchBaseClasses)) {
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode*>(node));
foreach (const Node* bc, baseClasses) {
t = matchPathAndTarget(path, idx, target, bc, flags, genus, ref);
@@ -851,8 +874,9 @@ const Node* Tree::findNode(const QStringList& path,
If the answer is yes, the reference identifies a QML
type node.
*/
- if ((genus != Node::CPP) && (path.size() >= 2) && !path[0].isEmpty()) {
- QmlClassNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
+ if (((genus == Node::QML) || (genus == Node::DontCare)) &&
+ (path.size() >= 2) && !path[0].isEmpty()) {
+ QmlTypeNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (qcn) {
node = qcn;
if (path.size() == 2)
@@ -869,7 +893,8 @@ const Node* Tree::findNode(const QStringList& path,
if (!next && (findFlags & SearchEnumValues) && i == path.size()-1) {
next = static_cast<const InnerNode*>(node)->findEnumNodeForValue(path.at(i));
}
- if (!next && (genus != Node::QML) && node->isClass() && (findFlags & SearchBaseClasses)) {
+ if (!next && ((genus == Node::CPP) || (genus == Node::DontCare)) &&
+ node->isClass() && (findFlags & SearchBaseClasses)) {
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode*>(node));
foreach (const Node* baseClass, baseClasses) {
next = static_cast<const InnerNode*>(baseClass)->findChildNode(path.at(i), genus);
@@ -1114,7 +1139,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();
@@ -1323,7 +1348,7 @@ ModuleNode* Tree::addToModule(const QString& name, Node* node)
{
ModuleNode* mn = findModule(name);
mn->addMember(node);
- node->setModuleName(name);
+ node->setPhysicalModuleName(name);
return mn;
}
@@ -1349,7 +1374,7 @@ QmlModuleNode* Tree::addToQmlModule(const QString& name, Node* node)
qmn->addMember(node);
node->setQmlModule(qmn);
if (node->isQmlType()) {
- QmlClassNode* n = static_cast<QmlClassNode*>(node);
+ QmlTypeNode* n = static_cast<QmlTypeNode*>(node);
for (int i=0; i<qmid.size(); ++i) {
QString key = qmid[i] + "::" + node->name();
insertQmlType(key, n);
@@ -1362,7 +1387,7 @@ QmlModuleNode* Tree::addToQmlModule(const QString& name, Node* node)
If the QML type map does not contain \a key, insert node
\a n with the specified \a key.
*/
-void Tree::insertQmlType(const QString& key, QmlClassNode* n)
+void Tree::insertQmlType(const QString& key, QmlTypeNode* n)
{
if (!qmlTypeMap_.contains(key))
qmlTypeMap_.insert(key,n);
@@ -1371,8 +1396,6 @@ void Tree::insertQmlType(const QString& key, QmlClassNode* n)
/*!
Split \a target on "::" and find the function node with that
path.
-
- Called in HtmlGenerator, DitaXmlGenerator, and QdocDatabase.
*/
const Node* Tree::findFunctionNode(const QString& target, const Node* relative, Node::Genus genus)
{
@@ -1394,4 +1417,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 physicalModuleName;
+ if (t && !broken) {
+ Tree* tree = t->tree();
+ if (tree != this)
+ tree->incrementLinkCount();
+ physicalModuleName = tree->physicalModuleName();
+ }
+ else
+ physicalModuleName = "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(physicalModuleName);
+ if (i == targetListMap_->end()) {
+ tList = new TargetList;
+ i = targetListMap_->insert(physicalModuleName, 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