diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-08-29 11:43:17 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-09-02 22:44:29 +0200 |
commit | 91a24f6cd71f03b001dc6a0a8dba23efe744033d (patch) | |
tree | 5f191ba80c6a1c25a420e8d8f6f0d49d1fb06518 /src/corelib/kernel | |
parent | ad32ac5b4f05c9eed1fb7a93ee7947050d840a19 (diff) | |
download | qtbase-91a24f6cd71f03b001dc6a0a8dba23efe744033d.tar.gz |
Add setter/getter support in QBindableInterface
This is required to properly implement QPropertyAlias on
all properties.
Change-Id: I2443b52aa72116596fa0891e5f8b8414518dcd93
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qproperty.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 27ad20d51a..7ba2d9514a 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -611,11 +611,15 @@ namespace QtPrivate struct QBindableInterface { + using Getter = void (*)(const QUntypedPropertyData *d, void *value); + using Setter = void (*)(QUntypedPropertyData *d, const void *value); using BindingGetter = QUntypedPropertyBinding (*)(const QUntypedPropertyData *d); using BindingSetter = QUntypedPropertyBinding (*)(QUntypedPropertyData *d, const QUntypedPropertyBinding &binding); using MakeBinding = QUntypedPropertyBinding (*)(const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location); using SetObserver = void (*)(const QUntypedPropertyData *d, QPropertyObserver *observer); using GetMetaType = QMetaType (*)(); + Getter getter; + Setter setter; BindingGetter getBinding; BindingSetter setBinding; MakeBinding makeBinding; @@ -631,6 +635,9 @@ public: // interface for read-only properties. Those do not have a binding()/setBinding() method, but one can // install observers on them. static constexpr QBindableInterface iface = { + [](const QUntypedPropertyData *d, void *value) -> void + { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); }, + nullptr, nullptr, nullptr, [](const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location) -> QUntypedPropertyBinding @@ -647,6 +654,10 @@ class QBindableInterfaceForProperty<Property, std::void_t<decltype(std::declval< using T = typename Property::value_type; public: static constexpr QBindableInterface iface = { + [](const QUntypedPropertyData *d, void *value) -> void + { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); }, + [](QUntypedPropertyData *d, const void *value) -> void + { static_cast<Property *>(d)->setValue(*static_cast<const T*>(value)); }, [](const QUntypedPropertyData *d) -> QUntypedPropertyBinding { return static_cast<const Property *>(d)->binding(); }, [](QUntypedPropertyData *d, const QUntypedPropertyBinding &binding) -> QUntypedPropertyBinding |