diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 6336bd5c58..a0cdda4200 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -817,6 +817,12 @@ QString QPropertyBindingError::description() const goes out of scope, the callback is unsubscribed. */ +/*! + \fn template QtPrivate::QPropertyBase &QProperty::propertyBase() const + \internal +*/ + + /*! \class QNotifiedProperty \inmodule QtCore @@ -1041,6 +1047,12 @@ QString QPropertyBindingError::description() const goes out of scope, the callback is unsubscribed. */ +/*! + \fn template QtPrivate::QPropertyBase &QNotifiedProperty::propertyBase() const + \internal +*/ + + /*! \class QPropertyChangeHandler \inmodule QtCore diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 1c2aede856..c6be89e169 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -82,10 +82,6 @@ struct Q_CORE_EXPORT QPropertyBindingSourceLocation }; template class QPropertyChangeHandler; - -template class QProperty; -template class QNotifiedProperty; - class QPropertyBindingErrorPrivate; class Q_CORE_EXPORT QPropertyBindingError @@ -171,13 +167,9 @@ public: : QUntypedPropertyBinding(QMetaType::fromType(), BindingAdaptor{std::forward(f)}, location) {} - QPropertyBinding(const QProperty &property) - : QUntypedPropertyBinding(property.d.priv.binding()) - {} - - template - QPropertyBinding(const QNotifiedProperty &property) - : QUntypedPropertyBinding(property.d.priv.binding()) + template> + QPropertyBinding(const Property &property) + : QUntypedPropertyBinding(property.propertyBase().binding()) {} // Internal @@ -331,6 +323,7 @@ public: template QPropertyChangeHandler subscribe(Functor f); + const QtPrivate::QPropertyBase &propertyBase() const { return d.priv; } private: void notify() { @@ -339,9 +332,6 @@ private: Q_DISABLE_COPY(QProperty) - friend struct QPropertyBasePointer; - friend class QPropertyBinding; - friend class QPropertyObserver; // Mutable because querying for the value may require evalating the binding expression, calling // non-const functions on QPropertyBase. mutable QtPrivate::QPropertyValueStorage d; @@ -539,6 +529,7 @@ public: template QPropertyChangeHandler subscribe(Functor f); + const QtPrivate::QPropertyBase &propertyBase() const { return d.priv; } private: void notify(Class *owner, T *oldValue=nullptr) { @@ -553,8 +544,6 @@ private: Q_DISABLE_COPY_MOVE(QNotifiedProperty) - friend class QPropertyBinding; - friend class QPropertyObserver; // Mutable because querying for the value may require evalating the binding expression, calling // non-const functions on QPropertyBase. mutable QtPrivate::QPropertyValueStorage d; @@ -578,13 +567,9 @@ public: QPropertyObserver &operator=(QPropertyObserver &&other); ~QPropertyObserver(); - template - void setSource(const QProperty &property) - { setSource(property.d.priv); } - - template - void setSource(const QNotifiedProperty &property) - { setSource(property.d.priv); } + template().propertyBase()), QtPrivate::QPropertyBase &>>> + void setSource(const Property &property) + { setSource(property.propertyBase()); } protected: QPropertyObserver(void (*callback)(QPropertyObserver*, void *)); @@ -632,19 +617,8 @@ public: { } - template - QPropertyChangeHandler(const QProperty &property, Functor handler) - : QPropertyObserver([](QPropertyObserver *self, void *) { - auto This = static_cast*>(self); - This->m_handler(); - }) - , m_handler(handler) - { - setSource(property); - } - - template - QPropertyChangeHandler(const QNotifiedProperty &property, Functor handler) + template> + QPropertyChangeHandler(const Property &property, Functor handler) : QPropertyObserver([](QPropertyObserver *self, void *) { auto This = static_cast*>(self); This->m_handler(); diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 1ddb3dd453..9c43c23959 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -90,7 +90,7 @@ struct Q_AUTOTEST_EXPORT QPropertyBasePointer template static QPropertyBasePointer get(QProperty &property) { - return QPropertyBasePointer{&property.d.priv}; + return QPropertyBasePointer{&property.propertyBase()}; } };