7#include <private/qqmlanybinding_p.h>
8#include <private/qqmlengine_p.h>
9#include <private/qqmlvmemetaobject_p.h>
10#include <private/qv4alloca_p.h>
12#include <QtQml/qqmlinfo.h>
17
18
19
20
21
22
23
24
25
26
28QQmlAnyBinding QQmlPropertyToPropertyBinding::create(
29 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
31 QQmlAnyBinding result;
32 if (target.isBindable() && !QQmlPropertyPrivate::get(target)->isValueType()) {
33 if (source.isBindable()) {
34 result = QUntypedPropertyBinding(
new QQmlBindableToBindablePropertyBinding(
35 engine, source, target));
39 result = QUntypedPropertyBinding(
new QQmlUnbindableToBindablePropertyBinding(
40 engine, source, target));
44 if (source.isBindable()) {
45 result =
new QQmlBindableToUnbindablePropertyBinding(engine, source, target);
49 result =
new QQmlUnbindableToUnbindablePropertyBinding(engine, source, target);
53QQmlPropertyToPropertyBinding::QQmlPropertyToPropertyBinding(
54 QQmlEngine *engine,
const QQmlProperty &source)
56 , sourceObject(source.object())
57 , sourcePropertyIndex(QQmlPropertyPrivate::get(source)->encodedIndex())
62 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
70 return PropertyToPropertyBinding;
74 bool e, QQmlPropertyData::WriteFlags flags)
76 const bool wasEnabled = enabledFlag();
78 updateCanUseAccessor();
89 QObject *target = targetObject();
90 if (QQmlData::wasDeleted(target))
93 const QQmlPropertyData *d =
nullptr;
95 getPropertyData(&d, &vtd);
99 if (Q_UNLIKELY(updatingFlag()))
102 setUpdatingFlag(
true);
104 if (canUseAccessor())
105 flags.setFlag(QQmlPropertyData::BypassInterceptor);
107 QVariant value = m_binding.readSourceValue(
108 [&](
const QMetaObject *sourceMetaObject,
const QMetaProperty &property) {
109 captureProperty(sourceMetaObject, property);
112 QQmlPropertyPrivate::writeValueProperty(target, *d, vtd, value, {}, flags);
113 setUpdatingFlag(
false);
117 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
124 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
131 QPropertyObserver *observer, QUntypedPropertyData *)
134 ->QQmlPropertyToUnbindablePropertyBinding::update();
138 const QMetaObject *sourceMetaObject,
const QMetaProperty &sourceProperty)
140 Q_UNUSED(sourceMetaObject);
141 m_binding.doConnectNotify(
this, sourceProperty);
145 const QMetaObject *sourceMetaObject,
const QMetaProperty &sourceProperty)
147 Q_UNUSED(sourceProperty);
153 QUntypedBindable bindable;
154 void *argv[] = { &bindable };
155 sourceMetaObject->metacall(
156 m_binding.sourceObject, QMetaObject::BindableProperty,
157 m_binding.sourcePropertyIndex.coreIndex(), argv);
158 bindable.observe(
this);
159 m_isObserving =
true;
168 [](
void *,
void *){},
174 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target,
175 const QtPrivate::BindingFunctionVTable *vtable)
183 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
194 PendingBindingObserverList bindingObservers;
195 evaluateRecursive(bindingObservers);
197 if (
const QPropertyBindingError error = bindingError();
198 Q_UNLIKELY(error.type() == QPropertyBindingError::BindingLoop)) {
202 notifyNonRecursive(bindingObservers);
206 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
QQmlBindableToBindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target)
void captureProperty(const QMetaObject *sourceMetaObject, const QMetaProperty &sourceProperty) final
QQmlBindableToUnbindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target)
QQmlPropertyToBindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target, const QtPrivate::BindingFunctionVTable *vtable)
void setEnabled(bool e, QQmlPropertyData::WriteFlags flags) final
QQmlPropertyToUnbindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target)
void update(QQmlPropertyData::WriteFlags flags=QQmlPropertyData::DontRemoveBinding)
QQmlUnbindableToBindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target)
QQmlUnbindableToUnbindablePropertyBinding(QQmlEngine *engine, const QQmlProperty &source, const QQmlProperty &target)
void captureProperty(const QMetaObject *sourceMetaObject, const QMetaProperty &sourceProperty) final
Combined button and popup list for selecting options.
constexpr BindingFunctionVTable bindingFunctionVTableForQQmlPropertyToBindablePropertyBinding
void QQmlUnbindableToBindableGuard_callback(QQmlNotifierEndpoint *e, void **)
void QQmlUnbindableToUnbindableGuard_callback(QQmlNotifierEndpoint *e, void **)