diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-29 15:08:53 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-06-18 17:26:11 +0200 |
commit | b0f445a1526fa43563522d865c5ad1546201003c (patch) | |
tree | 2b5756a39eaabfa507b3052da9b21fce3cb9ba88 /tests | |
parent | 31d2804e7a777fa4a41e8011bae3279601b08ff3 (diff) |
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 <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
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<int> publicProperty; - QProperty<int> notExposed; - signals: void publicPropertyChanged(); +public: + QNotifiedProperty<int, &ClassWithQPropertyMembers::publicPropertyChanged> publicProperty; + QProperty<int> notExposed; + + protected: QProperty<int> protectedProperty; private: QProperty<int> privateProperty; QProperty<int> 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<int> testProperty; void onTestPropertyChanged() { q->testPropertyChanged(); } - QPropertyMemberChangeHandler<&Private::testProperty, &Private::onTestPropertyChanged> testChangeHandler{this}; + QNotifiedProperty<int, &Private::onTestPropertyChanged> 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 |