void QmlContextPropertyAdaptor::doSetObject(const ObjectInstance &oi) { auto context = qobject_cast<QQmlContext *>(oi.qtObject()); Q_ASSERT(context); auto contextData = QQmlContextData::get(context); Q_ASSERT(contextData); const auto &propNames = contextData->propertyNames(); m_contextPropertyNames.clear(); m_contextPropertyNames.reserve(propNames.count()); QV4::IdentifierHashEntry *e = propNames.d->entries; QV4::IdentifierHashEntry *end = e + propNames.d->alloc; while (e < end) { #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) if (e->identifier) m_contextPropertyNames.push_back(e->identifier->string); #else if (e->identifier.isValid()) m_contextPropertyNames.push_back(e->identifier.toQString()); #endif ++e; } }
void DynamicPropertyAdaptor::doSetObject(const ObjectInstance &oi) { auto obj = oi.qtObject(); if (obj) { m_propNames = obj->dynamicPropertyNames(); obj->installEventFilter(this); connect(obj, SIGNAL(destroyed(QObject*)), this, SIGNAL(objectInvalidated())); } }
void QmlAttachedPropertyAdaptor::doSetObject(const ObjectInstance &oi) { auto data = QQmlData::get(oi.qtObject()); Q_ASSERT(data); Q_ASSERT(data->hasExtendedData()); Q_ASSERT(data->attachedProperties()); m_attachedTypes.reserve(data->attachedProperties()->size()); for (auto it = data->attachedProperties()->constBegin(); it != data->attachedProperties()->constEnd(); ++it) m_attachedTypes.push_back(it.key()); }
void QMetaPropertyAdaptor::doSetObject(const ObjectInstance& oi) { auto mo = oi.metaObject(); if (!mo || oi.type() != ObjectInstance::QtObject || !oi.qtObject()) return; connect(oi.qtObject(), SIGNAL(destroyed(QObject*)), this, SIGNAL(objectInvalidated())); for (int i = 0; i < mo->propertyCount(); ++i) { const QMetaProperty prop = mo->property(i); if (prop.hasNotifySignal()) { connect(oi.qtObject(), QByteArray("2") + #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) prop.notifySignal().signature() #else prop.notifySignal().methodSignature() #endif , this, SLOT(propertyUpdated())); m_notifyToPropertyMap.insert(prop.notifySignalIndex(), i); } } }