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);
fullTitle = marker->plainFullName(inner);
title = rawTitle + " Element";
Node::clearPropertyGroupCount();
generateHeader(inner, fullTitle);
generateBrief(inner, marker); // <shortdesc>
@ -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(); // </apiName>
@ -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(); // </apiName>
@ -4908,8 +4915,6 @@ void DitaXmlGenerator::writeFunctions(const Section& s,
if ((*m)->type() == Node::Function) {
FunctionNode* fn = const_cast<FunctionNode*>(static_cast<const FunctionNode*>(*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");

View File

@ -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<Node*>(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();
if (str.endsWith(".html"))
str.remove(str.size()-5,5);
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;
}
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();

View File

@ -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;