qdoc: Further changes to the QML specialization

The <qmlPropertyGroup> 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 <casper.vandonderen@nokia.com>
This commit is contained in:
Martin Smith 2012-04-27 16:08:16 +02:00 committed by Qt by Nokia
parent 600e193bbc
commit 82fa92b23c
3 changed files with 87 additions and 63 deletions

View File

@ -2210,6 +2210,7 @@ DitaXmlGenerator::generateClassLikeNode(InnerNode* inner, CodeMarker* marker)
rawTitle = marker->plainName(inner); rawTitle = marker->plainName(inner);
fullTitle = marker->plainFullName(inner); fullTitle = marker->plainFullName(inner);
title = rawTitle + " Element"; title = rawTitle + " Element";
Node::clearPropertyGroupCount();
generateHeader(inner, fullTitle); generateHeader(inner, fullTitle);
generateBrief(inner, marker); // <shortdesc> generateBrief(inner, marker); // <shortdesc>
@ -4491,6 +4492,9 @@ void DitaXmlGenerator::generateDetailedQmlMember(Node* node,
} }
else { else {
writeStartTag(DT_qmlPropertyGroup); writeStartTag(DT_qmlPropertyGroup);
QString id = "id-qml-propertygroup-" + node->name();
id.replace('.','-');
xmlWriter().writeAttribute("id",id);
writeStartTag(DT_apiName); writeStartTag(DT_apiName);
//writeCharacters("..."); //writeCharacters("...");
writeEndTag(); // </apiName> writeEndTag(); // </apiName>
@ -4534,6 +4538,9 @@ void DitaXmlGenerator::generateDetailedQmlMember(Node* node,
group. group.
*/ */
writeStartTag(DT_qmlPropertyGroup); writeStartTag(DT_qmlPropertyGroup);
QString id = "id-qml-propertygroup-" + node->name();
id.replace('.','-');
xmlWriter().writeAttribute("id",id);
writeStartTag(DT_apiName); writeStartTag(DT_apiName);
//writeCharacters("..."); //writeCharacters("...");
writeEndTag(); // </apiName> writeEndTag(); // </apiName>
@ -4908,8 +4915,6 @@ void DitaXmlGenerator::writeFunctions(const Section& s,
if ((*m)->type() == Node::Function) { if ((*m)->type() == Node::Function) {
FunctionNode* fn = const_cast<FunctionNode*>(static_cast<const FunctionNode*>(*m)); FunctionNode* fn = const_cast<FunctionNode*>(static_cast<const FunctionNode*>(*m));
writeStartTag(DT_cxxFunction); writeStartTag(DT_cxxFunction);
if (outFileName() == "qgeoboundingbox.dita" && fn->guid() == "id-operator-")
qDebug() << "ID:" << fn->guid() << fn->name();
xmlWriter().writeAttribute("id",fn->guid()); xmlWriter().writeAttribute("id",fn->guid());
if (fn->metaness() == FunctionNode::Signal) if (fn->metaness() == FunctionNode::Signal)
xmlWriter().writeAttribute("otherprops","signal"); xmlWriter().writeAttribute("otherprops","signal");

View File

@ -48,9 +48,22 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
int Node::propertyGroupCount_ = 0;
ExampleNodeMap ExampleNode::exampleNodeMap; ExampleNodeMap ExampleNode::exampleNodeMap;
QStringMap Node::operators_; 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 \class Node
\brief The Node class is a node in the Tree. \brief The Node class is a node in the Tree.
@ -2182,17 +2195,26 @@ QmlBasicTypeNode::QmlBasicTypeNode(InnerNode *parent,
always a QmlClassNode. always a QmlClassNode.
*/ */
QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent, const QString& name) QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent, const QString& name)
//bool attached)
: FakeNode(parent, name, QmlPropertyGroup, Node::ApiPage) : 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 Constructor for the QML property node, when the \a parent
is QML property group node. This constructor is only used is QML property group node. This constructor is only used
@ -2662,50 +2684,53 @@ QString Node::idForNode() const
} }
break; break;
case Node::Fake: case Node::Fake:
{ {
switch (subType()) { switch (subType()) {
case Node::QmlClass: case Node::QmlClass:
str = "qml-class-" + name(); str = "qml-class-" + name();
break; break;
case Node::QmlPropertyGroup: case Node::QmlPropertyGroup:
str = "qml-property-" + name(); {
break; Node* n = const_cast<Node*>(this);
case Node::Page: str = "qml-propertygroup-" + n->name();
case Node::Group: }
case Node::Module: break;
case Node::HeaderFile: case Node::Page:
str = title(); case Node::Group:
if (str.isEmpty()) { 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 = name();
if (str.endsWith(".html")) str.replace("/","-");
str.remove(str.size()-5,5); 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;
} }
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; break;
case Node::QmlProperty: case Node::QmlProperty:
str = "qml-property-" + name(); str = "qml-property-" + name();

View File

@ -238,6 +238,7 @@ public:
virtual const ImportList* importList() const { return 0; } virtual const ImportList* importList() const { return 0; }
virtual void setImportList(const ImportList& ) { } virtual void setImportList(const ImportList& ) { }
virtual const Node* applyModuleIdentifier(const Node* ) const { return 0; } virtual const Node* applyModuleIdentifier(const Node* ) const { return 0; }
virtual QString idNumber() { return "0"; }
QmlClassNode* qmlClassNode(); QmlClassNode* qmlClassNode();
ClassNode* declarativeCppNode(); ClassNode* declarativeCppNode();
const QString& outputSubdirectory() const { return outSubDir_; } const QString& outputSubdirectory() const { return outSubDir_; }
@ -251,6 +252,8 @@ public:
static QString pageTypeString(unsigned t); static QString pageTypeString(unsigned t);
static QString nodeTypeString(unsigned t); static QString nodeTypeString(unsigned t);
static QString nodeSubtypeString(unsigned t); static QString nodeSubtypeString(unsigned t);
static int incPropertyGroupCount();
static void clearPropertyGroupCount();
protected: protected:
Node(Type type, InnerNode* parent, const QString& name); Node(Type type, InnerNode* parent, const QString& name);
@ -288,6 +291,7 @@ private:
QString qmlModuleName_; QString qmlModuleName_;
QString qmlModuleVersion_; QString qmlModuleVersion_;
static QStringMap operators_; static QStringMap operators_;
static int propertyGroupCount_;
}; };
class FunctionNode; class FunctionNode;
@ -563,28 +567,18 @@ class QmlPropGroupNode : public FakeNode
{ {
public: public:
QmlPropGroupNode(QmlClassNode* parent, const QString& name); QmlPropGroupNode(QmlClassNode* parent, const QString& name);
//bool attached);
virtual ~QmlPropGroupNode() { } virtual ~QmlPropGroupNode() { }
virtual bool isQmlNode() const { return true; } virtual bool isQmlNode() const { return true; }
virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); }
virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); }
virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); }
virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); }
virtual QString idNumber();
const QString& element() const { return parent()->name(); } 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: private:
bool isdefault_; int idNumber_;
bool attached_;
int readOnly_;
#endif
}; };
class QmlPropertyNode; class QmlPropertyNode;