QQmlJSScope Class

Tracks the types for the QmlCompiler. More...

Header: #include <QQmlJSScope>

Public Types

flags Flags

Public Functions

int enclosingInlineComponentName() const
int inlineComponentName() const
bool isComponentRootElement() const
bool isCreatable() const
QHash<QString, QQmlJSMetaMethod> methods() const
QHash<QString, QQmlJSMetaProperty> properties() const

Static Public Members

bool causesImplicitComponentWrapping(const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &assignedType)
void resolveEnums(const QQmlJSScope::Ptr &self, const QQmlJSScope::ContextualTypes &contextualTypes, QSet<QString> *usedTypes = nullptr)

Detailed Description

\internal

QQmlJSScope tracks the types used in qml for the QmlCompiler.

Multiple QQmlJSScope objects might be created for the same conceptual type, except when reused due to extensive caching. Two QQmlJSScope objects are considered equal when they are backed by the same implementation, that is, they have the same internalName. The qualifiedName of the QQmlJSScope for a type imported from multiple modules will contain the name of one of the modules that imported it, which is not unique and might change depending on the caching in .

Member Function Documentation

[static] bool QQmlJSScope::causesImplicitComponentWrapping(const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &assignedType)

\internalReturns if assigning assignedType to property would require an implicit component wrapping.

int QQmlJSScope::enclosingInlineComponentName() const

\internalIf this type is part of an inline component, return its name. Otherwise, if this type is part of the document root, return the document root name.

int QQmlJSScope::inlineComponentName() const

\internalif this->isInlineComponent(), then this getter returns the name of the inline component.

bool QQmlJSScope::isComponentRootElement() const

\internalReturns true if the scope is the outermost element of a separate Component Either because it has been implicitly wrapped, e.g. due to an assignment to a Component property, or because it is the first (and only) child of a Component. For visitors: This method should only be called after implicit components are detected, that is, after QQmlJSImportVisitor::endVisit(UiProgram *) was called.

bool QQmlJSScope::isCreatable() const

\internalReturns true if the current type is creatable by checking all the required base classes. "Uncreatability" is only inherited from base types for composite types (in qml) and not for non-composite types (c++).

For the exact definition: A type is uncreatable if and only if one of its composite base type or its first non-composite base type matches following criteria:

QHash<QString, QQmlJSMetaMethod> QQmlJSScope::methods() const

Returns all methods visible from this scope including those of base types and extensions.

Note: Methods that get shadowed are not included and only the version visible from this scope is contained. Additionally method overrides are not included either, only the first visible version of any method is included.

QHash<QString, QQmlJSMetaProperty> QQmlJSScope::properties() const

Returns all properties visible from this scope including those of base types and extensions.

Note: Properties that get shadowed are not included and only the version visible from this scope is contained.

[static] void QQmlJSScope::resolveEnums(const QQmlJSScope::Ptr &self, const QQmlJSScope::ContextualTypes &contextualTypes, QSet<QString> *usedTypes = nullptr)

\internalResolves all enums of self.

Some enums happen to have an alias, e.g. when an enum is used as a flag, the enum will exist in two versions, once as enum (e.g. Qt::MouseButton) and once as a flag (e.g. Qt::MouseButtons). In this case, normally only the flag is exposed to the qt metatype system and tools like qmltc will have troubles when encountering the enum in signal parameters etc. To solve this problem, resolveEnums() will create a QQmlJSMetaEnum copy for the alias in case the 'self'-scope already does not have an enum called like the alias.