summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-10-11 01:24:05 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-10-11 01:25:22 (GMT)
commitaa7fa8608939676ba56e130214b85f5d0c3745df (patch)
treeda8717795c420a5b4c6b74f9d14b69b76a15ec78
parent86cb952cdfbc7bade3edad29da028e3b3fe71083 (diff)
downloadQt-aa7fa8608939676ba56e130214b85f5d0c3745df.zip
Qt-aa7fa8608939676ba56e130214b85f5d0c3745df.tar.gz
Qt-aa7fa8608939676ba56e130214b85f5d0c3745df.tar.bz2
Add a declarative callback for when a QObject's objectName changes
Task-number: QTBUG-13999 Reviewed-by: Martin Jones
-rw-r--r--src/corelib/kernel/qobject.cpp6
-rw-r--r--src/corelib/kernel/qobject_p.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8330e47..579c225 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -127,6 +127,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0;
void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0;
+void (*QAbstractDeclarativeData::objectNameChanged)(QAbstractDeclarativeData *, QObject *) = 0;
QObjectData::~QObjectData() {}
@@ -1094,7 +1095,12 @@ QString QObject::objectName() const
void QObject::setObjectName(const QString &name)
{
Q_D(QObject);
+ bool objectNameChanged = d->declarativeData && d->objectName != name;
+
d->objectName = name;
+
+ if (objectNameChanged)
+ d->declarativeData->objectNameChanged(d->declarativeData, this);
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 4800e6a..814769c 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -89,6 +89,7 @@ class Q_CORE_EXPORT QAbstractDeclarativeData
public:
static void (*destroyed)(QAbstractDeclarativeData *, QObject *);
static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *);
+ static void (*objectNameChanged)(QAbstractDeclarativeData *, QObject *);
};
class Q_CORE_EXPORT QObjectPrivate : public QObjectData