Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlImports Class Referencefinal

The QQmlImports class encapsulates one QML document's import statements. More...

#include <qqmlimport_p.h>

+ Inheritance diagram for QQmlImports:
+ Collaboration diagram for QQmlImports:

Classes

struct  CompositeSingletonReference
 
struct  ScriptReference
 

Public Types

enum  ImportVersion { FullyVersioned , PartiallyVersioned , Unversioned }
 
enum  ImportFlag : quint8 { ImportNoFlag = 0x0 , ImportIncomplete = 0x1 }
 

Public Member Functions

 QQmlImports ()=default
 
 ~QQmlImports ()
 
void setBaseUrl (const QUrl &url, const QString &urlString=QString())
 Sets the base URL to be used for all relative file imports added.
 
QUrl baseUrl () const
 
bool resolveType (QQmlTypeLoader *typeLoader, const QHashedStringRef &type, QQmlType *type_return, QTypeRevision *version_return, QQmlImportNamespace **ns_return, QList< QQmlError > *errors=nullptr, QQmlType::RegistrationType registrationType=QQmlType::AnyRegistrationType, bool *typeRecursionDetected=nullptr) const
 
QTypeRevision addImplicitImport (QQmlTypeLoader *typeLoader, QString *localQmldir, QList< QQmlError > *errors)
 
bool addInlineComponentImport (QQmlImportInstance *const importInstance, const QString &name, const QUrl importUrl)
 
QTypeRevision addFileImport (QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, QTypeRevision version, ImportFlags flags, quint16 precedence, QString *localQmldir, QList< QQmlError > *errors)
 
QTypeRevision addLibraryImport (QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, QTypeRevision version, const QString &qmldirIdentifier, const QString &qmldirUrl, ImportFlags flags, quint16 precedence, QList< QQmlError > *errors)
 
QTypeRevision updateQmldirContent (QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, const QString &qmldirIdentifier, const QString &qmldirUrl, QList< QQmlError > *errors)
 
void populateCache (QQmlTypeNameCache *cache) const
 
QList< ScriptReferenceresolvedScripts () const
 
QList< CompositeSingletonReferenceresolvedCompositeSingletons () const
 
- Public Member Functions inherited from QQmlRefCounted< QQmlImports >
void release () const
 
- Public Member Functions inherited from QQmlRefCount
 QQmlRefCount ()
 
void addref () const
 
int count () const
 

Static Public Member Functions

static QStringList completeQmldirPaths (const QString &uri, const QStringList &basePaths, QTypeRevision version)
 Forms complete paths to a qmldir file, from a base URL, a module URI and version specification.
 
static QString versionString (QTypeRevision version, ImportVersion importVersion)
 
static bool isLocal (const QString &url)
 
static bool isLocal (const QUrl &url)
 
static QUrl urlFromLocalFileOrQrcOrUrl (const QString &)
 
static void setDesignerSupportRequired (bool b)
 
static QTypeRevision validVersion (QTypeRevision version=QTypeRevision())
 

Friends

class QQmlImportDatabase
 

Additional Inherited Members

- Protected Member Functions inherited from QQmlRefCounted< QQmlImports >
 ~QQmlRefCounted ()
 

Detailed Description

The QQmlImports class encapsulates one QML document's import statements.

Definition at line 117 of file qqmlimport_p.h.

Member Enumeration Documentation

◆ ImportFlag

Enumerator
ImportNoFlag 
ImportIncomplete 

Definition at line 123 of file qqmlimport_p.h.

◆ ImportVersion

Enumerator
FullyVersioned 
PartiallyVersioned 
Unversioned 

Definition at line 121 of file qqmlimport_p.h.

Constructor & Destructor Documentation

◆ QQmlImports()

QQmlImports::QQmlImports ( )
default

◆ ~QQmlImports()

QQmlImports::~QQmlImports ( )
inline

Definition at line 130 of file qqmlimport_p.h.

Member Function Documentation

◆ addFileImport()

QTypeRevision QQmlImports::addFileImport ( QQmlTypeLoader * typeLoader,
const QString & uri,
const QString & prefix,
QTypeRevision version,
ImportFlags flags,
quint16 precedence,
QString * localQmldir,
QList< QQmlError > * errors )

Adds information to database such that subsequent calls to resolveType() will resolve types qualified by prefix by considering types found at the given uri.

The uri is either a directory (if importType is FileImport), or a URI resolved using paths added via addImportPath() (if importType is LibraryImport).

The prefix may be empty, in which case the import location is considered for unqualified types.

The base URL must already have been set with Import::setBaseUrl().

Optionally, the qmldir the import resolved to can be returned by providing the localQmldir parameter. Not all imports will have a local qmldir. If there is none, the localQmldir parameter won't be set.

