本文整理汇总了C++中QQmlEnginePrivate::captureProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlEnginePrivate::captureProperty方法的具体用法?C++ QQmlEnginePrivate::captureProperty怎么用?C++ QQmlEnginePrivate::captureProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlEnginePrivate
的用法示例。
在下文中一共展示了QQmlEnginePrivate::captureProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: propertystring
v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
const v8::AccessorInfo &info)
{
QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
// Its possible we could delay the calculation of the "actual" context (in the case
// of sub contexts) until it is definately needed.
QQmlContextData *context = resource->getContext();
QQmlContextData *expressionContext = context;
if (!context)
return v8::Undefined();
if (v8::Context::GetCallingQmlGlobal() != info.This())
return v8::Handle<v8::Value>();
// Search type (attached property/enum/imported scripts) names
// while (context) {
// Search context properties
// Search scope object
// Search context object
// context = context->parent
// }
QV8Engine *engine = resource->engine;
QObject *scopeObject = resource->getScopeObject();
QHashedV8String propertystring(property);
if (context->imports && QV8Engine::startsWithUpper(property)) {
// Search for attached properties, enums and imported scripts
QQmlTypeNameCache::Result r = context->imports->query(propertystring);
if (r.isValid()) {
if (r.scriptIndex != -1) {
int index = r.scriptIndex;
if (index < context->importedScripts.count())
return context->importedScripts.at(index);
else
return v8::Undefined();
} else if (r.type) {
return engine->typeWrapper()->newObject(scopeObject, r.type);
} else if (r.importNamespace) {
return engine->typeWrapper()->newObject(scopeObject, context->imports, r.importNamespace);
}
Q_ASSERT(!"Unreachable");
}
// Fall through
}
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine());
QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
while (context) {
// Search context properties
if (context->propertyNames) {
int propertyIdx = context->propertyNames->value(propertystring);
if (propertyIdx != -1) {
if (propertyIdx < context->idValueCount) {
ep->captureProperty(&context->idValues[propertyIdx].bindings);
return engine->newQObject(context->idValues[propertyIdx]);
} else {
QQmlContextPrivate *cp = context->asQQmlContextPrivate();
ep->captureProperty(context->asQQmlContext(), -1,
propertyIdx + cp->notifyIndex);
const QVariant &value = cp->propertyValues.at(propertyIdx);
if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*) qintptr(propertyIdx),
QQmlContextPrivate::context_count,
QQmlContextPrivate::context_at);
return engine->listWrapper()->newList(prop, qMetaTypeId<QQmlListProperty<QObject> >());
} else {
return engine->fromVariant(cp->propertyValues.at(propertyIdx));
}
}
}
}
// Search scope object
if (scopeObject) {
v8::Handle<v8::Value> result = qobjectWrapper->getProperty(scopeObject, propertystring,
context, QV8QObjectWrapper::CheckRevision);
if (!result.IsEmpty()) return result;
}
scopeObject = 0;
// Search context object
if (context->contextObject) {
v8::Handle<v8::Value> result = qobjectWrapper->getProperty(context->contextObject, propertystring,
context, QV8QObjectWrapper::CheckRevision);
if (!result.IsEmpty()) return result;
//.........这里部分代码省略.........