Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlbind.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qqmlbind_p.h"
5
6#include <private/qqmlnullablevalue_p.h>
7#include <private/qqmlproperty_p.h>
8#include <private/qqmlbinding_p.h>
9#include <private/qqmlmetatype_p.h>
10#include <private/qqmlvmemetaobject_p.h>
11#include <private/qv4persistent_p.h>
12
13#include <qqmlengine.h>
14#include <qqmlcontext.h>
15#include <qqmlproperty.h>
16#include <qqmlpropertymap.h>
17#include <qqmlinfo.h>
18
19#include <QtCore/qfile.h>
20#include <QtCore/qdebug.h>
21#include <QtCore/qtimer.h>
22#include <QtCore/qloggingcategory.h>
23#include <private/qqmlanybinding_p.h>
24#include <private/qv4qmlcontext_p.h>
25#include <private/qqmlcomponent_p.h>
26
27#include <private/qobject_p.h>
28
30
31Q_DECLARE_LOGGING_CATEGORY(lcBindingRemoval)
32
34 V4Value,
35 Variant,
36 Binding,
37 None
38};
39
48 Q_DISABLE_COPY_MOVE(QQmlBindEntryContent)
49public:
52
53 [[nodiscard]] QQmlBindEntryKind set(
55 {
56 silentDestroy(oldKind);
57 switch (newKind) {
59 new (&v4Value) QV4::PersistentValue(std::move(other.v4Value));
60 break;
62 new (&variant) QVariant(std::move(other.variant));
63 break;
65 new (&binding) QQmlAnyBinding(std::move(other.binding));
66 break;
68 break;
69 }
70 return newKind;
71 }
72
73 [[nodiscard]] QQmlBindEntryKind set(
75 {
76 silentDestroy(oldKind);
77 switch (newKind) {
79 new (&v4Value) QV4::PersistentValue(other.v4Value);
80 break;
82 new (&variant) QVariant(other.variant);
83 break;
85 new (&binding) QQmlAnyBinding(other.binding);
86 break;
88 break;
89 }
90 return newKind;
91 }
92
94 {
95 switch (kind) {
98 break;
101 break;
104 break;
106 break;
107 }
109 }
110
112 {
113 silentDestroy(oldKind);
114 new (&variant) QVariant(std::move(v));
116 }
117
119 {
120 silentDestroy(oldKind);
121 new (&v4Value) QV4::PersistentValue(std::move(v));
123 }
124
126 {
127 silentDestroy(oldKind);
128 new (&binding) QQmlAnyBinding(std::move(v));
130 }
131
135
136private:
137 void silentDestroy(QQmlBindEntryKind oldKind)
138 {
139 const QQmlBindEntryKind dead = destroy(oldKind);
141 Q_UNUSED(dead);
142 }
143};
144
154{
155 QQmlBindEntry() = default;
156 QQmlBindEntry(QQmlBindEntry &&other) noexcept : prop(std::move(other.prop))
157 {
158 currentKind = current.set(std::move(other.current), other.currentKind, currentKind);
159 previousKind = previous.set(std::move(other.previous), other.previousKind, previousKind);
160 }
161
163 : prop(other.prop)
164 {
165 currentKind = current.set(other.current, other.currentKind, currentKind);
166 previousKind = previous.set(other.previous, other.previousKind, previousKind);
167 }
168
170 {
173 }
174
176 {
177 if (this == &other)
178 return *this;
179 prop = std::move(other.prop);
180 currentKind = current.set(std::move(other.current), other.currentKind, currentKind);
181 previousKind = previous.set(std::move(other.previous), other.previousKind, previousKind);
182 return *this;
183 }
184
186 {
187 if (this == &other)
188 return *this;
189 prop = other.prop;
190 currentKind = current.set(other.current, other.currentKind, currentKind);
191 previousKind = previous.set(other.previous, other.previousKind, previousKind);
192 return *this;
193 }
194
195
201
202 void validate(QQmlBind *q) const;
203 void clearPrev();
204 void setTarget(QQmlBind *q, const QQmlProperty &p);
205};
206
208{
209public:
211 : when(true)
212 , componentComplete(true)
213 , delayed(false)
215 , restoreBinding(true)
216 , restoreValue(true)
219 {
220 }
222
223 // There can be multiple entries when using the generalized grouped
224 // property syntax. One is used for target/property/value.
226
227 // The target object if using the \l target property
229
230 // Any values we need to create a proxy for. This is necessary when
231 // using the \l delayed member on generalized grouped properties. See
232 // the note on \l delayed.
233 std::unique_ptr<QQmlPropertyMap> delayedValues;
234
235 // The property name if using the \l property property.
237
238 // Whether the binding is enabled.
239 bool when: 1;
240
241 // Whether we have already parsed any generalized grouped properties
242 // we might need.
244
245 // Whether we should run in "delayed" mode and proxy all values before
246 // applying them to the target.
247 bool delayed:1;
248
249 // In delayed mode, when using the target/property mode, the \l value
250 // is the proxy. Then pendingEval denotes that a timer is active to
251 // apply the value. We should not start another timer then.
253
254 // Whether we should restore bindings on !when.
255 // TODO: Deprecate this and always do.
257
258 // Whether we should restore values on !when.
259 // TODO: Deprecate this and always do.
261
262 // writingProperty tracks whether we are updating the target property
263 // when using target/property/value. We use this information to warn about
264 // binding removal if we detect the target property to be updated while we
265 // are not writing it. This doesn't remove the Binding after all.
266 // For generalized grouped properties, we don't have to do this as writing
267 // the target property does remove the binding, just like it removes any
268 // other binding.
270
271 // Whether the last entry is the the target property referred to by the
272 // \l target object and the \l property property. This will generally be
273 // the case when using \l target and \l property.
275
277 void validate(QQmlBind *binding) const;
278 void decodeBinding(
279 QQmlBind *q, const QString &propertyPrefix, QQmlData::DeferredData *deferredData,
280 const QV4::CompiledData::Binding *binding,
282 void createDelayedValues();
283 void onDelayedValueChanged(const QString &delayedName);
284 void evalDelayed();
286};
287
289{
290 if (!prop.isWritable()) {
291 qmlWarning(q) << "Property '" << prop.name() << "' on "
292 << QQmlMetaType::prettyTypeName(prop.object()) << " is read-only.";
293 }
294}
295
297{
298 if (!lastIsTarget) {
300 lastIsTarget = true;
301 }
302 return &entries.last();
303}
304
306{
307 if (!when)
308 return;
309
310 qsizetype iterationEnd = entries.size();
311 if (lastIsTarget) {
312 if (obj) {
314 const QQmlBindEntry &last = entries.last();
315 if (!last.prop.isValid()) {
316 qmlWarning(q) << "Property '" << propName << "' does not exist on "
318 --iterationEnd;
319 }
320 } else {
321 --iterationEnd;
322 }
323 }
324
325 for (qsizetype i = 0; i < iterationEnd; ++i)
327}
328
389{
390}
391
410bool QQmlBind::when() const
411{
412 Q_D(const QQmlBind);
413 return d->when;
414}
415
417{
418 Q_D(QQmlBind);
419 if (d->when == v)
420 return;
421
422 d->when = v;
423 if (v && d->componentComplete)
424 d->validate(this);
425 eval();
426}
427
451{
452 Q_D(const QQmlBind);
453 return d->obj;
454}
455
457{
458 Q_D(QQmlBind);
459 if (d->obj && d->when) {
460 /* if we switch the object at runtime, we need to restore the
461 previous binding on the old object before continuing */
462 d->when = false;
463 eval();
464 d->when = true;
465 }
466 /* if "when" and "target" depend on the same property, we might
467 end up here before we could have updated "when". So reevaluate
468 when manually here.
469 */
470 const QQmlProperty whenProp(this, QLatin1StringView("when"));
471 const auto potentialWhenBinding = QQmlAnyBinding::ofProperty(whenProp);
472 if (auto abstractBinding = potentialWhenBinding.asAbstractBinding()) {
473 QQmlBinding *binding = static_cast<QQmlBinding *>(abstractBinding);
474 if (binding->hasValidContext()) {
475 const auto boolType = QMetaType::fromType<bool>();
476 bool when;
477 binding->evaluate(&when, boolType);
478 d->when = when;
479 }
480 }
481 d->obj = obj;
482 if (d->componentComplete) {
483 setTarget(QQmlProperty(d->obj, d->propName, qmlContext(this)));
484 if (d->when)
485 d->validate(this);
486 }
487 eval();
488}
489
521{
522 Q_D(const QQmlBind);
523 return d->propName;
524}
525
527{
528 Q_D(QQmlBind);
529 if (!d->propName.isEmpty() && d->when) {
530 /* if we switch the property name at runtime, we need to restore the
531 previous binding on the old object before continuing */
532 d->when = false;
533 eval();
534 d->when = true;
535 }
536 d->propName = p;
537 if (d->componentComplete) {
538 setTarget(QQmlProperty(d->obj, d->propName, qmlContext(this)));
539 if (d->when)
540 d->validate(this);
541 }
542 eval();
543}
544
555{
556 Q_D(const QQmlBind);
557 if (!d->lastIsTarget)
558 return QVariant();
559 Q_ASSERT(d->entries.last().currentKind == QQmlBindEntryKind::Variant);
560 return d->entries.last().current.variant;
561}
562
564{
565 Q_D(QQmlBind);
566 QQmlBindEntry *targetEntry = d->targetEntry();
567 targetEntry->currentKind = targetEntry->current.set(v, targetEntry->currentKind);
568 prepareEval();
569}
570
598{
599 Q_D(const QQmlBind);
600 return d->delayed;
601}
602
603void QQmlBind::setDelayed(bool delayed)
604{
605 Q_D(QQmlBind);
606 if (d->delayed == delayed)
607 return;
608
609 d->delayed = delayed;
610 if (!d->componentComplete)
611 return;
612
613 d->delayedValues.reset();
614
615 QVarLengthArray<QQmlBindEntry, 1> oldEntries = std::move(d->entries);
616 d->entries.clear();
617 d->buildBindEntries(this, nullptr);
618
619 if (d->lastIsTarget) {
620 d->entries.append(std::move(oldEntries.last()));
621 oldEntries.pop_back();
622 }
623
624 for (qsizetype i = 0, end = oldEntries.size(); i < end; ++i) {
625 QQmlBindEntry &newEntry = d->entries[i];
626 QQmlBindEntry &oldEntry = oldEntries[i];
627 newEntry.previousKind = newEntry.previous.set(
628 std::move(oldEntry.previous), oldEntry.previousKind, newEntry.previousKind);
629 if (d->delayed && oldEntry.currentKind == QQmlBindEntryKind::Binding)
631 }
632
633 if (!d->delayed)
634 eval();
635}
636
659{
660 Q_D(const QQmlBind);
661 unsigned result = RestoreNone;
662 if (d->restoreValue)
664 if (d->restoreBinding)
666 return RestorationMode(result);
667}
668
670{
671 Q_D(QQmlBind);
672 if (newMode != restoreMode()) {
673 d->restoreValue = (newMode & RestoreValue);
674 d->restoreBinding = (newMode & RestoreBinding);
676 }
677}
678
680{
681 Q_D(QQmlBind);
682 d->targetEntry()->setTarget(this, p);
683}
684
686{
687 if (Q_UNLIKELY(lcBindingRemoval().isInfoEnabled())) {
688 if (QObject *oldObject = prop.object()) {
689 QMetaProperty metaProp = oldObject->metaObject()->property(prop.index());
690 if (metaProp.hasNotifySignal()) {
691 QByteArray signal('2' + metaProp.notifySignal().methodSignature());
692 QObject::disconnect(oldObject, signal.constData(),
693 q, SLOT(targetValueChanged()));
694 }
695 }
696 p.connectNotifySignal(q, SLOT(targetValueChanged()));
697 }
698
699 prop = p;
700}
701
703{
704 Q_D(QQmlBind);
705 d->componentComplete = false;
706}
707
709 const QQmlProperty &prop, const QV4::CompiledData::Binding *binding,
711 const QQmlRefPointer<QQmlContextData> &contextData,
712 QObject *scopeObject)
713{
714 switch (binding->type()) {
717 return QQmlAnyBinding::createTranslationBinding(prop, compilationUnit, binding, scopeObject);
720 if (id == QQmlBinding::Invalid) {
722 prop, compilationUnit->bindingValueAsString(binding), scopeObject,
723 contextData, compilationUnit->finalUrlString(), binding->location.line());
724 }
725 QV4::Scope scope(contextData->engine()->handle());
728 scope.engine->rootContext(), contextData, scopeObject));
730 prop, compilationUnit->runtimeFunctions.at(id), scopeObject, contextData,
731 qmlCtxt);
732 }
733 default:
734 break;
735 }
736 return QQmlAnyBinding();
737}
738
740 QQmlBind *q, const QString &propertyPrefix,
741 QQmlData::DeferredData *deferredData,
742 const QV4::CompiledData::Binding *binding,
744{
746 = deferredData->compilationUnit;
747 const QString propertyName = propertyPrefix
748 + compilationUnit->stringAt(binding->propertyNameIndex);
749
750 switch (binding->type()) {
753 const QString pre = propertyName + u'.';
754 const QV4::CompiledData::Object *subObj
755 = compilationUnit->objectAt(binding->value.objectIndex);
756 const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
757 for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding)
758 decodeBinding(q, pre, deferredData, subBinding, immediateState);
759 return;
760 }
761 default:
762 break;
763 }
764
768 entry.prop = QQmlPropertyPrivate::create(nullptr, propertyName, contextData,
770 if (!entry.prop.isValid()) {
771 // Try again in the context of this object. If that works, it's a regular property.
772 // ... unless we're not supposed to handle regular properties. Then ignore it.
773 if (!immediateState)
774 return;
775
777 q, propertyName, contextData, QQmlPropertyPrivate::InitFlag::AllowSignal);
778 if (property.isValid()) {
779 if (!immediateState->hasCreator()) {
780 immediateState->setCompletePending(true);
781 immediateState->initCreator(
782 deferredData->context->parent(), deferredData->compilationUnit,
783 contextData);
784 immediateState->creator()->beginPopulateDeferred(deferredData->context);
785 }
786 immediateState->creator()->populateDeferredBinding(
787 property, deferredData->deferredIdx, binding);
788 } else {
789 qmlWarning(q).nospace() << "Unknown name " << propertyName
790 << ". The binding is ignored.";
791 }
792 return;
793 }
794
795 const auto setVariant = [&entry](QVariant var) {
796 entry.currentKind = entry.current.set(std::move(var), entry.currentKind);
797 };
798
799 const auto setBinding = [&entry](QQmlAnyBinding binding) {
800 entry.currentKind = entry.current.set(binding, entry.currentKind);
801 };
802
803 switch (binding->type()) {
806 Q_UNREACHABLE(); // Handled above
807 break;
811 if (delayed) {
812 if (!delayedValues)
814 const QString delayedName = QString::number(entries.size());
815 delayedValues->insert(delayedName, QVariant());
816 QQmlProperty bindingTarget = QQmlProperty(delayedValues.get(), delayedName);
817 Q_ASSERT(bindingTarget.isValid());
818 QQmlAnyBinding anyBinding = createBinding(
819 bindingTarget, binding, compilationUnit, contextData, q);
820 anyBinding.installOn(bindingTarget);
821 } else {
822 setBinding(createBinding(entry.prop, binding, compilationUnit, contextData, q));
823 }
824 break;
826 setVariant(compilationUnit->bindingValueAsString(binding));
827 break;
829 setVariant(compilationUnit->bindingValueAsNumber(binding));
830 break;
832 setVariant(binding->valueAsBoolean());
833 break;
835 setVariant(QVariant::fromValue(nullptr));
836 break;
839 break;
840 }
841
842 entries.append(std::move(entry));
843}
844
846{
847 delayedValues = std::make_unique<QQmlPropertyMap>();
850 delayedValues.get(), [this](const QString &delayedName, const QVariant &value) {
851 Q_UNUSED(value);
852 onDelayedValueChanged(delayedName);
853 }
854 );
855}
856
858{
861 const QString pendingName = QStringLiteral("pending");
862 QStringList pending = qvariant_cast<QStringList>((*delayedValues)[pendingName]);
863 if (componentComplete && pending.size() == 0)
864 QTimer::singleShot(0, delayedValues.get(), [this]() { evalDelayed(); });
865 else if (pending.contains(delayedName))
866 return;
867
868 pending.append(delayedName);
869 (*delayedValues)[pendingName].setValue(std::move(pending));
870}
871
873{
874 if (!when || !delayedValues)
875 return;
876
877 const QString pendingName = QStringLiteral("pending");
878 const QStringList pending = qvariant_cast<QStringList>((*delayedValues)[pendingName]);
879 for (const QString &delayedName : pending) {
880 bool ok;
881 const int delayedIndex = delayedName.toInt(&ok);
882 Q_ASSERT(ok);
883 Q_ASSERT(delayedIndex >= 0 && delayedIndex < entries.size());
884 entries[delayedIndex].prop.write((*delayedValues)[delayedName]);
885 }
886 (*delayedValues)[pendingName].setValue(QStringList());
887}
888
890{
892 if (data && !data->deferredData.isEmpty()) {
893 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine());
894 for (QQmlData::DeferredData *deferredData : data->deferredData) {
895 QMultiHash<int, const QV4::CompiledData::Binding *> *bindings = &deferredData->bindings;
896 if (deferredState) {
898 for (auto it = bindings->cbegin(); it != bindings->cend(); ++it)
899 decodeBinding(q, QString(), deferredData, *it, &constructionState);
900
901
902 if (constructionState.hasCreator()) {
904 constructionState.creator()->finalizePopulateDeferred();
905 constructionState.appendCreatorErrors();
906 deferredState->push_back(std::move(constructionState));
907 }
908 } else {
909 for (auto it = bindings->cbegin(); it != bindings->cend(); ++it)
910 decodeBinding(q, QString(), deferredData, *it, nullptr);
911 }
912 }
913
914 if (deferredState) {
915 data->releaseDeferredData();
916 if (!deferredState->empty())
918 }
919 }
920}
921
923{
924 Q_D(QQmlBind);
926 d->buildBindEntries(this, &deferredState);
927 d->componentComplete = true;
928 if (!d->propName.isEmpty() || d->obj) {
929 QQmlBindEntry *target = d->targetEntry();
930 if (!target->prop.isValid())
931 target->setTarget(this, QQmlProperty(d->obj, d->propName, qmlContext(this)));
932 }
933 d->validate(this);
934 d->evalDelayed();
935 eval();
936}
937
938void QQmlBind::prepareEval()
939{
940 Q_D(QQmlBind);
941 if (d->delayed) {
942 if (!d->pendingEval)
943 QTimer::singleShot(0, this, &QQmlBind::eval);
944 d->pendingEval = true;
945 } else {
946 eval();
947 }
948}
949
951{
953}
954
955void QQmlBind::eval()
956{
957 Q_D(QQmlBind);
958 d->pendingEval = false;
959 if (!d->componentComplete)
960 return;
961
962 for (QQmlBindEntry &entry : d->entries) {
963 if (!entry.prop.isValid() || (entry.currentKind == QQmlBindEntryKind::None))
964 continue;
965
966 if (!d->when) {
967 //restore any previous binding
968 switch (entry.previousKind) {
970 if (d->restoreBinding) {
971 QQmlAnyBinding p = std::move(entry.previous.binding);
972 entry.clearPrev(); // Do that before setBinding(), as setBinding() may recurse.
973 p.installOn(entry.prop);
974 }
975 break;
977 if (d->restoreValue) {
978 auto propPriv = QQmlPropertyPrivate::get(entry.prop);
979 QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(propPriv->object);
980 Q_ASSERT(vmemo);
981 vmemo->setVMEProperty(propPriv->core.coreIndex(),
982 *entry.previous.v4Value.valueRef());
983 entry.clearPrev();
984 }
985 break;
987 if (d->restoreValue) {
988 entry.prop.write(entry.previous.variant);
989 entry.clearPrev();
990 }
991 break;
993 break;
994 }
995 continue;
996 }
997
998 //save any set binding for restoration
999 if (entry.previousKind == QQmlBindEntryKind::None) {
1000 // try binding first; we need to use takeFrom to properly unlink the binding
1002 if (prevBind) {
1003 entry.previousKind = entry.previous.set(std::move(prevBind), entry.previousKind);
1004 } else {
1005 // nope, try a V4 value next
1006 auto propPriv = QQmlPropertyPrivate::get(entry.prop);
1007 auto propData = propPriv->core;
1008 if (!propPriv->valueTypeData.isValid() && propData.isVarProperty()) {
1009 QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(propPriv->object);
1010 Q_ASSERT(vmemo);
1011 auto retVal = vmemo->vmeProperty(propData.coreIndex());
1012 entry.previousKind = entry.previous.set(
1013 QV4::PersistentValue(vmemo->engine, retVal), entry.previousKind);
1014 } else {
1015 // nope, use the meta object to get a QVariant
1016 entry.previousKind = entry.previous.set(entry.prop.read(), entry.previousKind);
1017 }
1018 }
1019 }
1020
1021 // NOTE: removeBinding has no effect on QProperty classes, but
1022 // we already used takeBinding to remove it
1024 }
1025
1026 if (!d->when)
1027 return;
1028
1029 d->writingProperty = true;
1030 for (qsizetype i = 0, end = d->entries.size(); i != end; ++i) {
1031 QQmlBindEntry &entry = d->entries[i];
1032 if (!entry.prop.isValid())
1033 continue;
1034 switch (entry.currentKind) {
1036 entry.prop.write(entry.current.variant);
1037 break;
1039 Q_ASSERT(!d->delayed);
1040 entry.current.binding.installOn(entry.prop);
1041 break;
1043 auto propPriv = QQmlPropertyPrivate::get(entry.prop);
1044 QQmlVMEMetaObject::get(propPriv->object)->setVMEProperty(
1045 propPriv->core.coreIndex(), *entry.current.v4Value.valueRef());
1046 break;
1047 }
1049 break;
1050 }
1051 }
1052 d->writingProperty = false;
1053}
1054
1055void QQmlBind::targetValueChanged()
1056{
1057 Q_D(QQmlBind);
1058 if (d->writingProperty)
1059 return;
1060
1061 if (!d->when)
1062 return;
1063
1064 QUrl url;
1065 quint16 line = 0;
1066
1067 const QQmlData *ddata = QQmlData::get(this, false);
1068 if (ddata && ddata->outerContext) {
1069 url = ddata->outerContext->url();
1070 line = ddata->lineNumber;
1071 }
1072
1073 qCInfo(lcBindingRemoval,
1074 "The target property of the Binding element created at %s:%d was changed from "
1075 "elsewhere. This does not overwrite the binding. The target property will still be "
1076 "updated when the value of the Binding element changes.",
1078}
1079
1081
1082#include "moc_qqmlbind_p.cpp"
\inmodule QtCore
Definition qbytearray.h:57
QByteArray methodSignature() const
\inmodule QtCore
QMetaMethod notifySignal() const
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false.
\inmodule QtCore
Definition qhash.h:1348
const_iterator cbegin() const noexcept
Definition qhash.h:1828
const_iterator cend() const noexcept
Definition qhash.h:1832
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3099
\inmodule QtCore
Definition qpointer.h:18
QQmlAnyBinding is an abstraction over the various bindings in QML.
static QQmlAnyBinding createFromCodeString(const QQmlProperty &prop, const QString &code, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, const QString &url, quint16 lineNumber)
static void removeBindingFrom(QQmlProperty &prop)
static QQmlAnyBinding createTranslationBinding(const QQmlProperty &prop, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QV4::CompiledData::Binding *translationBinding, QObject *scopeObject=nullptr, QQmlRefPointer< QQmlContextData > context={})
static QQmlAnyBinding takeFrom(const QQmlProperty &prop)
Removes the binding from the property prop, and returns it as a QQmlAnyBinding if there was any.
void installOn(const QQmlProperty &target, InterceptorMode mode=IgnoreInterceptors)
~QQmlAnyBinding() noexcept
static QQmlAnyBinding ofProperty(const QQmlProperty &prop)
static QQmlAnyBinding createFromFunction(const QQmlProperty &prop, QV4::Function *function, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, QV4::ExecutionContext *scope)
void validate(QQmlBind *binding) const
Definition qqmlbind.cpp:305
std::unique_ptr< QQmlPropertyMap > delayedValues
Definition qqmlbind.cpp:233
QVarLengthArray< QQmlBindEntry, 1 > entries
Definition qqmlbind.cpp:225
QQmlBindEntry * targetEntry()
Definition qqmlbind.cpp:296
void decodeBinding(QQmlBind *q, const QString &propertyPrefix, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding, QQmlComponentPrivate::ConstructionState *immediateState)
Definition qqmlbind.cpp:739
void buildBindEntries(QQmlBind *q, QQmlComponentPrivate::DeferredState *deferredState)
Definition qqmlbind.cpp:889
QPointer< QObject > obj
Definition qqmlbind.cpp:228
void createDelayedValues()
Definition qqmlbind.cpp:845
void onDelayedValueChanged(const QString &delayedName)
Definition qqmlbind.cpp:857
QString property
Definition qqmlbind_p.h:42
bool when
Definition qqmlbind_p.h:44
void setRestoreMode(RestorationMode)
Definition qqmlbind.cpp:669
void setDelayed(bool)
Definition qqmlbind.cpp:603
void setWhen(bool)
Definition qqmlbind.cpp:416
void classBegin() override
Invoked after class creation, but before any properties have been set.
Definition qqmlbind.cpp:702
RestorationMode restoreMode
Definition qqmlbind_p.h:47
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
Definition qqmlbind.cpp:922
void setTarget(const QQmlProperty &) override
Set the target property for the value source.
Definition qqmlbind.cpp:679
QQmlBind(QObject *parent=nullptr)
Definition qqmlbind.cpp:387
QObject * object()
\qmlproperty QtObject QtQml::Binding::target
Definition qqmlbind.cpp:450
void setValue(const QVariant &)
Definition qqmlbind.cpp:563
QVariant value
Definition qqmlbind_p.h:43
@ RestoreNone
Definition qqmlbind_p.h:30
@ RestoreValue
Definition qqmlbind_p.h:32
@ RestoreBinding
Definition qqmlbind_p.h:31
void setObject(QObject *)
Definition qqmlbind.cpp:456
bool delayed
Definition qqmlbind_p.h:45
void setProperty(const QString &)
Definition qqmlbind.cpp:526
void restoreModeChanged()
QVariant evaluate()
std::vector< ConstructionState > DeferredState
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState)
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
QQmlRefPointer< QQmlContextData > parent() const
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
quint16 lineNumber
Definition qqmldata_p.h:168
QQmlContextData * outerContext
Definition qqmldata_p.h:149
static QQmlEnginePrivate * get(QQmlEngine *e)
static QString prettyTypeName(const QObject *object)
Returns the pretty QML type name (e.g.
void beginPopulateDeferred(const QQmlRefPointer< QQmlContextData > &context)
void populateDeferredBinding(const QQmlProperty &qmlProperty, int deferredIndex, const QV4::CompiledData::Binding *binding)
void valueChanged(const QString &key, const QVariant &value)
This signal is emitted whenever one of the values in the map is changed.
static QQmlProperty create(QObject *target, const QString &propertyName, const QQmlRefPointer< QQmlContextData > &context, QQmlPropertyPrivate::InitFlags flags)
static void removeBinding(const QQmlProperty &that)
static QQmlPropertyPrivate * get(const QQmlProperty &p)
The QQmlProperty class abstracts accessing properties on objects created from QML.
bool isValid() const
Returns true if the QQmlProperty refers to a valid property, otherwise false.
int index() const
Return the Qt metaobject index of the property.
QML_ANONYMOUSQObject * object
bool isWritable() const
Returns true if the property is writable, otherwise false.
QV4::ReturnedValue vmeProperty(int index) const
static QQmlVMEMetaObject * get(QObject *o)
QV4::ExecutionEngine * engine
void setVMEProperty(int index, const QV4::Value &v)
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
bool singleShot
whether the timer is a single-shot timer
Definition qtimer.h:22
\inmodule QtCore
Definition qurl.h:94
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Definition qurl.cpp:2828
constexpr size_type size() const noexcept
bool isEmpty() const
void append(const T &t)
\inmodule QtCore
Definition qvariant.h:64
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
~QVariant()
Destroys the QVariant and the contained object.
Definition qvariant.cpp:544
QSet< QString >::iterator it
auto signal
Combined button and popup list for selecting options.
static void * context
#define Q_UNLIKELY(x)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall * pending
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCInfo(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
#define SLOT(a)
Definition qobjectdefs.h:51
GLsizei const GLfloat * v
[13]
GLuint GLuint end
GLenum target
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLhandleARB obj
[2]
GLuint entry
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:71
QQmlBindEntryKind
Definition qqmlbind.cpp:33
static QQmlAnyBinding createBinding(const QQmlProperty &prop, const QV4::CompiledData::Binding *binding, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlRefPointer< QQmlContextData > &contextData, QObject *scopeObject)
Definition qqmlbind.cpp:708
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define qPrintable(string)
Definition qstring.h:1391
#define QStringLiteral(str)
#define emit
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:45
unsigned short quint16
Definition qtypes.h:43
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned char quint8
Definition qtypes.h:41
const char property[13]
Definition qwizard.cpp:101
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
QQmlBindEntryKind previousKind
Definition qqmlbind.cpp:200
QQmlBindEntry(const QQmlBindEntry &other)
Definition qqmlbind.cpp:162
QQmlBindEntry & operator=(QQmlBindEntry &&other) noexcept
Definition qqmlbind.cpp:175
void clearPrev()
Definition qqmlbind.cpp:950
QQmlProperty prop
Definition qqmlbind.cpp:198
void setTarget(QQmlBind *q, const QQmlProperty &p)
Definition qqmlbind.cpp:685
QQmlBindEntryKind currentKind
Definition qqmlbind.cpp:199
QQmlBindEntry & operator=(const QQmlBindEntry &other)
Definition qqmlbind.cpp:185
QQmlBindEntryContent current
Definition qqmlbind.cpp:196
QQmlBindEntryContent previous
Definition qqmlbind.cpp:197
void validate(QQmlBind *q) const
Definition qqmlbind.cpp:288
QQmlBindEntry(QQmlBindEntry &&other) noexcept
Definition qqmlbind.cpp:156
QQmlBindEntry()=default
QQmlObjectCreator * initCreator(QQmlRefPointer< QQmlContextData > parentContext, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlRefPointer< QQmlContextData > &creationContext)
QQmlRefPointer< QQmlContextData > context
Definition qqmldata_p.h:183
unsigned int deferredIdx
Definition qqmldata_p.h:176
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit
Definition qqmldata_p.h:180
union QV4::CompiledData::Binding::@543 value
const Binding * bindingTable() const
ExecutionContext * rootContext() const
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)
ExecutionEngine * engine
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
QQmlAnyBinding binding
Definition qqmlbind.cpp:134
QQmlBindEntryKind set(const QQmlBindEntryContent &other, QQmlBindEntryKind newKind, QQmlBindEntryKind oldKind)
Definition qqmlbind.cpp:73
QQmlBindEntryKind set(QQmlAnyBinding v, QQmlBindEntryKind oldKind)
Definition qqmlbind.cpp:125
QV4::PersistentValue v4Value
Definition qqmlbind.cpp:132
QQmlBindEntryKind set(QV4::PersistentValue v, QQmlBindEntryKind oldKind)
Definition qqmlbind.cpp:118
QQmlBindEntryKind set(QVariant v, QQmlBindEntryKind oldKind)
Definition qqmlbind.cpp:111
QQmlBindEntryKind set(QQmlBindEntryContent &&other, QQmlBindEntryKind newKind, QQmlBindEntryKind oldKind)
Definition qqmlbind.cpp:53
QQmlBindEntryKind destroy(QQmlBindEntryKind kind)
Definition qqmlbind.cpp:93