summaryrefslogtreecommitdiffstats
path: root/scripts/templates
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-10-10 17:08:35 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-10-10 22:08:50 +0200
commit8c4add8a61b9eeda682f84cca7f99a3f0181726d (patch)
tree6dbff0f3bb03da451147aac6268799b757c51d66 /scripts/templates
parentdc76a0dc87fe7ee0f94e96881990a4e83911fd8e (diff)
Further refactoring in QtModeling (step 2)
Change-Id: I336f9f24af1c763883e9cc3c716c02ef557bebd1 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/templates')
-rw-r--r--scripts/templates/common.tmpl51
-rw-r--r--scripts/templates/module.pro2
-rw-r--r--scripts/templates/qclass.cpp75
-rw-r--r--scripts/templates/qclass.h12
-rw-r--r--scripts/templates/qobjectclass.cpp52
-rw-r--r--scripts/templates/qobjectclass_p.h13
6 files changed, 106 insertions, 99 deletions
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl
index a9d5089c..544558ce 100644
--- a/scripts/templates/common.tmpl
+++ b/scripts/templates/common.tmpl
@@ -243,16 +243,16 @@ ${parameter.findvalue("@name")}
{
[%- IF qtType.match("QList|QSet") && !qtType.match("QString") %]
${qtType}[% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
- foreach (Q${originalQtType.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}())
- [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF qtType.match("QList") %]append[% ELSE %]insert[% END %](element->asQObject());
+ foreach (Q${originalQtType.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}())
+ [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF qtType.match("QList") %]append[% ELSE %]insert[% END %](element->asQModelingObject());
return [% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
[%- ELSIF qtType.match('\*$') %]
- if (!qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}())
+ if (!qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}())
return 0;
else
- return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}()->asQObject();
+ return qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}()->asQModelingObject();
[%- ELSE %]
- return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}();
+ return qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${PLURALFORM(qtAttribute, attribute)}();
[%- END %]
}
@@ -291,31 +291,31 @@ ${parameter.findvalue("@name")}
[%- IF QT_TYPE(namespace, parameter, "true").match("QList|QSet") %]
${QT_TYPE(namespace, parameter, "true")}${parameter.findvalue("@name")}Converted;
foreach (QObject *object, ${parameter.findvalue("@name")})
- ${parameter.findvalue("@name")}Converted.[% IF QT_TYPE(namespace, parameter, "true").match("QList") %]append[% ELSE %]insert[% END %](qmodelingobjectproperty_cast<${QT_TYPE(namespace, parameter, "true").remove("QList<").remove("QSet<").remove(">").trim}>(object));
+ ${parameter.findvalue("@name")}Converted.[% IF QT_TYPE(namespace, parameter, "true").match("QList") %]append[% ELSE %]insert[% END %](qmodelingelementproperty_cast<${QT_TYPE(namespace, parameter, "true").remove("QList<").remove("QSet<").remove(">").trim}>(object));
[%- END -%]
[%- END -%]
[%- IF return.match("QList|QSet") && return.match('\*') %]
${return}[% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
- foreach (${originalReturn.remove("QList<").remove("QSet<").remove(">").trim}element, qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
+ foreach (${originalReturn.remove("QList<").remove("QSet<").remove(">").trim}element, qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
[%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
[%- qtType = QT_TYPE(namespace, parameter, "true") -%]
[%- IF qtType.match('QList|QSet') -%]
${parameter.findvalue("@name")}Converted
[%- ELSIF qtType.match('\*$') -%]
-qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
+qmodelingelementproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
[%- ELSE -%]
${parameter.findvalue("@name")}
[%- END -%]
[%- IF !loop.last %], [% END -%]
[%- END -%]))
- [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF return.match("QList") %]append[% ELSE %]insert[% END %](element->asQObject());
+ [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF return.match("QList") %]append[% ELSE %]insert[% END %](element->asQModelingObject());
return [% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
[%- ELSIF !return.match("QList|QSet") && return.match('\*$') %]
- if (!qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
+ if (!qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
[%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
[%- qtType = QT_TYPE(namespace, parameter, "true") -%]
[%- IF qtType.match('\*$') -%]
-qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
+qmodelingelementproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
[%- ELSE -%]
${parameter.findvalue("@name")}
[%- END -%]
@@ -323,22 +323,22 @@ ${parameter.findvalue("@name")}
[%- END -%]))
return 0;
else
- return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
+ return qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
[%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
[%- qtType = QT_TYPE(namespace, parameter, "true") -%]
[%- IF qtType.match('\*$') -%]
-qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
+qmodelingelementproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
[%- ELSE -%]
${parameter.findvalue("@name")}
[%- END -%]
[%- IF !loop.last %], [% END -%]
- [%- END -%])->asQObject();
+ [%- END -%])->asQModelingObject();
[%- ELSE %]
- return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
+ return qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
[%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
[%- qtType = QT_TYPE(namespace, parameter, "true") -%]
[%- IF qtType.match('\*$') -%]
-qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
+qmodelingelementproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
[%- ELSE -%]
${parameter.findvalue("@name")}
[%- END -%]
@@ -380,9 +380,9 @@ void Q${namespace}${originalClassName}Object::add${attributeName}(${originalQtTy
[%- END %]
{
[%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
- qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(qmodelingobjectproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute}));
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(qmodelingelementproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute}));
[%- ELSE %]
- qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(${qtAttribute});
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(${qtAttribute});
[%- END %]
}
@@ -393,29 +393,30 @@ void Q${namespace}${originalClassName}Object::remove${attributeName}(${originalQ
[%- END %]
{
[%- 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}));
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(qmodelingelementproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute}));
[%- ELSE %]
- qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(${qtAttribute});
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(${qtAttribute});
[%- 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}));
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName}(qmodelingelementproperty_cast<${originalQtType}>(${qtAttribute}));
}
[%- ELSE %]
void Q${namespace}${originalClassName}Object::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
{
- qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName.remove("^Is")}(${qtAttribute});
+ qmodelingelementproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName.remove("^Is")}(${qtAttribute});
}
[%- END -%]
[%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %]
void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").ucfirst}()
{
- qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->modifiedResettableProperties().removeAll(QStringLiteral("${attributeName.remove("^Is").lcfirst}"));
+ Q_D(QModelingObject);
+ d->modifiedResettableProperties.removeAll(QStringLiteral("${attributeName.remove("^Is").lcfirst}"));
}
[%- END -%]
@@ -479,12 +480,12 @@ void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").u
[%- END -%]
[%- SET className = class.findvalue("@name") %]
- _propertyGroups << QStringLiteral("Q${namespace}${className}");
+ d->propertyGroups << QStringLiteral("Q${namespace}${className}");
[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
[%- SET qtType = QT_TYPE(namespace, attribute) -%]
[%- SET attributeName = attribute.findvalue("@name") -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
[%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 %]
- _groupProperties.insert(QStringLiteral("Q${namespace}${className}"), new QMetaProperty(metaObject->property(metaObject->indexOfProperty("${PLURALFORM(qtAttribute, attribute)}"))));
+ d->groupProperties.insert(QStringLiteral("Q${namespace}${className}"), new QMetaProperty(metaObject->property(metaObject->indexOfProperty("${PLURALFORM(qtAttribute, attribute)}"))));
[%- END %]
[%- END -%] \ No newline at end of file
diff --git a/scripts/templates/module.pro b/scripts/templates/module.pro
index eae886f1..01f3ee9e 100644
--- a/scripts/templates/module.pro
+++ b/scripts/templates/module.pro
@@ -1,7 +1,7 @@
load(qt_build_config)
TARGET = Qt${namespace}
-QT = core modeling
+QT = core-private modeling-private
QMAKE_DOCS = [%- GET '$$PWD' -%]/doc/qt${namespace.lower}.qdocconf
diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp
index c04d163a..3b9d5429 100644
--- a/scripts/templates/qclass.cpp
+++ b/scripts/templates/qclass.cpp
@@ -67,7 +67,7 @@
\brief ${class.findvalue("ownedComment/body/text()")}
*/
-Q${namespace}${className}::Q${namespace}${className}([%- IF class.findvalue("@isAbstract") != "true" %]bool createQObject[% END %])
+Q${namespace}${className}::Q${namespace}${className}([%- IF class.findvalue("@isAbstract") != "true" %]bool createQModelingObject[% END %])
[%- SET found = "false" -%]
[%- FOREACH superclass IN generalization -%]
[%- SET superclassName = superclass.findvalue('@general') -%]
@@ -118,25 +118,23 @@ Q${namespace}${className}::Q${namespace}${className}([%- IF class.findvalue("@is
[%- END %]
{
[%- IF class.findvalue("@isAbstract") != "true" %]
- if (createQObject)
- _qObject = new Q${namespace}${className}Object(this);
+ if (createQModelingObject)
+ _qModelingObject = qobject_cast<QModelingObject *>(new Q${namespace}${className}Object(this));
[%- END %]
- setGroupProperties();
- setPropertyData();
}
Q${namespace}${className}::~Q${namespace}${className}()
{
[%- IF class.findvalue("@isAbstract") != "true" %]
- if (!deletingFromQObject) {
- if (_qObject)
- _qObject->setProperty("deletingFromModelingObject", true);
- delete _qObject;
+ if (!deletingFromQModelingObject) {
+ if (_qModelingObject)
+ _qModelingObject->setProperty("deletingFromModelingObject", true);
+ delete _qModelingObject;
}
[%- END %]
}
-QModelingObject *Q${namespace}${className}::clone() const
+QModelingElement *Q${namespace}${className}::clone() const
{
Q${namespace}${className} *c = new Q${namespace}${className};
[%- visitedClasses = [] -%]
@@ -197,10 +195,10 @@ void Q${namespace}${className}::add${attributeName}(${qtType.remove("QSet<").rem
if (!_${PLURALFORM(qtAttribute, attribute)}.contains(${qtAttribute})) {
_${PLURALFORM(qtAttribute, attribute)}.[% IF qtType.match("QList") %]append[% ELSE %]insert[% END %](${qtAttribute});
[%- IF qtType.match('\*') %]
- if (${qtAttribute} && ${qtAttribute}->asQObject() && this->asQObject())
- QObject::connect(${qtAttribute}->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(remove${attributeName}(QObject *)));
+ if (${qtAttribute} && ${qtAttribute}->asQModelingObject() && this->asQModelingObject())
+ QObject::connect(${qtAttribute}->asQModelingObject(), SIGNAL(destroyed(QObject*)), this->asQModelingObject(), SLOT(remove${attributeName}(QObject *)));
[%- IF attribute.findvalue("@aggregation") == "composite" %]
- ${qtAttribute}->asQObject()->setParent(this->asQObject());
+ ${qtAttribute}->asQModelingObject()->setParent(this->asQModelingObject());
[%- END -%]
[%- END %]
[%- END %]
@@ -258,8 +256,8 @@ void Q${namespace}${className}::remove${attributeName}(${qtType.remove("QSet<").
if (_${PLURALFORM(qtAttribute, attribute)}.contains(${qtAttribute})) {
_${PLURALFORM(qtAttribute, attribute)}.[% IF qtType.match("QList") %]removeAll[% ELSE %]remove[% END %](${qtAttribute});
[%- IF attribute.findvalue("@aggregation") == "composite" %]
- if (${qtAttribute}->asQObject())
- ${qtAttribute}->asQObject()->setParent(0);
+ if (${qtAttribute}->asQModelingObject())
+ ${qtAttribute}->asQModelingObject()->setParent(0);
[%- END -%]
[%- END %]
[%- found = "false" -%]
@@ -335,13 +333,13 @@ void Q${namespace}${className}::set${attributeName.remove("^Is")}([% IF !qtType.
[%- ELSE %]
_${PLURALFORM(qtAttribute, attribute)} = ${qtAttribute};
[%- IF attribute.findvalue("defaultValue/@xmi:type") != "" %]
- _modifiedResettableProperties << QStringLiteral("${attributeName.lcfirst}");
+ _qModelingObject->modifiedResettableProperties() << QStringLiteral("${attributeName.lcfirst}");
[%- END %]
[%- IF qtType.match('\*') %]
- if (${qtAttribute} && ${qtAttribute}->asQObject() && this->asQObject())
- QObject::connect(${qtAttribute}->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(set${attributeName}()));
+ if (${qtAttribute} && ${qtAttribute}->asQModelingObject() && this->asQModelingObject())
+ QObject::connect(${qtAttribute}->asQModelingObject(), SIGNAL(destroyed()), this->asQModelingObject(), SLOT(set${attributeName}()));
[%- IF attribute.findvalue("@aggregation") == "composite" %]
- ${qtAttribute}->asQObject()->setParent(this->asQObject());
+ ${qtAttribute}->asQModelingObject()->setParent(this->asQModelingObject());
[%- END -%]
[%- END %]
[%- END %]
@@ -404,42 +402,3 @@ ${parameter.findvalue("@name")}
}
[%- END %]
-void Q${namespace}${className}::setGroupProperties()
-{
- const QMetaObject *metaObject = _qObject->metaObject();
-
- _propertyGroups << QStringLiteral("QObject");
- _groupProperties.insert(QStringLiteral("QObject"), new QMetaProperty(metaObject->property(metaObject->indexOfProperty("objectName"))));
-[%- visitedClasses = [] -%]
-[%- SET_GROUP_PROPERTIES(class, visitedClasses, redefinedProperties) %]
-}
-
-void Q${namespace}${className}::setPropertyData()
-{
-[%- FOREACH attribute = class.findnodes("ownedAttribute") -%]
-[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
-[%- SET association = attribute.findvalue("@association") -%]
-[%- IF attribute.findvalue("@aggregation") == "composite" %]
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::AggregationRole] = QStringLiteral("composite");
-[%- ELSE %]
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::AggregationRole] = QStringLiteral("none");
-[%- END %]
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::PropertyClassRole] = QStringLiteral("Q${namespace}${className}");
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::IsDerivedRole] = [% IF attribute.findvalue("@isDerived") == "true" %]true[% ELSE %]false[% END %];
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::IsDerivedUnionRole] = [% IF attribute.findvalue("@isDerivedUnion") == "true" %]true[% ELSE %]false[% END %];
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::DocumentationRole] = QStringLiteral("${attribute.findvalue("ownedComment/body/text()")}");
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::RedefinedPropertiesRole] = QStringLiteral("${attribute.findvalue("@redefinedProperty")}");
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::SubsettedPropertiesRole] = QStringLiteral("${attribute.findvalue("@subsettedProperty")}");
- QModelingObject::propertyDataHash[QStringLiteral("Q${namespace}${className}")][QStringLiteral("${PLURALFORM(qtAttribute, attribute)}")][QtModeling::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 %]
-}
-
diff --git a/scripts/templates/qclass.h b/scripts/templates/qclass.h
index 58953164..f725a0ed 100644
--- a/scripts/templates/qclass.h
+++ b/scripts/templates/qclass.h
@@ -54,7 +54,7 @@
[% END -%]
[%- END -%]
[%- IF superclasses.size == 0 -%]
-#include <QtModeling/QModelingObject>
+#include <QtModeling/QModelingElement>
[% END -%]
[%- SET useNamespace = 'false' -%]
@@ -70,7 +70,6 @@
[%- IF useNamespace == 'true' %]
#include <Qt${namespace}/Qt${namespace}Namespace>
[% END -%]
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -89,16 +88,16 @@ public Q${namespace}${superclass.findvalue("@general")}
[%- IF !loop.last %], [% END -%]
[%- END -%]
[%- IF superclasses.size == 0 -%]
-public QModelingObject
+public QModelingElement
[%- END %]
{
public:
[%- IF class.findvalue("@isAbstract") != "true" %]
- explicit Q${namespace}${className}(bool createQObject = true);
+ explicit Q${namespace}${className}(bool createQModelingObject = true);
[%- END %]
virtual ~Q${namespace}${className}();
- [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% END %]QModelingObject *clone() const;
+ [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% END %]virtual QModelingElement *clone() const;
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
[%- IF loop.first %]
// Owned attributes
@@ -140,9 +139,6 @@ protected:
[%- FOREACH attribute = class.findnodes("ownedAttribute[(@isDerived=\"false\" or not(@isDerived)) or (@isDerivedUnion and @isDerivedUnion=\"true\")]") %]
[% QT_TYPE(namespace, attribute) -%]_[%- PLURALFORM(QT_ATTRIBUTE(attribute), attribute) %];
[%- END %]
-
- virtual void setGroupProperties();
- virtual void setPropertyData();
};
QT_END_NAMESPACE
diff --git a/scripts/templates/qobjectclass.cpp b/scripts/templates/qobjectclass.cpp
index 2142a4de..2fb157f8 100644
--- a/scripts/templates/qobjectclass.cpp
+++ b/scripts/templates/qobjectclass.cpp
@@ -40,6 +40,7 @@
**
****************************************************************************/
#include "q${namespace.lower}${className.lower}object_p.h"
+#include "private/qmodelingobject_p.h"
#include <Qt${namespace}/Q${namespace}${className}>
[% SET useNamespace = 'false' -%]
@@ -53,17 +54,19 @@
[%- END -%]
QT_BEGIN_NAMESPACE
-Q${namespace}${className}Object::Q${namespace}${className}Object(Q${namespace}${className} *qModelingObject)
+Q${namespace}${className}Object::Q${namespace}${className}Object(Q${namespace}${className} *modelingElement)
{
- setProperty("modelingObject", QVariant::fromValue(static_cast<QModelingObject *>(qModelingObject)));
+ setProperty("modelingElement", QVariant::fromValue(static_cast<QModelingElement *>(modelingElement)));
+ setGroupProperties();
+ setPropertyData();
}
[%- IF class.findvalue("@isAbstract") != "true" %]
Q${namespace}${className}Object::~Q${namespace}${className}Object()
{
if (!property("deletingFromModelingObject").isValid()) {
- qmodelingobjectproperty_cast<Q${namespace}${className} *>(this)->deletingFromQObject = true;
- delete qmodelingobjectproperty_cast<QUmlComment *>(this);
+ qmodelingelementproperty_cast<Q${namespace}${className} *>(this)->deletingFromQModelingObject = true;
+ delete qmodelingelementproperty_cast<QUmlComment *>(this);
}
}
@@ -81,5 +84,46 @@ Q${namespace}${className}Object::~Q${namespace}${className}Object()
[%- GENERATE_CPP_OPERATIONS(originalClassName, class, visitedClasses, redefinedOperations) -%]
[%- visitedClasses = [] %]
[%- GENERATE_CPP_SLOTS(originalClassName, class, visitedClasses, redefinedProperties) -%]
+
+void Q${namespace}${className}Object::setGroupProperties()
+{
+ Q_D(QModelingObject);
+ const QMetaObject *metaObject = this->metaObject();
+
+ d->propertyGroups << QStringLiteral("QObject");
+ d->groupProperties.insert(QStringLiteral("QObject"), new QMetaProperty(metaObject->property(metaObject->indexOfProperty("objectName"))));
+[%- visitedClasses = [] -%]
+[%- SET_GROUP_PROPERTIES(class, visitedClasses, redefinedProperties) %]
+}
+
+void Q${namespace}${className}Object::setPropertyData()
+{
+[%- 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 %]
+}
+
QT_END_NAMESPACE
diff --git a/scripts/templates/qobjectclass_p.h b/scripts/templates/qobjectclass_p.h
index e41ac90f..e2956b0f 100644
--- a/scripts/templates/qobjectclass_p.h
+++ b/scripts/templates/qobjectclass_p.h
@@ -44,7 +44,7 @@
#include <Qt${namespace}/Qt${namespace}Global>
-#include <QtCore/QObject>
+#include <QtModeling/QModelingObject>
[% useNamespace = [] -%]
[%- forwards = [] -%]
[%- visitedClasses = [] -%]
@@ -60,9 +60,12 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Qt${namespace})
class Q${namespace}${className};
-class Q_${namespace.upper}_EXPORT Q${namespace}${className}Object : public QObject
+class QModelingObjectPrivate;
+class Q_${namespace.upper}_EXPORT Q${namespace}${className}Object : public QModelingObject
{
Q_OBJECT
+ Q_DISABLE_COPY(Q${namespace}${className}Object)
+ Q_DECLARE_PRIVATE(QModelingObject)
[%- visitedClasses = [] -%]
[%- redefinedProperties = [] -%]
[%- POPULATE_REDEFINED_PROPERTIES(class, visitedClasses, redefinedProperties) -%]
@@ -70,7 +73,7 @@ class Q_${namespace.upper}_EXPORT Q${namespace}${className}Object : public QObje
[%- GENERATE_QPROPERTIES(class, visitedClasses, redefinedProperties) %]
public:
- [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% ELSE %]Q_INVOKABLE [% END %]explicit Q${namespace}${className}Object(Q${namespace}${className} *qModelingObject);
+ [% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% ELSE %]Q_INVOKABLE [% END %]explicit Q${namespace}${className}Object(Q${namespace}${className} *modelingElement);
[%- IF class.findvalue("@isAbstract") != "true" %]
virtual ~Q${namespace}${className}Object();
[%- END %]
@@ -84,6 +87,10 @@ public:
[%- visitedClasses = [] %]
public Q_SLOTS:[%- GENERATE_SLOTS(class, visitedClasses, redefinedProperties) %]
+
+protected:
+ virtual void setGroupProperties();
+ virtual void setPropertyData();
};
QT_END_NAMESPACE