From b0f445a1526fa43563522d865c5ad1546201003c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 29 Apr 2020 15:08:53 +0200 Subject: Add support for QNotifiedProperty to the moc Change the meaning of Q_PRIVATE_QPROPERTY to imply that the property is implemented using a QNotifiedProperty. That requires passing the owner object instance to the value and binding setters. Similarly, detect QNotifiedProperty members like QProperty. Change-Id: If49bbb04c8ccd4a661973888c50d2d556c25034f Reviewed-by: Ulf Hermann --- tests/auto/tools/moc/tst_moc.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/auto/tools/moc') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 37d3cc130f..4a6d16b45a 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -4116,19 +4116,20 @@ class ClassWithQPropertyMembers : public QObject Q_PROPERTY(int privateExposedProperty) public: - QProperty publicProperty; - QProperty notExposed; - signals: void publicPropertyChanged(); +public: + QNotifiedProperty publicProperty; + QProperty notExposed; + + protected: QProperty protectedProperty; private: QProperty privateProperty; QProperty privateExposedProperty; - QPropertyMemberChangeHandler<&ClassWithQPropertyMembers::publicProperty, &ClassWithQPropertyMembers::publicPropertyChanged> connector{this}; }; void tst_Moc::qpropertyMembers() @@ -4151,7 +4152,7 @@ void tst_Moc::qpropertyMembers() QSignalSpy publicPropertySpy(&instance, SIGNAL(publicPropertyChanged())); - instance.publicProperty.setValue(100); + instance.publicProperty.setValue(&instance, 100); QCOMPARE(prop.read(&instance).toInt(), 100); QCOMPARE(publicPropertySpy.count(), 1); @@ -4182,9 +4183,9 @@ void tst_Moc::observerMetaCall() instance.qt_metacall(QMetaObject::RegisterQPropertyObserver, prop.propertyIndex(), argv); } - instance.publicProperty.setValue(100); + instance.publicProperty.setValue(&instance, 100); QCOMPARE(observerCallCount, 1); - instance.publicProperty.setValue(101); + instance.publicProperty.setValue(&instance, 101); QCOMPARE(observerCallCount, 2); } @@ -4235,9 +4236,8 @@ public: ClassWithPrivateQPropertyShim *q = nullptr; - QProperty testProperty; void onTestPropertyChanged() { q->testPropertyChanged(); } - QPropertyMemberChangeHandler<&Private::testProperty, &Private::onTestPropertyChanged> testChangeHandler{this}; + QNotifiedProperty testProperty; }; Private priv{this}; @@ -4257,7 +4257,7 @@ void tst_Moc::privateQPropertyShim() QVERIFY(prop.notifySignal().isValid()); } - testObject.priv.testProperty.setValue(42); + testObject.priv.testProperty.setValue(&testObject.priv, 42); QCOMPARE(testObject.property("testProperty").toInt(), 42); // Behave like a QProperty -- cgit v1.2.3