summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp29
-rw-r--r--src/corelib/kernel/qmetaobject.h2
-rw-r--r--src/tools/moc/generator.cpp7
-rw-r--r--src/tools/moc/moc.cpp23
-rw-r--r--src/tools/moc/moc.h3
5 files changed, 61 insertions, 3 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 08cecaf..fee2da9 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -159,7 +159,9 @@ enum PropertyFlags {
ResolveEditable = 0x00080000,
User = 0x00100000,
ResolveUser = 0x00200000,
- Notify = 0x00400000
+ Notify = 0x00400000,
+ Dynamic = 0x00800000,
+ Constant = 0x00000400
};
enum MethodFlags {
@@ -2439,6 +2441,31 @@ bool QMetaProperty::isUser(const QObject *object) const
}
/*!
+ \internal
+*/
+bool QMetaProperty::isDynamic() const
+{
+ if (!mobj)
+ return false;
+ int flags = mobj->d.data[handle + 2];
+ return flags & Dynamic;
+}
+
+/*!
+ Returns true if the property is constant; otherwise returns false.
+
+ A property is constant if the \c{Q_PROPERTY()}'s \c CONSTANT attribute
+ is set.
+*/
+bool QMetaProperty::isConstant() const
+{
+ if (!mobj)
+ return false;
+ int flags = mobj->d.data[handle + 2];
+ return flags & Constant;
+}
+
+/*!
\obsolete
Returns true if the property is editable for the given \a object;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 000ba6e..73b52a9 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -187,6 +187,8 @@ public:
bool isStored(const QObject *obj = 0) const;
bool isEditable(const QObject *obj = 0) const;
bool isUser(const QObject *obj = 0) const;
+ bool isDynamic() const;
+ bool isConstant() const;
bool isFlagType() const;
bool isEnumType() const;
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index b872dfd..e4086e6 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -66,7 +66,9 @@ enum PropertyFlags {
ResolveEditable = 0x00080000,
User = 0x00100000,
ResolveUser = 0x00200000,
- Notify = 0x00400000
+ Notify = 0x00400000,
+ Dynamic = 0x00800000,
+ Constant = 0x00000400
};
enum MethodFlags {
AccessPrivate = 0x00,
@@ -597,6 +599,9 @@ void Generator::generateProperties()
if (p.notifyId != -1)
flags |= Notify;
+ if (p.constant)
+ flags |= Constant;
+
fprintf(out, " %4d, %4d, ",
strreg(p.name),
strreg(p.type));
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 797595f..66012ca 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -908,6 +908,12 @@ void Moc::parseProperty(ClassDef *def)
propDef.name = lexem();
while (test(IDENTIFIER)) {
QByteArray l = lexem();
+
+ if (l[0] == 'C' && l == "CONSTANT") {
+ propDef.constant = true;
+ continue;
+ }
+
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
@@ -963,6 +969,23 @@ void Moc::parseProperty(ClassDef *def)
msg += " has no READ accessor function. The property will be invalid.";
warning(msg.constData());
}
+ if (propDef.constant && !propDef.write.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+ if (propDef.constant && !propDef.notify.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
+ propDef.constant = false;
+ warning(msg.constData());
+ }
+
if(!propDef.notify.isEmpty())
def->notifyableProperties++;
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 9fa9ac2..494d53e 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -115,9 +115,10 @@ struct FunctionDef
struct PropertyDef
{
- PropertyDef():notifyId(-1), gspec(ValueSpec){}
+ PropertyDef():notifyId(-1), constant(false), gspec(ValueSpec){}
QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify;
int notifyId;
+ bool constant;
enum Specification { ValueSpec, ReferenceSpec, PointerSpec };
Specification gspec;
bool stdCppSet() const {