diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-11 18:42:08 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-11 23:45:48 +0200 |
commit | 7f74cff83f818e740f144988a0b48403aad409fd (patch) | |
tree | b7ebe5df868dc3b548fcf3701e485b3f336c6fb8 /scripts/templates/common.tmpl | |
parent | 638f0ea794cc77875b2fc9448446fbc891e6962b (diff) |
Fix code generation for property metadata
Change-Id: Ib09020d2b44446f224623bbf0de8d19b710cc88b
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/templates/common.tmpl')
-rw-r--r-- | scripts/templates/common.tmpl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl index 544558ce..7d9d052f 100644 --- a/scripts/templates/common.tmpl +++ b/scripts/templates/common.tmpl @@ -488,4 +488,39 @@ void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").u [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 %] d->groupProperties.insert(QStringLiteral("Q${namespace}${className}"), new QMetaProperty(metaObject->property(metaObject->indexOfProperty("${PLURALFORM(qtAttribute, attribute)}")))); [%- END %] +[%- END -%] +[%- MACRO SET_PROPERTY_DATA(class, visitedClasses, redefinedProperties) BLOCK -%] +[%- FOREACH parent IN class.findnodes("generalization") -%] + [%- SET parentName = parent.findvalue("@general") -%] + [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%] + [%- visitedClasses.push("${parentName}") -%] + [%- SET_PROPERTY_DATA(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%] + [%- END -%] +[%- END -%] +[%- SET className = class.findvalue("@name") %] +[%- FOREACH attribute = class.findnodes("ownedAttribute") -%] +[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] +[%- SET association = attribute.findvalue("@association") -%] +[%- IF attribute.findvalue("@aggregation") == "composite" %] + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, AggregationRole, QStringLiteral("composite")); +[%- ELSE %] + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, AggregationRole, QStringLiteral("none")); +[%- END %] + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, PropertyClassRole, QStringLiteral("Q${namespace}${className}")); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, IsDerivedRole, [% IF attribute.findvalue("@isDerived") == "true" %]true[% ELSE %]false[% END %]); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, IsDerivedUnionRole, [% IF attribute.findvalue("@isDerivedUnion") == "true" %]true[% ELSE %]false[% END %]); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, DocumentationRole, QStringLiteral("${attribute.findvalue("ownedComment/body/text()")}")); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, RedefinedPropertiesRole, QStringLiteral("${attribute.findvalue("@redefinedProperty")}")); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, SubsettedPropertiesRole, QStringLiteral("${attribute.findvalue("@subsettedProperty")}")); + Q_DECLARE_METAPROPERTY_INFO(Q${namespace}${className}, ${PLURALFORM(qtAttribute, attribute)}, OppositeEndRole, QStringLiteral(" +[%- IF association != "" -%] +[%- FOREACH memberEnd = xmi.findvalue("//packagedElement[@xmi:type=\"uml:Association\" and @name=\"${association}\"]/@memberEnd").split(' ') -%] +[%- NEXT IF memberEnd == className.replace('$', "-${attribute.findvalue(\"@name\")}") -%] +[%- SET oppositeProperty = xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${memberEnd.split('-').0}\"]/ownedAttribute[@name=\"${memberEnd.split('-').1}\"]") -%] +[%- IF oppositeProperty.findvalue("@name") != "" -%]${oppositeProperty.findvalue("@xmi:id")}[%- END -%] +[%- END -%] +[%- END -%] +")); + +[%- END %] [%- END -%]
\ No newline at end of file |