summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/qdocindexfiles.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2015-10-09 16:06:36 +0200
committerTopi Reiniƶ <topi.reinio@digia.com>2015-10-13 11:55:46 +0000
commitee634611d4d78d7ee66b79dc765abab231391eab (patch)
tree5933ae846a0db1f4382b75c25f48f1102da3f581 /src/tools/qdoc/qdocindexfiles.cpp
parent798128856c83f2542af166de0083ed46bcd70704 (diff)
qdoc: Insert targets for function and enum nodes read from the index
QDoc wrote \target and \keyword information into the index file properly, but did not read them back in. This was because the code for handling enum and function elements read their own child elements (without handling targets), and marked the remaining children to be skipped. This commit fixes the issue by refactoring the code for inserting targets into a new function and calling it from relevant places. Change-Id: I85d7b26ce54620daec35b19e447d1a065515b863 Task-number: QTBUG-48687 Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'src/tools/qdoc/qdocindexfiles.cpp')
-rw-r--r--src/tools/qdoc/qdocindexfiles.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp
index 292a4de021..ef86d782c7 100644
--- a/src/tools/qdoc/qdocindexfiles.cpp
+++ b/src/tools/qdoc/qdocindexfiles.cpp
@@ -463,10 +463,15 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
location = Location(parent->name().toLower() + ".html");
while (reader.readNextStartElement()) {
+ QXmlStreamAttributes childAttributes = reader.attributes();
if (reader.name() == QLatin1String("value")) {
- QXmlStreamAttributes childAttributes = reader.attributes();
+
EnumItem item(childAttributes.value(QLatin1String("name")).toString(), childAttributes.value(QLatin1String("value")).toString());
enumNode->addItem(item);
+ } else if (reader.name() == QLatin1String("keyword")) {
+ insertTarget(TargetRec::Keyword, childAttributes, enumNode);
+ } else if (reader.name() == QLatin1String("target")) {
+ insertTarget(TargetRec::Target, childAttributes, enumNode);
}
reader.skipCurrentElement();
}
@@ -552,8 +557,8 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
*/
while (reader.readNextStartElement()) {
+ QXmlStreamAttributes childAttributes = reader.attributes();
if (reader.name() == QLatin1String("parameter")) {
- QXmlStreamAttributes childAttributes = reader.attributes();
// Do not use the default value for the parameter; it is not
// required, and has been known to cause problems.
Parameter parameter(childAttributes.value(QLatin1String("left")).toString(),
@@ -561,6 +566,10 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
childAttributes.value(QLatin1String("name")).toString(),
QString()); // childAttributes.value(QLatin1String("default"))
functionNode->addParameter(parameter);
+ } else if (reader.name() == QLatin1String("keyword")) {
+ insertTarget(TargetRec::Keyword, childAttributes, functionNode);
+ } else if (reader.name() == QLatin1String("target")) {
+ insertTarget(TargetRec::Target, childAttributes, functionNode);
}
reader.skipCurrentElement();
}
@@ -581,18 +590,15 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
location = Location(parent->name().toLower() + ".html");
}
else if (elementName == QLatin1String("keyword")) {
- QString title = attributes.value(QLatin1String("title")).toString();
- qdb_->insertTarget(name, title, TargetRec::Keyword, current, 1);
+ insertTarget(TargetRec::Keyword, attributes, current);
goto done;
}
else if (elementName == QLatin1String("target")) {
- QString title = attributes.value(QLatin1String("title")).toString();
- qdb_->insertTarget(name, title, TargetRec::Target, current, 2);
+ insertTarget(TargetRec::Target, attributes, current);
goto done;
}
else if (elementName == QLatin1String("contents")) {
- QString title = attributes.value(QLatin1String("title")).toString();
- qdb_->insertTarget(name, title, TargetRec::Contents, current, 3);
+ insertTarget(TargetRec::Contents, attributes, current);
goto done;
}
else
@@ -702,6 +708,30 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
}
}
+void QDocIndexFiles::insertTarget(TargetRec::TargetType type,
+ const QXmlStreamAttributes &attributes,
+ Node *node)
+{
+ int priority;
+ switch (type) {
+ case TargetRec::Keyword:
+ priority = 1;
+ break;
+ case TargetRec::Target:
+ priority = 2;
+ break;
+ case TargetRec::Contents:
+ priority = 3;
+ break;
+ default:
+ return;
+ }
+
+ QString name = attributes.value(QLatin1String("name")).toString();
+ QString title = attributes.value(QLatin1String("title")).toString();
+ qdb_->insertTarget(name, title, type, node, priority);
+}
+
/*!
This function tries to resolve class inheritance immediately
after the index file is read. It is not always possible to