![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QQmlTypeLoader class abstracts loading files and their dependencies over the network. More...
#include <qqmltypeloader_p.h>
Classes | |
| class | Blob |
Public Types | |
| enum | Mode { PreferSynchronous , Asynchronous , Synchronous } |
| enum | AddPathMode { PrependPath , AppendPath } |
| using | ChecksumCache = QQmlTypeLoaderThreadData::ChecksumCache |
Public Member Functions | |
| QQmlTypeLoader (QV4::ExecutionEngine *engine) | |
| Constructs a new type loader that uses the given engine. | |
| ~QQmlTypeLoader () | |
| Destroys the type loader, first clearing the cache of any information about loaded files. | |
| template<typename TypeReference> | |
| QByteArray | hashDependencies (QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypeCache, const QList< TypeReference > &compositeSingletons) |
| QQmlRefPointer< QQmlTypeData > | getType (const QUrl &unNormalizedUrl, Mode modemode=PreferSynchronous) |
| Returns a QQmlTypeData for the specified url. | |
| QQmlRefPointer< QQmlTypeData > | getType (const QByteArray &datadata, const QUrl &url, Mode modemode=PreferSynchronous) |
| Returns a QQmlTypeData for the given data with the provided base url. | |
| QQmlRefPointer< QQmlScriptBlob > | getScript (const QUrl &unNormalizedUrl, Mode modemode=PreferSynchronous) |
| QQmlRefPointer< QV4::CompiledData::CompilationUnit > | injectModule (const QUrl &relativeUrl, const QV4::CompiledData::Unit *unit) |
| QQmlRefPointer< QQmlScriptBlob > | getScript (const QUrl &unNormalizedUrl, const QUrl &relativeUrl) |
| Return a QQmlScriptBlob for unNormalizedUrl or relativeUrl. | |
| QQmlRefPointer< QQmlQmldirData > | getQmldir (const QUrl &) |
| Returns a QQmlQmldirData for url. | |
| QString | cleanFilePath (const QString &pathpath) const |
| Returns the clean filename of path via a directory cache. | |
| bool | fileExists (const QString &filePath) const |
| bool | fileExists (const QString &dirPath, const QString &file) const |
| bool | directoryExists (const QString &pathpath) const |
| Returns true if the path is a directory via a directory cache. | |
| const QQmlTypeLoaderQmldirContent | qmldirContent (const QString &filePath) |
| void | setQmldirContent (const QString &filePath, const QString &content) |
| void | clearCache () |
| Clears cached information about loaded files, including any type data, scripts and qmldir information. | |
| void | trimCache () |
| bool | removeFromCache (const QUrl &url) |
| bool | isTypeLoaded (const QUrl &url) const |
| bool | isScriptLoaded (const QUrl &url) const |
| void | loadWithStaticData (const QQmlDataBlob::Ptr &blob, const QByteArray &datadata, Mode modemode=PreferSynchronous) |
| Load the provided blob with data. | |
| void | drop (const QQmlDataBlob::Ptr &blob) |
| void | initializeEngine (QQmlEngineExtensionInterface *, const char *) |
| void | initializeEngine (QQmlExtensionInterface *, const char *) |
| void | invalidate () |
| void | addUrlInterceptor (QQmlAbstractUrlInterceptor *urlInterceptor) |
| void | removeUrlInterceptor (QQmlAbstractUrlInterceptor *urlInterceptor) |
| QList< QQmlAbstractUrlInterceptor * > | urlInterceptors () const |
| QUrl | interceptUrl (const QUrl &url, QQmlAbstractUrlInterceptor::DataType typetype) const |
| bool | hasUrlInterceptors () const |
| quintptr | profiler () const |
| void | setProfiler (quintptr) |
| QStringList | importPathList () const |
| void | setImportPathList (const QStringList &pathspaths) |
| void | addImportPath (const QString &dir, AddPathMode modemode) |
| QStringList | pluginPathList () const |
| void | setPluginPathList (const QStringList &pathspaths) |
| void | addPluginPath (const QString &pathpath, AddPathMode modemode) |
| void | setPluginInitialized (const QString &plugin) |
| bool | isPluginInitialized (const QString &plugin) const |
| void | setModulePluginProcessingDone (const QString &module) |
| bool | isModulePluginProcessingDone (const QString &module) |
| bool | writeCacheFile () |
| bool | readCacheFile () |
| bool | isDebugging () |
Static Public Member Functions | |
| template<typename Engine, typename EnginePrivate = QQmlEnginePrivate, typename = std::enable_if_t<std::is_base_of_v<QJSEngine, Engine>>> | |
| static QQmlTypeLoader * | get (Engine *engine) |
| template<typename Engine, typename = std::enable_if_t<std::is_base_of_v<QJSEnginePrivate, Engine>>> | |
| static QQmlTypeLoader * | get (Engine *engine) |
| static void | sanitizeUNCPath (QString *pathpath) |
| static bool | isResource (const QString &pathpath) |
Friends | |
| struct | PlainLoader |
| struct | CachedLoader |
| struct | StaticLoader |
| class | QQmlDataBlob |
| class | QQmlTypeLoaderThread |
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
The QQmlTypeLoader class is provided for the exclusive use of the QQmlTypeLoader class.
Clients create QQmlDataBlob instances and submit them to the QQmlTypeLoader class through the QQmlTypeLoader::load() or QQmlTypeLoader::loadWithStaticData() methods. The loader then fetches the data over the network or from the local file system in an efficient way. QQmlDataBlob is an abstract class, so should always be specialized.
Once data is received, the QQmlDataBlob::dataReceived() method is invoked on the blob. The derived class should use this callback to process the received data. Processing of the data can result in an error being set (QQmlDataBlob::setError()), or one or more dependencies being created (QQmlDataBlob::addDependency()). Dependencies are other QQmlDataBlob's that are required before processing can fully complete.
To complete processing, the QQmlDataBlob::done() callback is invoked. done() is called when one of these three preconditions are met.
\list 1
Thus QQmlDataBlob::done() will always eventually be called, even if the blob has an error set.
Definition at line 46 of file qqmltypeloader_p.h.
Definition at line 50 of file qqmltypeloader_p.h.
| Enumerator | |
|---|---|
| PrependPath | |
| AppendPath | |
Definition at line 259 of file qqmltypeloader_p.h.
| enum QQmlTypeLoader::Mode |
| Enumerator | |
|---|---|
| PreferSynchronous | |
| Asynchronous | |
| Synchronous | |
Definition at line 51 of file qqmltypeloader_p.h.
| QQmlTypeLoader::QQmlTypeLoader | ( | QV4::ExecutionEngine * | engine | ) |
Constructs a new type loader that uses the given engine.
Definition at line 1284 of file qqmltypeloader.cpp.
| QQmlTypeLoader::~QQmlTypeLoader | ( | ) |
Destroys the type loader, first clearing the cache of any information about loaded files.
Definition at line 1341 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::addImportPath | ( | const QString & | path, |
| AddPathMode | mode ) |
Definition at line 562 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::addPluginPath | ( | const QString & | path, |
| AddPathMode | mode ) |
Definition at line 635 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::addUrlInterceptor | ( | QQmlAbstractUrlInterceptor * | urlInterceptor | ) |
Definition at line 90 of file qqmltypeloader.cpp.
Returns the clean filename of path via a directory cache.
Returns a empty string if the path does not exist.
Why a directory cache? QML checks for files in many paths with invalid directories. By caching whether a directory exists we avoid many stats. We also cache the files' existence in the directory, for the same reason.
Definition at line 1562 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::clearCache | ( | ) |
Clears cached information about loaded files, including any type data, scripts and qmldir information.
Definition at line 1745 of file qqmltypeloader.cpp.
Referenced by QQmlPreviewServiceImpl::messageReceived().
| bool QQmlTypeLoader::directoryExists | ( | const QString & | path | ) | const |
Returns true if the path is a directory via a directory cache.
Cache is shared with cleanFilePath().
Definition at line 1628 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::drop | ( | const QQmlDataBlob::Ptr & | blob | ) |
Definition at line 267 of file qqmltypeloader.cpp.
Definition at line 1591 of file qqmltypeloader.cpp.
|
inline |
Definition at line 210 of file qqmltypeloader_p.h.
|
inlinestatic |
Definition at line 160 of file qqmltypeloader_p.h.
|
inlinestatic |
Definition at line 152 of file qqmltypeloader_p.h.
| QQmlRefPointer< QQmlQmldirData > QQmlTypeLoader::getQmldir | ( | const QUrl & | url | ) |
Returns a QQmlQmldirData for url.
The QQmlQmldirData may be cached.
Definition at line 1519 of file qqmltypeloader.cpp.
| QQmlRefPointer< QQmlScriptBlob > QQmlTypeLoader::getScript | ( | const QUrl & | unNormalizedUrl, |
| const QUrl & | relativeUrl ) |
Return a QQmlScriptBlob for unNormalizedUrl or relativeUrl.
This assumes PreferSynchronous, and therefore the result may not be ready yet.
Definition at line 1482 of file qqmltypeloader.cpp.
| QQmlRefPointer< QQmlScriptBlob > QQmlTypeLoader::getScript | ( | const QUrl & | unNormalizedUrl, |
| Mode | mode = PreferSynchronous ) |
Definition at line 1433 of file qqmltypeloader.cpp.
| QQmlRefPointer< QQmlTypeData > QQmlTypeLoader::getType | ( | const QByteArray & | data, |
| const QUrl & | url, | ||
| Mode | mode = PreferSynchronous ) |
Returns a QQmlTypeData for the given data with the provided base url.
The QQmlTypeData will not be cached.
Definition at line 1418 of file qqmltypeloader.cpp.
| QQmlRefPointer< QQmlTypeData > QQmlTypeLoader::getType | ( | const QUrl & | unNormalizedUrl, |
| Mode | mode = PreferSynchronous ) |
Returns a QQmlTypeData for the specified url.
The QQmlTypeData may be cached.
Definition at line 1384 of file qqmltypeloader.cpp.
|
inline |
Definition at line 180 of file qqmltypeloader_p.h.
| bool QQmlTypeLoader::hasUrlInterceptors | ( | ) | const |
Definition at line 129 of file qqmltypeloader.cpp.
|
inline |
Definition at line 261 of file qqmltypeloader_p.h.
| void QQmlTypeLoader::initializeEngine | ( | QQmlEngineExtensionInterface * | iface, |
| const char * | uri ) |
Definition at line 429 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::initializeEngine | ( | QQmlExtensionInterface * | iface, |
| const char * | uri ) |
Definition at line 435 of file qqmltypeloader.cpp.
| QQmlRefPointer< QV4::CompiledData::CompilationUnit > QQmlTypeLoader::injectModule | ( | const QUrl & | relativeUrl, |
| const QV4::CompiledData::Unit * | unit ) |
Definition at line 1459 of file qqmltypeloader.cpp.
| QUrl QQmlTypeLoader::interceptUrl | ( | const QUrl & | url, |
| QQmlAbstractUrlInterceptor::DataType | type ) const |
Definition at line 121 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::invalidate | ( | ) |
Definition at line 75 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::isDebugging | ( | ) |
Definition at line 1223 of file qqmltypeloader.cpp.
|
inline |
Definition at line 293 of file qqmltypeloader_p.h.
|
inline |
Definition at line 282 of file qqmltypeloader_p.h.
|
static |
Definition at line 1542 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::isScriptLoaded | ( | const QUrl & | url | ) | const |
Definition at line 1863 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::isTypeLoaded | ( | const QUrl & | url | ) | const |
Definition at line 1857 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::loadWithStaticData | ( | const QQmlDataBlob::Ptr & | blob, |
| const QByteArray & | data, | ||
| Mode | mode = PreferSynchronous ) |
Load the provided blob with data.
The blob's URL is not used by the data loader in this case.
The loader must be locked.
Definition at line 253 of file qqmltypeloader.cpp.
|
inline |
Definition at line 269 of file qqmltypeloader_p.h.
|
inline |
Definition at line 248 of file qqmltypeloader_p.h.
| const QQmlTypeLoaderQmldirContent QQmlTypeLoader::qmldirContent | ( | const QString & | filePathIn | ) |
Return a QQmlTypeLoaderQmldirContent for filePathIn. The QQmlTypeLoaderQmldirContent may be cached.
It can also be a remote path for a remote directory import, but it will have been cached by now in this case.
Definition at line 1659 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::readCacheFile | ( | ) |
Definition at line 1228 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::removeFromCache | ( | const QUrl & | url | ) |
Remove any cached artifacts for url.
Returns true if anything was removed, or false otherwise.
Definition at line 1777 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::removeUrlInterceptor | ( | QQmlAbstractUrlInterceptor * | urlInterceptor | ) |
Definition at line 97 of file qqmltypeloader.cpp.
Definition at line 165 of file qqmltypeloader_p.h.
| void QQmlTypeLoader::setImportPathList | ( | const QStringList & | paths | ) |
Definition at line 608 of file qqmltypeloader.cpp.
Definition at line 288 of file qqmltypeloader_p.h.
Definition at line 277 of file qqmltypeloader_p.h.
| void QQmlTypeLoader::setPluginPathList | ( | const QStringList & | paths | ) |
Definition at line 625 of file qqmltypeloader.cpp.
Definition at line 249 of file qqmltypeloader_p.h.
Definition at line 1714 of file qqmltypeloader.cpp.
| void QQmlTypeLoader::trimCache | ( | ) |
Definition at line 1785 of file qqmltypeloader.cpp.
| QList< QQmlAbstractUrlInterceptor * > QQmlTypeLoader::urlInterceptors | ( | ) | const |
Definition at line 104 of file qqmltypeloader.cpp.
| bool QQmlTypeLoader::writeCacheFile | ( | ) |
Definition at line 1233 of file qqmltypeloader.cpp.
|
friend |
Definition at line 313 of file qqmltypeloader_p.h.
|
friend |
Definition at line 312 of file qqmltypeloader_p.h.
|
friend |
Definition at line 316 of file qqmltypeloader_p.h.
|
friend |
Definition at line 317 of file qqmltypeloader_p.h.
|
friend |
Definition at line 314 of file qqmltypeloader_p.h.