From 82fa92b23cca834481571f0b0a5d66bc33a672e9 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 27 Apr 2012 16:08:16 +0200 Subject: qdoc: Further changes to the QML specialization The tag now has an id attribute of the form "id-qml-propertygroup-xxx" where the xxx is the property name. //This should be unique within the document. Change-Id: I20b30266dbe92b85b60400de30ebf9b1f1e292ea Reviewed-by: Casper van Donderen --- src/tools/qdoc/ditaxmlgenerator.cpp | 9 ++- src/tools/qdoc/node.cpp | 121 ++++++++++++++++++++++-------------- src/tools/qdoc/node.h | 20 +++--- 3 files changed, 87 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp index 96a1de659a..a19bf45610 100644 --- a/src/tools/qdoc/ditaxmlgenerator.cpp +++ b/src/tools/qdoc/ditaxmlgenerator.cpp @@ -2210,6 +2210,7 @@ DitaXmlGenerator::generateClassLikeNode(InnerNode* inner, CodeMarker* marker) rawTitle = marker->plainName(inner); fullTitle = marker->plainFullName(inner); title = rawTitle + " Element"; + Node::clearPropertyGroupCount(); generateHeader(inner, fullTitle); generateBrief(inner, marker); // @@ -4491,6 +4492,9 @@ void DitaXmlGenerator::generateDetailedQmlMember(Node* node, } else { writeStartTag(DT_qmlPropertyGroup); + QString id = "id-qml-propertygroup-" + node->name(); + id.replace('.','-'); + xmlWriter().writeAttribute("id",id); writeStartTag(DT_apiName); //writeCharacters("..."); writeEndTag(); // @@ -4534,6 +4538,9 @@ void DitaXmlGenerator::generateDetailedQmlMember(Node* node, group. */ writeStartTag(DT_qmlPropertyGroup); + QString id = "id-qml-propertygroup-" + node->name(); + id.replace('.','-'); + xmlWriter().writeAttribute("id",id); writeStartTag(DT_apiName); //writeCharacters("..."); writeEndTag(); // @@ -4908,8 +4915,6 @@ void DitaXmlGenerator::writeFunctions(const Section& s, if ((*m)->type() == Node::Function) { FunctionNode* fn = const_cast(static_cast(*m)); writeStartTag(DT_cxxFunction); - if (outFileName() == "qgeoboundingbox.dita" && fn->guid() == "id-operator-") - qDebug() << "ID:" << fn->guid() << fn->name(); xmlWriter().writeAttribute("id",fn->guid()); if (fn->metaness() == FunctionNode::Signal) xmlWriter().writeAttribute("otherprops","signal"); diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 24c0006dae..5f9c45d31b 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -48,9 +48,22 @@ QT_BEGIN_NAMESPACE +int Node::propertyGroupCount_ = 0; ExampleNodeMap ExampleNode::exampleNodeMap; QStringMap Node::operators_; +/*! + Increment the number of property groups seen in the current + file, and return the new value. + */ +int Node::incPropertyGroupCount() { return ++propertyGroupCount_; } + +/*! + Reset the number of property groups seen in the current file + to 0, because we are starting a new file. + */ +void Node::clearPropertyGroupCount() { propertyGroupCount_ = 0; } + /*! \class Node \brief The Node class is a node in the Tree. @@ -2182,17 +2195,26 @@ QmlBasicTypeNode::QmlBasicTypeNode(InnerNode *parent, always a QmlClassNode. */ QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent, const QString& name) - //bool attached) : FakeNode(parent, name, QmlPropertyGroup, Node::ApiPage) -#if 0 - isdefault_(false), - attached_(attached), - readOnly_(-1) -#endif { - // nothing. + idNumber_ = -1; +} + +/*! + Return the property group node's id number for use in + constructing an id attribute for the property group. + If the id number is currently -1, increment the global + property group count and set the id number to the new + value. + */ +QString QmlPropGroupNode::idNumber() +{ + if (idNumber_ == -1) + idNumber_ = incPropertyGroupCount(); + return QString().setNum(idNumber_); } + /*! Constructor for the QML property node, when the \a parent is QML property group node. This constructor is only used @@ -2662,50 +2684,53 @@ QString Node::idForNode() const } break; case Node::Fake: - { - switch (subType()) { - case Node::QmlClass: - str = "qml-class-" + name(); - break; - case Node::QmlPropertyGroup: - str = "qml-property-" + name(); - break; - case Node::Page: - case Node::Group: - case Node::Module: - case Node::HeaderFile: - str = title(); - if (str.isEmpty()) { + { + switch (subType()) { + case Node::QmlClass: + str = "qml-class-" + name(); + break; + case Node::QmlPropertyGroup: + { + Node* n = const_cast(this); + str = "qml-propertygroup-" + n->name(); + } + break; + case Node::Page: + case Node::Group: + case Node::Module: + case Node::HeaderFile: + str = title(); + if (str.isEmpty()) { + str = name(); + if (str.endsWith(".html")) + str.remove(str.size()-5,5); + } + str.replace("/","-"); + break; + case Node::File: + str = name(); + str.replace("/","-"); + break; + case Node::Example: str = name(); - if (str.endsWith(".html")) - str.remove(str.size()-5,5); + str.replace("/","-"); + break; + case Node::QmlBasicType: + str = "qml-basic-type-" + name(); + break; + case Node::QmlModule: + str = "qml-module-" + name(); + break; + case Node::Collision: + str = title(); + str.replace(": ","-"); + break; + default: + qDebug() << "ERROR: A case was not handled in Node::idForNode():" + << "subType():" << subType() << "type():" << type(); + break; } - str.replace("/","-"); - break; - case Node::File: - str = name(); - str.replace("/","-"); - break; - case Node::Example: - str = name(); - str.replace("/","-"); - break; - case Node::QmlBasicType: - str = "qml-basic-type-" + name(); - break; - case Node::QmlModule: - str = "qml-module-" + name(); - break; - case Node::Collision: - str = title(); - str.replace(": ","-"); - break; - default: - qDebug() << "ERROR: A case was not handled in Node::idForNode():" - << "subType():" << subType() << "type():" << type(); - break; } - } break; case Node::QmlProperty: str = "qml-property-" + name(); diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 45b5ded640..44b4973ff0 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -238,6 +238,7 @@ public: virtual const ImportList* importList() const { return 0; } virtual void setImportList(const ImportList& ) { } virtual const Node* applyModuleIdentifier(const Node* ) const { return 0; } + virtual QString idNumber() { return "0"; } QmlClassNode* qmlClassNode(); ClassNode* declarativeCppNode(); const QString& outputSubdirectory() const { return outSubDir_; } @@ -251,6 +252,8 @@ public: static QString pageTypeString(unsigned t); static QString nodeTypeString(unsigned t); static QString nodeSubtypeString(unsigned t); + static int incPropertyGroupCount(); + static void clearPropertyGroupCount(); protected: Node(Type type, InnerNode* parent, const QString& name); @@ -288,6 +291,7 @@ private: QString qmlModuleName_; QString qmlModuleVersion_; static QStringMap operators_; + static int propertyGroupCount_; }; class FunctionNode; @@ -563,28 +567,18 @@ class QmlPropGroupNode : public FakeNode { public: QmlPropGroupNode(QmlClassNode* parent, const QString& name); - //bool attached); virtual ~QmlPropGroupNode() { } virtual bool isQmlNode() const { return true; } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } + virtual QString idNumber(); const QString& element() const { return parent()->name(); } -#if 0 - void setDefault() { isdefault_ = true; } - void setReadOnly(int ro) { readOnly_ = ro; } - int getReadOnly() const { return readOnly_; } - bool isDefault() const { return isdefault_; } - bool isAttached() const { return attached_; } - bool isReadOnly() const { return (readOnly_ > 0); } -private: - bool isdefault_; - bool attached_; - int readOnly_; -#endif + private: + int idNumber_; }; class QmlPropertyNode; -- cgit v1.2.3