Returns a valid QTypeRevision on success, and an invalid one on failure. In case of failure, the errors array will filled appropriately.

Definition at line 1236 of file qqmlimport.cpp.

References QQmlTypeLoader::absoluteFilePath(), addImportToNamespace(), arg, Backslash, baseUrl(), QString::chop(), Colon, QList< T >::constBegin(), QList< T >::constEnd(), dir, QQmlTypeLoader::directoryExists(), QString::endsWith(), QQmlTypeLoader::engine(), error, QQmlTypeLoaderQmldirContent::hasContent(), QQmlTypeLoaderQmldirContent::hasRedirection(), QQmlImportInstance::Implicit, QQmlTypeLoader::importDatabase(), QV4::CompiledData::Import::ImportFile, ImportIncomplete, QQmlImportNamespace::imports, QQmlEngine::interceptUrl(), QUrl::isEmpty(), QString::isEmpty(), QQmlFile::isLocalFile(), QTypeRevision::isValid(), it, lcQmlImport(), QString::left(), QQmlImportNamespace::prefix, Q_ASSERT, qCDebug, QQmlAbstractUrlInterceptor::QmldirFile, qPrintable, Slash, Slash_qmldir, QString::startsWith(), String_qmldir, toString(), QUrl::toString(), QQmlTypeLoaderQmldirContent::typeNamespace(), url, QQmlFile::urlToLocalFileOrQrc(), and validVersion().

+ Here is the call graph for this function:

◆ addImplicitImport()

QQmlImports::addImplicitImport ( QQmlTypeLoader * typeLoader,
QString * localQmldir,
QList< QQmlError > * errors )
inline

Adds an implicit "." file import. This is equivalent to calling addFileImport(), but error messages related to the path or qmldir file not existing are suppressed.

Additionally, this will add the import with lowest instead of highest precedence.

Definition at line 146 of file qqmlimport_p.h.

References baseUrl, QQmlImportInstance::Implicit, lcQmlImport(), Q_ASSERT, qCDebug, qPrintable, and toString().

+ Here is the call graph for this function:

◆ addInlineComponentImport()

bool QQmlImports::addInlineComponentImport ( QQmlImportInstance *const importInstance,
const QString & name,
const QUrl importUrl )

Definition at line 1451 of file qqmlimport.cpp.

References QQmlImportNamespace::imports, QList< T >::push_back(), QQmlImportNamespace::setNeedsSorting(), and QTypeRevision::zero().

+ Here is the call graph for this function:

◆ addLibraryImport()

QTypeRevision QQmlImports::addLibraryImport ( QQmlTypeLoader * typeLoader,
const QString & uri,
const QString & prefix,
QTypeRevision version,
const QString & qmldirIdentifier,
const QString & qmldirUrl,
ImportFlags flags,
quint16 precedence,
QList< QQmlError > * errors )

◆ baseUrl()

QQmlImports::baseUrl ( ) const
inline

Returns the base URL to be used for all relative file imports added.

Definition at line 137 of file qqmlimport_p.h.

Referenced by addFileImport(), addLibraryImport(), QQmlTypeData::allDependenciesDone(), resolvedCompositeSingletons(), and updateQmldirContent().

+ Here is the caller graph for this function:

◆ completeQmldirPaths()

QStringList QQmlImports::completeQmldirPaths ( const QString & uri,
const QStringList & basePaths,
QTypeRevision version )
static

Forms complete paths to a qmldir file, from a base URL, a module URI and version specification.

For example, QtQml.Models 2.0:

  • base/QtQml/Models.2.0/qmldir
  • base/QtQml.2.0/Models/qmldir
  • base/QtQml/Models.2/qmldir
  • base/QtQml.2/Models/qmldir
  • base/QtQml/Models/qmldir

Definition at line 418 of file qqmlimport.cpp.

References qQmlResolveImportPaths(), and Slash_qmldir.

Referenced by QQmlImportDatabase::locateLocalQmldir().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocal() [1/2]

static bool QQmlImports::isLocal ( const QString & url)
inlinestatic

Definition at line 201 of file qqmlimport_p.h.

References url, and QQmlFile::urlToLocalFileOrQrc().

+ Here is the call graph for this function:

◆ isLocal() [2/2]

static bool QQmlImports::isLocal ( const QUrl & url)
inlinestatic

Definition at line 206 of file qqmlimport_p.h.

References url, and QQmlFile::urlToLocalFileOrQrc().

+ Here is the call graph for this function:

◆ populateCache()

void QQmlImports::populateCache ( QQmlTypeNameCache * cache) const

Definition at line 236 of file qqmlimport.cpp.

