doc: QML Inheritance is not resolved correctly.

qdoc did not resolve QML Inheritance correctly and the result was that
QML inheritance was not shown correctly in the documentation. Part of
the problem was that information was missing for QML types in the .index
files produced by qdoc. qdoc also did not show inheritance properly
when one of its base types was marked internal. These problems have
now been fixed.

This update also fixes the problem that caused qdoc to slow down to a
snail's pace over time. The group members list for certain group pages
was getting longer and longer, because qdoc added the same member to
the member list an additional time every time qdoc was run in -prepare
mode if you didn't clear the index files first. Now, qdoc only adds a
member to the member list if it isn't already in the member list.

Task-number: QTBUG-29778
Change-Id: Ie4f0458a2ea4ceb1a64cdcd7f60f16b124a20790
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
bb10
Martin Smith 2013-02-21 12:53:06 +01:00 committed by The Qt Project
parent 298f0b6573
commit bfce04fe5b
5 changed files with 48 additions and 11 deletions

View File

@ -1259,7 +1259,6 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
}
else {
FastSection all(qmlClassNode,QString(),QString(),"member","members");
const QmlClassNode* current = qmlClassNode;
while (current != 0) {
NodeList::ConstIterator c = current->childNodes().constBegin();
@ -1271,9 +1270,9 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
if ((*p)->type() == Node::QmlProperty) {
QString key = current->name() + "::" + (*p)->name();
key = sortName(*p, &key);
if (!all.memberMap.contains(key))
if (!all.memberMap.contains(key)) {
all.memberMap.insert(key,*p);
//insert(all,*p,style,Okay);
}
}
++p;
}
@ -1281,9 +1280,9 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, Syno
else {
QString key = current->name() + "::" + (*c)->name();
key = sortName(*c, &key);
if (!all.memberMap.contains(key))
if (!all.memberMap.contains(key)) {
all.memberMap.insert(key,*c);
//insert(all,*c,style,Okay);
}
}
++c;
}

View File

@ -661,6 +661,16 @@ bool InnerNode::hasMembers() const
return !members_.isEmpty();
}
/*!
Appends \a node to the members list, if and only if it
isn't already in the members list.
*/
void InnerNode::addMember(Node* node)
{
if (!members_.contains(node))
members_.append(node);
}
/*!
Returns true if this node's members collection contains at
least one namespace node.
@ -2187,6 +2197,20 @@ bool Node::setQmlModuleInfo(const QString& arg)
return false;
}
/*!
If this QML type node has a base type node,
return the fully qualified name of that QML
type, i.e. <QML-module-name>::<QML-type-name>.
*/
QString QmlClassNode::qmlFullBaseName() const
{
QString result;
if (baseNode_) {
result = baseNode_->qmlModuleIdentifier() + "::" + baseNode_->name();
}
return result;
}
/*!
The name of this QML class node might be the same as the
name of some other QML class node. If so, then this node's

View File

@ -240,6 +240,7 @@ public:
QString guid() const;
QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
virtual QString qmlFullBaseName() const { return QString(); }
virtual QString qmlModuleName() const { return qmlModuleName_; }
virtual QString qmlModuleVersion() const { return qmlModuleVersionMajor_ + "." + qmlModuleVersionMinor_; }
virtual QString qmlModuleIdentifier() const { return qmlModuleName_ + qmlModuleVersionMajor_; }
@ -332,7 +333,7 @@ public:
const NodeList & childNodes() const { return children_; }
const NodeList & relatedNodes() const { return related_; }
virtual void addMember(Node* node) { members_.append(node); }
virtual void addMember(Node* node);
const NodeList& members() const { return members_; }
virtual bool hasMembers() const;
virtual bool hasNamespaces() const;
@ -563,6 +564,7 @@ public:
virtual bool isAbstract() const { return abstract_; }
virtual void setAbstract(bool b) { abstract_ = b; }
virtual bool isInternal() const { return (status() == Internal); }
virtual QString qmlFullBaseName() const;
const ImportList& importList() const { return importList_; }
void setImportList(const ImportList& il) { importList_ = il; }
const QString& qmlBaseName() const { return baseName_; }

View File

@ -886,11 +886,16 @@ void QDocDatabase::resolveQmlInheritance(InnerNode* root)
QmlClassNode* qcn = static_cast<QmlClassNode*>(child);
if ((qcn->qmlBaseNode() == 0) && !qcn->qmlBaseName().isEmpty()) {
QmlClassNode* bqcn = 0;
const ImportList& imports = qcn->importList();
for (int i=0; i<imports.size(); ++i) {
bqcn = findQmlType(imports[i], qcn->qmlBaseName());
if (bqcn)
break;
if (qcn->qmlBaseName().contains("::")) {
bqcn = qmlTypeMap_.value(qcn->qmlBaseName());
}
else {
const ImportList& imports = qcn->importList();
for (int i=0; i<imports.size(); ++i) {
bqcn = findQmlType(imports[i], qcn->qmlBaseName());
if (bqcn)
break;
}
}
if (bqcn == 0) {
bqcn = findQmlType(QString(), qcn->qmlBaseName());

View File

@ -193,6 +193,9 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
QString qmlModuleName = element.attribute("qml-module-name");
QString qmlModuleVersion = element.attribute("qml-module-version");
qdb_->addToQmlModule(qmlModuleName + " " + qmlModuleVersion, qcn);
QString qmlFullBaseName = element.attribute("qml-base-type");
if (!qmlFullBaseName.isEmpty())
qcn->setQmlBaseName(qmlFullBaseName);
if (element.hasAttribute("location"))
name = element.attribute("location", QString());
if (!indexUrl.isEmpty())
@ -597,6 +600,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
QString nodeName;
QString qmlModuleName;
QString qmlModuleVersion;
QString qmlFullBaseName;
switch (node->type()) {
case Node::Namespace:
nodeName = "namespace";
@ -610,6 +614,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
nodeName = "qmlclass";
qmlModuleName = node->qmlModuleName();
qmlModuleVersion = node->qmlModuleVersion();
qmlFullBaseName = node->qmlFullBaseName();
}
else if (node->subType() == Node::QmlBasicType)
nodeName = "qmlbasictype";
@ -728,6 +733,8 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
if (!qmlModuleName.isEmpty()) {
writer.writeAttribute("qml-module-name", qmlModuleName);
writer.writeAttribute("qml-module-version", qmlModuleVersion);
if (!qmlFullBaseName.isEmpty())
writer.writeAttribute("qml-base-type", qmlFullBaseName);
}
QString fullName = node->fullDocumentName();
if (fullName != objName)