summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2015-10-16 11:51:22 +0200
committerTopi Reiniƶ <topi.reinio@digia.com>2015-10-21 09:52:29 +0000
commit70b229d996d45a661fe70fdb18909ad0e364f7ba (patch)
tree365eca104ee5d0167908b5730623f86508a6c6f1 /src
parentd159fe199fd50845fd20b00da0962c060479fe4c (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp64
-rw-r--r--src/tools/qdoc/qdocindexfiles.cpp20
2 files changed, 22 insertions, 62 deletions
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index b260e7ac1c..3c03a08019 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -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>";
- }
- 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>";
+ out() << qmlItemFooter;
+ }
+ 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);
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp
index ef86d782c7..b466f59819 100644
--- a/src/tools/qdoc/qdocindexfiles.cpp
+++ b/src/tools/qdoc/qdocindexfiles.cpp
@@ -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;