References cache, QFieldList< N, nextMember >::first(), QFieldList< N, nextMember >::next(), and set.

Referenced by QQmlScriptBlob::done().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolvedCompositeSingletons()

QList< QQmlImports::CompositeSingletonReference > QQmlImports::resolvedCompositeSingletons ( ) const

Definition at line 337 of file qqmlimport.cpp.

References baseUrl(), findCompositeSingletons(), QFieldList< N, nextMember >::first(), QFieldList< N, nextMember >::next(), and set.

+ Here is the call graph for this function:

◆ resolvedScripts()

QList< QQmlImports::ScriptReference > QQmlImports::resolvedScripts ( ) const

Definition at line 372 of file qqmlimport.cpp.

References QFieldList< N, nextMember >::first(), QQmlImports::ScriptReference::nameSpace, QFieldList< N, nextMember >::next(), QUrl::resolved(), and set.

+ Here is the call graph for this function:

◆ resolveType()

bool QQmlImports::resolveType ( QQmlTypeLoader * typeLoader,
const QHashedStringRef & type,
QQmlType * type_return,
QTypeRevision * version_return,
QQmlImportNamespace ** ns_return,
QList< QQmlError > * errors = nullptr,
QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType,
bool * typeRecursionDetected = nullptr ) const

The given (namespace qualified) type is resolved to either \list

If any return pointer is 0, the corresponding search is not done.

See also
addFileImport(), addLibraryImport

Definition at line 452 of file qqmlimport.cpp.

References lcQmlImport(), RESOLVE_TYPE_DEBUG, and resolveType().

Referenced by QQmlPropertyCacheCreator< ObjectContainer >::createMetaObject(), QQmlCustomParser::evaluateEnum(), QQmlPropertyCacheCreator< ObjectContainer >::metaTypeForParameter(), QQmlPropertyCacheCreator< ObjectContainer >::propertyCacheForObject(), QQmlCustomParser::resolveType(), LoadHelper::resolveType(), and resolveType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBaseUrl()

void QQmlImports::setBaseUrl ( const QUrl & url,
const QString & urlString = QString() )

Sets the base URL to be used for all relative file imports added.

Definition at line 209 of file qqmlimport.cpp.

References QString::isEmpty(), QUrl::toString(), and url.

+ Here is the call graph for this function:

◆ setDesignerSupportRequired()

void QQmlImports::setDesignerSupportRequired ( bool b)
static

Definition at line 1472 of file qqmlimport.cpp.

References designerSupportRequired.

◆ updateQmldirContent()

QTypeRevision QQmlImports::updateQmldirContent ( QQmlTypeLoader * typeLoader,
const QString & uri,
const QString & prefix,
const QString & qmldirIdentifier,
const QString & qmldirUrl,
QList< QQmlError > * errors )

Definition at line 1381 of file qqmlimport.cpp.

References arg, baseUrl(), error, QQmlImportNamespace::findImport(), QQmlTypeLoaderQmldirContent::hasContent(), QQmlTypeLoaderQmldirContent::hasRedirection(), QTypeRevision::isValid(), lcQmlImport(), QQmlMetaType::matchingModuleVersion(), Q_ASSERT, qDebug, qPrintable, resolvedUrl(), toString(), and validVersion().

+ Here is the call graph for this function:

◆ urlFromLocalFileOrQrcOrUrl()

QUrl QQmlImports::urlFromLocalFileOrQrcOrUrl ( const QString & file)
static

Definition at line 1462 of file qqmlimport.cpp.

References Colon, file, QUrl::fromLocalFile(), QUrl::scheme(), QString::size(), and url.

Referenced by QQmlImportDatabase::locateLocalQmldir(), and QQmlMetaType::registerPluginTypes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validVersion()

QTypeRevision QQmlImports::validVersion ( QTypeRevision version = QTypeRevision())
static

Definition at line 200 of file qqmlimport.cpp.

References QTypeRevision::fromMinorVersion(), and QTypeRevision::isValid().

Referenced by addFileImport(), addLibraryImport(), QQmlPluginImporter::importDynamicPlugin(), QQmlPluginImporter::importPlugins(), QQmlPluginImporter::importStaticPlugin(), and updateQmldirContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ versionString()

QString QQmlImports::versionString ( QTypeRevision version,
ImportVersion importVersion )
static

Definition at line 427 of file qqmlimport.cpp.

References QString::asprintf(), FullyVersioned, QTypeRevision::majorVersion(), QTypeRevision::minorVersion(), and PartiallyVersioned.

Referenced by versionUriList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QQmlImportDatabase

friend class QQmlImportDatabase
friend

Definition at line 218 of file qqmlimport_p.h.


The documentation for this class was generated from the following files: