Revert "Revert "Add QObject::objectNameChanged(con... signal""

This reverts commit 9b17557f3b.

Justification: Temporary commit, see JIRA task.
Task-number: QTBUG-22985
Change-Id: I3df9eb5fdbdc133349dca5e192dcfcc9e758626c
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Alan Alpert 2011-12-20 17:23:31 +10:00 committed by Qt by Nokia
parent 8754bf03f5
commit cb9b7ceffb
4 changed files with 29 additions and 23 deletions

View File

@ -949,14 +949,21 @@ 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);
if (d->objectName != name) {
d->objectName = name;
if (d->declarativeData)
d->declarativeData->objectNameChanged(d->declarativeData, this);
emit objectNameChanged(d->objectName);
}
}
/*! \fn void QObject::objectNameChanged(const QString &objectName)
This signal is emitted after the object's name has been changed. The new object name is passed as \a objectName.
\sa QObject::objectName
*/
/*!
\fn bool QObject::isWidgetType() const

View File

@ -113,7 +113,7 @@ public:
class Q_CORE_EXPORT QObject
{
Q_OBJECT
Q_PROPERTY(QString objectName READ objectName WRITE setObjectName)
Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
Q_DECLARE_PRIVATE(QObject)
public:
@ -322,6 +322,7 @@ public:
Q_SIGNALS:
void destroyed(QObject * = 0);
void objectNameChanged(const QString &objectName);
public:
inline QObject *parent() const { return d_ptr->parent; }

View File

@ -3493,7 +3493,6 @@ void tst_QObject::isSignalConnected()
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()")));
#endif
QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69()));
@ -3548,7 +3547,6 @@ void tst_QObject::isSignalConnected()
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig55()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()")));
#endif
emit o.sig00();

View File

@ -1091,15 +1091,15 @@ void tst_Moc::invokable()
{
{
const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject;
QCOMPARE(mobj.methodCount(), 5);
QVERIFY(mobj.method(4).signature() == QByteArray("foo()"));
QCOMPARE(mobj.methodCount(), 6);
QVERIFY(mobj.method(5).signature() == QByteArray("foo()"));
}
{
const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 6);
QVERIFY(mobj.method(4).signature() == QByteArray("foo()"));
QVERIFY(mobj.method(5).signature() == QByteArray("bar()"));
QCOMPARE(mobj.methodCount(), 7);
QVERIFY(mobj.method(5).signature() == QByteArray("foo()"));
QVERIFY(mobj.method(6).signature() == QByteArray("bar()"));
}
}
@ -1107,23 +1107,23 @@ void tst_Moc::singleFunctionKeywordSignalAndSlot()
{
{
const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject;
QCOMPARE(mobj.methodCount(), 6);
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
QCOMPARE(mobj.methodCount(), 7);
QVERIFY(mobj.method(5).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(6).signature() == QByteArray("mySlot()"));
}
{
const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 6);
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
QCOMPARE(mobj.methodCount(), 7);
QVERIFY(mobj.method(5).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(6).signature() == QByteArray("mySlot()"));
}
{
const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 6);
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
QCOMPARE(mobj.methodCount(), 7);
QVERIFY(mobj.method(5).signature() == QByteArray("mySignal()"));
QVERIFY(mobj.method(6).signature() == QByteArray("mySlot()"));
}
}