summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
diff options
context:
space:
mode:
authorGerhard Gappmeier <gerhard.gappmeier@ascolab.com>2012-07-02 13:01:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-19 17:36:55 +0100
commit9bbebb914422262b7b585b6d1dab9d21c4238c44 (patch)
tree65a87988bb8d2d8bae3e81bbff2dce480f436435 /src/tools/moc/moc.cpp
parent6f225b0b5d774828df310948435f1cc3a4720104 (diff)
Add support for defining properties from member variables.
This associates properties with member variables and avoids writing getter and setter methods manually. The metaCall() method directly accesses the member variable, so additional method calls can be avoided. The metaCall() setter code also supports NOTIFY signals, which means the according signal is emitted when the property gets written. Task-number: QTBUG-16852 Change-Id: I88a1f237ea53a1e9cf65fc9ef2e207718eb8b6c3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r--src/tools/moc/moc.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 5fbbd57c22..788033800f 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1059,6 +1059,12 @@ void Moc::createPropertyDef(PropertyDef &propDef)
v2 = "()";
}
switch (l[0]) {
+ case 'M':
+ if (l == "MEMBER")
+ propDef.member = v;
+ else
+ error(2);
+ break;
case 'R':
if (l == "READ")
propDef.read = v;
@@ -1099,11 +1105,11 @@ void Moc::createPropertyDef(PropertyDef &propDef)
error(2);
}
}
- if (propDef.read.isNull()) {
+ if (propDef.read.isNull() && propDef.member.isNull()) {
QByteArray msg;
msg += "Property declaration ";
msg += propDef.name;
- msg += " has no READ accessor function. The property will be invalid.";
+ msg += " has no READ accessor function or associated MEMBER variable. The property will be invalid.";
warning(msg.constData());
}
if (propDef.constant && !propDef.write.isNull()) {
@@ -1515,7 +1521,7 @@ void Moc::checkProperties(ClassDef *cdef)
//
for (int i = 0; i < cdef->propertyList.count(); ++i) {
PropertyDef &p = cdef->propertyList[i];
- if (p.read.isEmpty())
+ if (p.read.isEmpty() && p.member.isEmpty())
continue;
for (int j = 0; j < cdef->publicList.count(); ++j) {
const FunctionDef &f = cdef->publicList.at(j);