summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-08-29 14:55:27 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-08-29 20:01:38 +0200
commit65c1353742f739bbb82df36fd11a0e2155ce4ff0 (patch)
treef295582c0e93f20d5cfd55a045d53f4fd86dda9a /scripts
parentf68bc8f2ece0d726480f7e084f17ae80cd307ad7 (diff)
Move attribute's mutators to slots
Change-Id: If7c4983c402347fe58407389baffd4fd9defc401 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/templates/qclass.cpp104
-rw-r--r--scripts/templates/qclass.h53
2 files changed, 87 insertions, 70 deletions
diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp
index 1894cb0c..6729a3d5 100644
--- a/scripts/templates/qclass.cpp
+++ b/scripts/templates/qclass.cpp
@@ -60,8 +60,8 @@ Q${namespace}${className}::Q${namespace}${className}(QObject *parent) :
{
}
-[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
- [%- IF loop.first %]
+[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
+ [%- IF loop.first -%]
// Owned attributes
[% END -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
@@ -94,58 +94,15 @@ Q${namespace}${className}::Q${namespace}${className}(QObject *parent) :
[%- END %]
}
- [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
- [%- IF readOnly == "false" || readOnly == "" -%]
- [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
- [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
- [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
-void Q${namespace}${className}::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
- [%- ELSE %]
-void Q${namespace}${className}::add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
- [%- END %]
-{
- ${namespace}${className}::add${attributeName}(${qtAttribute});
-}
-
- [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
-void Q${namespace}${className}::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
- [%- ELSE %]
-void Q${namespace}${className}::remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
- [%- END %]
-{
- ${namespace}${className}::remove${attributeName}(${qtAttribute});
-}
-
- [%- ELSE -%]
- [%- IF qtType.match('QList|QSet') %]
-void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute})
-{
- ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
-}
-
- [%- ELSIF qtType.match('\*$') %]
-void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
-{
- ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
-}
-
- [%- ELSE %]
-void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
-{
- ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
-}
+[%- IF loop.last %]
[% END -%]
- [%- END -%]
- [%- END %]
- [%- IF loop.last %]
- [%- END %]
-[%- END %]
+[%- END -%]
[% FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- IF loop.first -%]
// Operations
-[% END %]
+[% END -%]
[% SET operationName = operation.findvalue("@name") -%]
-[%- SET return = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") -%]
+[%- SET return = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") %]
[% return -%]
Q${namespace}${className}::${operationName}(
[%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
@@ -186,6 +143,55 @@ ${parameter.findvalue("@name")}
[%- IF loop.last %]
[% END -%]
+[%- END -%]
+[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
+ [%- IF loop.first -%]
+// Slots for owned attributes
+[% END -%]
+ [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
+ [%- IF readOnly == "false" || readOnly == "" -%]
+ [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
+ [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
+ [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
+void Q${namespace}${className}::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
+ [%- ELSE %]
+void Q${namespace}${className}::add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
+ [%- END %]
+{
+ ${namespace}${className}::add${attributeName}(${qtAttribute});
+}
+
+ [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
+void Q${namespace}${className}::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute})
+ [%- ELSE %]
+void Q${namespace}${className}::remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
+ [%- END %]
+{
+ ${namespace}${className}::remove${attributeName}(${qtAttribute});
+}
+
+ [%- ELSE -%]
+ [%- IF qtType.match('QList|QSet') %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
+
+ [%- ELSIF qtType.match('\*$') %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
+
+ [%- ELSE %]
+void Q${namespace}${className}::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
+{
+ ${namespace}${className}::set${attributeName.remove("^Is")}(${qtAttribute});
+}
[% END -%]
+ [%- END -%]
+ [%- END %]
+[%- END %]
QT_END_NAMESPACE
diff --git a/scripts/templates/qclass.h b/scripts/templates/qclass.h
index 88d3443e..a68631d0 100644
--- a/scripts/templates/qclass.h
+++ b/scripts/templates/qclass.h
@@ -100,27 +100,6 @@ public:
[%- ELSE %]
Q_INVOKABLE ${qtType}${qtAttribute}() const;
[%- END %]
- [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
- [%- IF readOnly == "false" || readOnly == "" -%]
- [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
- [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
- [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
- Q_INVOKABLE void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
- Q_INVOKABLE void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
- [%- ELSE %]
- Q_INVOKABLE void add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
- Q_INVOKABLE void remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
- [%- END -%]
- [%- ELSE -%]
- [%- IF qtType.match('QList|QSet') %]
- Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute});
- [%- ELSIF qtType.match('\*$') %]
- Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
- [%- ELSE %]
- Q_INVOKABLE void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
- [%- END -%]
- [%- END -%]
- [%- END %]
[%- IF loop.last %]
[%- END %]
[%- END -%]
@@ -139,6 +118,38 @@ ${parameter.findvalue("@name")}
[%- END -%]
)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %];
[%- END %]
+[%- FOREACH attribute IN attributes -%]
+ [%- IF loop.first %]
+
+public Q_SLOTS:
+ // Owned attributes
+ [%- END -%]
+ [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
+ [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
+ [%- SET readOnly = attribute.findvalue("@isReadOnly") %]
+ [%- IF readOnly == "false" || readOnly == "" -%]
+ [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
+ [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
+ [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
+ void add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
+ void remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*').remove('^Q') %]${qtAttribute});
+ [%- ELSE %]
+ void add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
+ void remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
+ [%- END -%]
+ [%- ELSE -%]
+ [%- IF qtType.match('QList|QSet') %]
+ void set${attributeName.remove("^Is")}(${qtType.remove('^Q')}${qtAttribute});
+ [%- ELSIF qtType.match('\*$') %]
+ void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
+ [%- ELSE %]
+ void set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
+ [%- END -%]
+ [%- END -%]
+ [%- END %]
+ [%- IF loop.last %]
+ [%- END %]
+[%- END %]
};
QT_END_NAMESPACE