qdoc: Minor optimizations

Remove unnecessary type casts in qdocindexfiles.cpp, and reduce the
amount of duplicate string literals used for generating QML
documentation.

Change-Id: Ia6d68a44fad14bd7414c0106e8752999830c93e8
Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
Topi Reinio 2015-10-16 11:51:22 +02:00 committed by Topi Reiniö
parent d159fe199f
commit 70b229d996
2 changed files with 21 additions and 61 deletions

View File

@ -4170,6 +4170,17 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node,
#endif
generateExtractionMark(node, MemberMark);
generateKeywordAnchors(node);
QString qmlItemHeader("<div class=\"qmlproto\">\n"
"<div class=\"table\"><table class=\"qmlname\">\n"
"<tr valign=\"top\" class=\"odd\" id=\"%1\">\n"
"<td class=\"%2\"><p>\n"
"<a name=\"%3\"></a>");
QString qmlItemFooter("</p></td></tr>\n"
"</table></div>\n"
"</div>");
out() << "<div class=\"qmlitem\">";
QString nodeRef = refForNode(node);
if (node->type() == Node::QmlPropertyGroup) {
@ -4206,11 +4217,7 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node,
}
else if (node->type() == Node::QmlProperty) {
qpn = static_cast<QmlPropertyNode*>(node);
out() << "<div class=\"qmlproto\">";
out() << "<div class=\"table\"><table class=\"qmlname\">";
out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">";
out() << "<td class=\"tblQmlPropNode\"><p>";
out() << "<a name=\"" + refForNode(qpn) + "\"></a>";
out() << qmlItemHeader.arg(nodeRef, "tblQmlPropNode", refForNode(qpn));
if (!qpn->isReadOnlySet()) {
if (qpn->declarativeCppNode())
qpn->setReadOnly(!qpn->isWritable());
@ -4220,45 +4227,14 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node,
if (qpn->isDefault())
out() << "<span class=\"qmldefault\">default</span>";
generateQmlItem(qpn, relative, marker, false);
out() << "</p></td></tr>";
out() << "</table></div>";
out() << "</div>";
out() << qmlItemFooter;
}
else if (node->type() == Node::QmlSignal) {
const FunctionNode* qsn = static_cast<const FunctionNode*>(node);
out() << "<div class=\"qmlproto\">";
out() << "<div class=\"table\"><table class=\"qmlname\">";
out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">";
out() << "<td class=\"tblQmlFuncNode\"><p>";
out() << "<a name=\"" + refForNode(qsn) + "\"></a>";
generateSynopsis(qsn,relative,marker,CodeMarker::Detailed,false);
out() << "</p></td></tr>";
out() << "</table></div>";
out() << "</div>";
}
else if (node->type() == Node::QmlSignalHandler) {
const FunctionNode* qshn = static_cast<const FunctionNode*>(node);
out() << "<div class=\"qmlproto\">";
out() << "<div class=\"table\"><table class=\"qmlname\">";
out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">";
out() << "<td class=\"tblQmlFuncNode\"><p>";
out() << "<a name=\"" + refForNode(qshn) + "\"></a>";
generateSynopsis(qshn,relative,marker,CodeMarker::Detailed,false);
out() << "</p></td></tr>";
out() << "</table></div>";
out() << "</div>";
}
else if (node->type() == Node::QmlMethod) {
const FunctionNode* qmn = static_cast<const FunctionNode*>(node);
out() << "<div class=\"qmlproto\">";
out() << "<div class=\"table\"><table class=\"qmlname\">";
out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">";
out() << "<td class=\"tblQmlFuncNode\"><p>";
out() << "<a name=\"" + refForNode(qmn) + "\"></a>";
generateSynopsis(qmn,relative,marker,CodeMarker::Detailed,false);
out() << "</p></td></tr>";
out() << "</table></div>";
out() << "</div>";
else if (node->type() == Node::QmlSignal ||
node->type() == Node::QmlSignalHandler ||
node->type() == Node::QmlMethod) {
out() << qmlItemHeader.arg(nodeRef, "tblQmlFuncNode", refForNode(node));
generateSynopsis(node, relative, marker, CodeMarker::Detailed, false);
out() << qmlItemFooter;
}
out() << "<div class=\"qmldoc\">";
generateStatus(node, marker);

View File

@ -315,15 +315,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
bool readonly = false;
if (attributes.value(QLatin1String("writable")) == QLatin1String("false"))
readonly = true;
QmlPropertyNode* qpn = 0;
if (parent->isQmlType()) {
QmlTypeNode* qcn = static_cast<QmlTypeNode*>(parent);
qpn = new QmlPropertyNode(qcn, name, type, attached);
}
else if (parent->isQmlPropertyGroup()) {
QmlPropertyGroupNode* qpgn = static_cast<QmlPropertyGroupNode*>(parent);
qpn = new QmlPropertyNode(qpgn, name, type, attached);
}
QmlPropertyNode* qpn = new QmlPropertyNode(parent, name, type, attached);
qpn->setReadOnly(readonly);
node = qpn;
}
@ -335,15 +327,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
bool readonly = false;
if (attributes.value(QLatin1String("writable")) == QLatin1String("false"))
readonly = true;
QmlPropertyNode* qpn = 0;
if (parent->isJsType()) {
QmlTypeNode* qcn = static_cast<QmlTypeNode*>(parent);
qpn = new QmlPropertyNode(qcn, name, type, attached);
}
else if (parent->isJsPropertyGroup()) {
QmlPropertyGroupNode* qpgn = static_cast<QmlPropertyGroupNode*>(parent);
qpn = new QmlPropertyNode(qpgn, name, type, attached);
}
QmlPropertyNode* qpn = new QmlPropertyNode(parent, name, type, attached);
qpn->setGenus(Node::JS);
qpn->setReadOnly(readonly);
node = qpn;