summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-08-25 23:35:56 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-08-26 04:33:49 +0200
commitb15e532fc664d4c5d91095bb22093a68e3bdfd39 (patch)
tree6ff325651181e9082bf047326d873e07c0e77470 /scripts
parent5392c0a8ce5545783c86d830e8c321d487538613 (diff)
Add subsetted property adjustment for single-valued properties
Change-Id: Ibea136f1eeccc8a1f3e9dcb1e86cab111daf3c9c Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/templates/class.cpp37
-rw-r--r--scripts/templates/class.h12
2 files changed, 39 insertions, 10 deletions
diff --git a/scripts/templates/class.cpp b/scripts/templates/class.cpp
index c5a0229c..09a06b39 100644
--- a/scripts/templates/class.cpp
+++ b/scripts/templates/class.cpp
@@ -144,7 +144,6 @@ Q${namespace}${className}::${qtAttribute}() const
[%- END %]
}
[%- SET attributeName = attribute.findvalue("@name").ucfirst %]
- [%- IF attribute.findvalue("@isReadOnly") != "true" -%]
[%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
void Q${namespace}${className}::add${attributeName}(${QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*')}${qtAttribute})
@@ -197,11 +196,43 @@ void Q${namespace}${className}::set${attributeName.remove("^Is")}(${QT_TYPE(name
}
[%- ELSE %]
if (_${qtAttribute} != ${qtAttribute}) {
+ [%- found = "false" -%]
+ [%- FOREACH subsettedPropertyName = attribute.findvalue("@subsettedProperty").split(" ") -%]
+ [%- SET subsettedProperty = xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${subsettedPropertyName.split('-').0}\"]/ownedAttribute[@name=\"${subsettedPropertyName.split('-').1}\"]") -%]
+ [%- IF subsettedProperty.findvalue("@name") != "" -%]
+ [%- IF found == "false" %]
+ // Adjust subsetted properties
+ [%- found = "true" -%]
+ [%- END -%]
+ [%- IF subsettedProperty.findvalue("upperValue/@value") == "*" %]
+ remove${subsettedPropertyName.split('-').1.ucfirst}(_${qtAttribute});
+ [%- END -%]
+ [%- END %]
+ [%- END %]
+[%- IF found == "true" %]
+[% END %]
_${qtAttribute} = ${qtAttribute};
+ [%- found = "false" -%]
+ [%- FOREACH subsettedPropertyName = attribute.findvalue("@subsettedProperty").split(" ") -%]
+ [%- SET subsettedProperty = xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${subsettedPropertyName.split('-').0}\"]/ownedAttribute[@name=\"${subsettedPropertyName.split('-').1}\"]") -%]
+ [%- IF subsettedProperty.findvalue("@name") != "" -%]
+ [%- IF found == "false" %]
+
+ // Adjust subsetted properties
+ [%- found = "true" -%]
+ [%- END -%]
+ [%- IF subsettedProperty.findvalue("upperValue/@value") == "*" %]
+ if (${qtAttribute}) {
+ add${subsettedPropertyName.split('-').1.ucfirst}(${qtAttribute});
+ }
+ [%- ELSE %]
+ set${subsettedPropertyName.split('-').1.ucfirst}(${qtAttribute});
+ [%- END -%]
+ [%- END %]
+ [%- END %]
}
- [%- END %]
-}
[%- END %]
+}
[%- END %]
[%- END %]
[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
diff --git a/scripts/templates/class.h b/scripts/templates/class.h
index a7312309..999f087c 100644
--- a/scripts/templates/class.h
+++ b/scripts/templates/class.h
@@ -99,13 +99,11 @@ public:
[% QT_TYPE(namespace, attribute) -%]
[%- QT_ATTRIBUTE(attribute) -%]() const;
[%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
- [%- IF attribute.findvalue("@isReadOnly") != "true" -%]
- [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
- void add${attributeName}([% QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %][% QT_ATTRIBUTE(attribute) %]);
- void remove${attributeName}([% QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %][% QT_ATTRIBUTE(attribute) %]);
- [%- ELSE %]
- void set${attributeName.remove("^Is")}([% QT_TYPE(namespace, attribute) %][% QT_ATTRIBUTE(attribute) %]);
- [%- END %]
+ [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" %]
+ [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void add${attributeName}([% QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %][% QT_ATTRIBUTE(attribute) %]);
+ [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void remove${attributeName}([% QT_TYPE(namespace, attribute).remove("QSet<").remove("QList<").replace("> ", " ").replace('\* $', '*') %][% QT_ATTRIBUTE(attribute) %]);
+ [%- ELSE %]
+ [% IF attribute.findvalue("@isReadOnly") == "true" -%]Q_DECL_HIDDEN [% END %]void set${attributeName.remove("^Is")}([% QT_TYPE(namespace, attribute) %][% QT_ATTRIBUTE(attribute) %]);
[%- END %]
[%- IF loop.last %]
[%- END %]