diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-03 18:50:38 -0400 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-04 00:51:35 +0200 |
commit | 501adbcfd644dd9417a89845516b91df2995443b (patch) | |
tree | a097ff35469e4773a55abf8313d216c66976f66c /scripts/templates | |
parent | bacf368c156cb5c50e3c72613f6be1a32d679657 (diff) |
Add support for dirty properties
Change-Id: Iad81cc3912f746542ad6dd25f0877343b0a97eea
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/templates')
-rw-r--r-- | scripts/templates/common.tmpl | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl index 2b968ee9..6ddab0bf 100644 --- a/scripts/templates/common.tmpl +++ b/scripts/templates/common.tmpl @@ -90,7 +90,7 @@ ${attributeName} [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%] [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%] [%- SET qtType = QT_TYPE(namespace, attribute, "false") %] - Q_PROPERTY(${qtType.trim} ${qtAttribute} READ ${qtAttribute}) + Q_PROPERTY(${qtType.trim} ${qtAttribute} READ ${qtAttribute}[% IF attribute.findvalue("defaultValue/@xmi:type") != "" %] RESET unset${qtAttribute.remove("^is").ucfirst}[% END %][% IF attribute.findvalue("@isDerived") == "true" and attribute.findvalue("@isDerivedUnion") != "true" %] STORED false[% END %]) [%- END %] [%- END -%] [%- MACRO GENERATE_ATTRIBUTES(class, visitedClasses, redefinedProperties) BLOCK -%] @@ -191,6 +191,9 @@ ${parameter.findvalue("@name")} void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]set${attributeName.remove("^Is")}(${qtType}${qtAttribute}); [%- END -%] [%- END -%] + [%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %] + void unset${qtAttribute.remove("^is").ucfirst}(); + [%- END -%] [%- END %] [%- END -%] [%- MACRO GENERATE_CPP_ATTRIBUTES(originalClassName, class, visitedClasses, redefinedProperties) BLOCK -%] @@ -364,31 +367,45 @@ void Q${namespace}${originalClassName}Object::add${attributeName}(${originalQtTy [%- END %] } - [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] + [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] void Q${namespace}${originalClassName}Object::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*') %]${qtAttribute}) - [%- ELSE %] + [%- ELSE %] void Q${namespace}${originalClassName}Object::remove${attributeName}(${originalQtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute}) - [%- END %] + [%- END %] { - [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] + [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %] qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(qmodelingobjectproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute})); - [%- ELSE %] + [%- ELSE %] qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(${qtAttribute}); - [%- END %] + [%- END %] } [%- ELSIF qtType.match('\*$') %] void Q${namespace}${originalClassName}Object::set${attributeName}(${qtType}${qtAttribute}) { qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName}(qmodelingobjectproperty_cast<${originalQtType}>(${qtAttribute})); +[%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %] + _modifiedResettableProperties << QStringLiteral("${attributeName.remove("^Is").lcfirst}"); +[%- END %] } [%- ELSE %] void Q${namespace}${originalClassName}Object::set${attributeName.remove("^Is")}(${qtType}${qtAttribute}) { qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName.remove("^Is")}(${qtAttribute}); +[%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %] + _modifiedResettableProperties << QStringLiteral("${attributeName.remove("^Is").lcfirst}"); +[%- END %] } - [% END -%] + + [%- END -%] + [%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %] +void unset${qtAttribute.remove("^is").ucfirst}() +{ + _modifiedResettableProperties.removeAll(QStringLiteral("${attributeName.remove("^Is").lcfirst}")); +} + + [%- END -%] [%- IF loop.last %] [% END -%] [%- END %] |