![]() |
Qt 6.x
The Qt SDK
|
The QQmlDataBlob encapsulates a data request that can be issued to a QQmlTypeLoader. More...
#include <qqmldatablob_p.h>
Classes | |
class | SourceCodeData |
Public Types | |
enum | Status { Null , Loading , WaitingForDependencies , ResolvingDependencies , Complete , Error } |
This enum describes the status of the data blob. More... | |
enum | Type { QmlFile = QQmlAbstractUrlInterceptor::QmlFile , JavaScriptFile = QQmlAbstractUrlInterceptor::JavaScriptFile , QmldirFile = QQmlAbstractUrlInterceptor::QmldirFile } |
This enum describes the type of the data blob. More... | |
using | Ptr = QQmlRefPointer< QQmlDataBlob > |
Public Member Functions | |
QQmlDataBlob (const QUrl &, Type, QQmlTypeLoader *manager) | |
Create a new QQmlDataBlob for url and of the provided type. | |
virtual | ~QQmlDataBlob () |
void | startLoading () |
Must be called before loading can occur. | |
QQmlTypeLoader * | typeLoader () const |
Type | type () const |
Returns the type provided to the constructor. | |
Status | status () const |
Returns the blob's status. | |
bool | isNull () const |
Returns true if the status is Null. | |
bool | isLoading () const |
Returns true if the status is Loading. | |
bool | isWaiting () const |
Returns true if the status is WaitingForDependencies. | |
bool | isComplete () const |
Returns true if the status is Complete. | |
bool | isError () const |
Returns true if the status is Error. | |
bool | isCompleteOrError () const |
Returns true if the status is Complete or Error. | |
qreal | progress () const |
Returns the data download progress from 0 to 1. | |
QUrl | url () const |
Returns the physical url of the data. | |
QString | urlString () const |
QUrl | finalUrl () const |
Returns the logical URL to be used for resolving further URLs referred to in the code. | |
QString | finalUrlString () const |
Returns the finalUrl() as a string. | |
QList< QQmlError > | errors () const |
Return the errors on this blob. | |
![]() | |
void | release () const |
![]() | |
QQmlRefCount () | |
void | addref () const |
int | count () const |
Protected Member Functions | |
void | setError (const QQmlError &) |
Mark this blob as having errors. | |
void | setError (const QList< QQmlError > &errors) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | setError (const QQmlJS::DiagnosticMessage &error) |
void | setError (const QString &description) |
void | addDependency (QQmlDataBlob *) |
Wait for blob to become complete or to error. | |
virtual void | dataReceived (const SourceCodeData &)=0 |
Invoked when data for the blob is received. | |
virtual void | initializeFromCachedUnit (const QQmlPrivate::CachedQmlUnit *)=0 |
virtual void | done () |
Invoked once data has either been received or a network error occurred, and all dependencies are complete. | |
virtual void | dependencyError (QQmlDataBlob *) |
Called if blob, which was previously waited for, has an error. | |
virtual void | dependencyComplete (QQmlDataBlob *) |
Called if blob, which was previously waited for, has completed. | |
virtual void | allDependenciesDone () |
Called when all blobs waited for have completed. | |
virtual void | downloadProgressChanged (qreal) |
Called when the download progress of this blob changes. | |
virtual void | completed () |
Invoked on the main thread sometime after done() was called on the load thread. | |
![]() | |
~QQmlRefCounted () | |
Protected Attributes | |
QQmlTypeLoader * | m_typeLoader |
QList< QQmlDataBlob * > | m_waitingOnMe |
Friends | |
class | QQmlTypeLoader |
class | QQmlTypeLoaderThread |
The QQmlDataBlob encapsulates a data request that can be issued to a QQmlTypeLoader.
QQmlDataBlob's are loaded by a QQmlTypeLoader. The user creates the QQmlDataBlob and then calls QQmlTypeLoader::load() or QQmlTypeLoader::loadWithStaticData() to load it. The QQmlTypeLoader invokes callbacks on the QQmlDataBlob as data becomes available.
Definition at line 38 of file qqmldatablob_p.h.
using QQmlDataBlob::Ptr = QQmlRefPointer<QQmlDataBlob> |
Definition at line 41 of file qqmldatablob_p.h.
enum QQmlDataBlob::Status |
This enum describes the status of the data blob.
\value Null The blob has not yet been loaded by a QQmlTypeLoader \value Loading The blob is loading network data. The QQmlDataBlob::setData() callback has not yet been invoked or has not yet returned. \value WaitingForDependencies The blob is waiting for dependencies to be done before continuing. This status only occurs after the QQmlDataBlob::setData() callback has been made, and when the blob has outstanding dependencies. \value Complete The blob's data has been loaded and all dependencies are done. \value Error An error has been set on this blob.
Enumerator | |
---|---|
Null | |
Loading | |
WaitingForDependencies | |
ResolvingDependencies | |
Complete | |
Error |
Definition at line 43 of file qqmldatablob_p.h.
enum QQmlDataBlob::Type |
This enum describes the type of the data blob.
\value QmlFile This is a QQmlTypeData \value JavaScriptFile This is a QQmlScriptData \value QmldirFile This is a QQmlQmldirData
Enumerator | |
---|---|
QmlFile | |
JavaScriptFile | |
QmldirFile |
Definition at line 52 of file qqmldatablob_p.h.
QQmlDataBlob::QQmlDataBlob | ( | const QUrl & | url, |
Type | type, | ||
QQmlTypeLoader * | manager | ||
) |
Create a new QQmlDataBlob for url and of the provided type.
Definition at line 65 of file qqmldatablob.cpp.
References QQmlTypeLoader::engine(), QQmlEngine::interceptUrl(), m_typeLoader, and qmlEngine().
|
virtual |
Definition at line 75 of file qqmldatablob.cpp.
References QList< T >::isEmpty(), m_waitingOnMe, and Q_ASSERT.
|
protected |
Wait for blob to become complete or to error.
If blob is already complete or in error, or this blob is already complete, this has no effect.
The setError() method may only be called from within a QQmlDataBlob callback.
Definition at line 303 of file qqmldatablob.cpp.
References QList< T >::append(), ASSERT_CALLBACK, Complete, Error, QListSpecialMethodsBase< T >::indexOf(), m_waitingOnMe, Null, Q_ASSERT, qCWarning, status(), QUrl::toString(), url(), and WaitingForDependencies.
|
protectedvirtual |
Called when all blobs waited for have completed.
This occurs regardless of whether they are in error, or complete state.
The default implementation does nothing.
Reimplemented in QQmlTypeData.
Definition at line 436 of file qqmldatablob.cpp.
References ResolvingDependencies.
Referenced by QQmlTypeData::allDependenciesDone().
|
protectedvirtual |
Invoked on the main thread sometime after done() was called on the load thread.
You cannot modify the blobs state at all in this callback and cannot depend on the order or timeliness of these callbacks. Implementors should use this callback to notify dependencies on the main thread that the blob is done and not a lot else.
This callback is only invoked if an asynchronous load for this blob is made. An asynchronous load is one in which the Asynchronous mode is specified explicitly, or one that is implicitly delayed due to a network operation.
The default implementation does nothing.
Reimplemented in QQmlTypeData.
Definition at line 471 of file qqmldatablob.cpp.
|
protectedpure virtual |
Invoked when data for the blob is received.
Implementors should use this callback to determine a blob's dependencies. Within this callback you may call setError() or addDependency().
Implemented in LoadHelper, QQmlQmldirData, QQmlScriptBlob, and QQmlTypeData.
|
protectedvirtual |
Called if blob, which was previously waited for, has completed.
The default implementation does nothing.
Reimplemented in QQmlTypeLoader::Blob.
Definition at line 425 of file qqmldatablob.cpp.
References Q_UNUSED.
|
protectedvirtual |
Called if blob, which was previously waited for, has an error.
The default implementation does nothing.
Definition at line 415 of file qqmldatablob.cpp.
References Q_UNUSED.
|
protectedvirtual |
Invoked once data has either been received or a network error occurred, and all dependencies are complete.
You can set an error in this method, but you cannot add new dependencies. Implementors should use this callback to finalize processing of data.
The default implementation does nothing.
XXX Rename processData() or some such to avoid confusion between done() (processing thread) and completed() (main thread)
Reimplemented in QQmlScriptBlob, and QQmlTypeData.
Definition at line 351 of file qqmldatablob.cpp.
Called when the download progress of this blob changes.
progress goes from 0 to 1.
This callback is only invoked if an asynchronous load for this blob is made. An asynchronous load is one in which the Asynchronous mode is specified explicitly, or one that is implicitly delayed due to a network operation.
The default implementation does nothing.
Reimplemented in QQmlTypeData.
Definition at line 452 of file qqmldatablob.cpp.
References progress(), and Q_UNUSED.
Return the errors on this blob.
May only be called from the load thread, or after the blob isCompleteOrError().
Definition at line 221 of file qqmldatablob.cpp.
References isCompleteOrError(), QQmlThread::isThisThread(), m_typeLoader, and Q_ASSERT.
Referenced by QQmlTypeData::allDependenciesDone(), QQmlScriptBlob::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), LoadHelper::resolveType(), setError(), and setError().
QUrl QQmlDataBlob::finalUrl | ( | ) | const |
Returns the logical URL to be used for resolving further URLs referred to in the code.
This is the blob url passed to the constructor. If a URL interceptor rewrites the URL, this one stays the same. If a network redirect happens while fetching the data, this url is updated to reflect the new location. Therefore, if both an interception and a redirection happen, the final url will indirectly incorporate the result of the interception, potentially breaking further lookups.
Definition at line 200 of file qqmldatablob.cpp.
Referenced by QQmlTypeData::done(), and QQmlTypeCompiler::url().
QString QQmlDataBlob::finalUrlString | ( | ) | const |
Returns the finalUrl() as a string.
Definition at line 208 of file qqmldatablob.cpp.
References QString::isEmpty(), and QUrl::toString().
Referenced by QQmlTypeCompiler::compile(), QQmlScriptBlob::dataReceived(), QQmlScriptBlob::initializeFromCachedUnit(), and QQmlTypeData::initializeFromCachedUnit().
|
protectedpure virtual |
Implemented in LoadHelper, QQmlQmldirData, QQmlScriptBlob, and QQmlTypeData.
bool QQmlDataBlob::isComplete | ( | ) | const |
Returns true if the status is Complete.
Definition at line 135 of file qqmldatablob.cpp.
References Complete, and status().
Referenced by QQmlTypeLoader::trimCache().
bool QQmlDataBlob::isCompleteOrError | ( | ) | const |
Returns true if the status is Complete or Error.
Definition at line 151 of file qqmldatablob.cpp.
References Complete, Error, and status().
Referenced by QQmlScriptBlob::done(), QQmlTypeData::done(), errors(), and QQmlTypeLoader::getType().
bool QQmlDataBlob::isError | ( | ) | const |
Returns true if the status is Error.
Definition at line 143 of file qqmldatablob.cpp.
References Error, and status().
Referenced by QQmlTypeData::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), and QQmlTypeLoader::trimCache().
bool QQmlDataBlob::isLoading | ( | ) | const |
Returns true if the status is Loading.
Definition at line 118 of file qqmldatablob.cpp.
References Loading, and status().
bool QQmlDataBlob::isNull | ( | ) | const |
Returns true if the status is Null.
Definition at line 110 of file qqmldatablob.cpp.
References Null, and status().
bool QQmlDataBlob::isWaiting | ( | ) | const |
Returns true if the status is WaitingForDependencies.
Definition at line 126 of file qqmldatablob.cpp.
References ResolvingDependencies, status(), and WaitingForDependencies.
qreal QQmlDataBlob::progress | ( | ) | const |
Returns the data download progress from 0 to 1.
Definition at line 160 of file qqmldatablob.cpp.
Referenced by downloadProgressChanged().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 247 of file qqmldatablob.cpp.
References QList< T >::append(), ASSERT_CALLBACK, QList< T >::at(), error, Error, errors(), QList< T >::isEmpty(), Q_ASSERT, qPrintable, qWarning, QList< T >::reserve(), QQmlError::setUrl(), QList< T >::size(), status(), QQmlError::toString(), url(), and urlString().
Mark this blob as having errors.
All outstanding dependencies will be cancelled. Requests to add new dependencies will be ignored. Entry into the Error state is irreversable.
The setError() method may only be called from within a QQmlDataBlob callback.
Definition at line 235 of file qqmldatablob.cpp.
References ASSERT_CALLBACK, errors(), and setError().
Referenced by QQmlTypeData::allDependenciesDone(), QQmlQmldirData::dataReceived(), QQmlScriptBlob::dataReceived(), QQmlTypeData::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), setError(), setError(), and setError().
|
protected |
Definition at line 279 of file qqmldatablob.cpp.
References e, error, qmlConvertSourceCoordinate< quint32, int >(), setError(), and url().
Definition at line 289 of file qqmldatablob.cpp.
References e, setError(), and url().
void QQmlDataBlob::startLoading | ( | ) |
QQmlDataBlob::Status QQmlDataBlob::status | ( | ) | const |
Returns the blob's status.
Definition at line 102 of file qqmldatablob.cpp.
Referenced by addDependency(), isComplete(), isCompleteOrError(), isError(), isLoading(), isNull(), isWaiting(), setError(), and startLoading().
QQmlDataBlob::Type QQmlDataBlob::type | ( | ) | const |
Returns the type provided to the constructor.
Definition at line 94 of file qqmldatablob.cpp.
Referenced by QQmlTypeLoader::Blob::dependencyComplete(), QQmlTypeData::done(), and LoadHelper::resolveType().
|
inline |
Definition at line 63 of file qqmldatablob_p.h.
Referenced by QQmlTypeData::done().
QUrl QQmlDataBlob::url | ( | ) | const |
Returns the physical url of the data.
Initially this is the same as finalUrl(), but if a URL interceptor is set, it will work on this URL and leave finalUrl() alone.
Definition at line 174 of file qqmldatablob.cpp.
Referenced by addDependency(), QQmlScriptBlob::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), QQmlTypeLoader::getScript(), QQmlTypeLoader::getType(), setError(), setError(), and setError().
QString QQmlDataBlob::urlString | ( | ) | const |
Definition at line 179 of file qqmldatablob.cpp.
References QString::isEmpty(), and QUrl::toString().
Referenced by QQmlTypeCompiler::compile(), QQmlScriptBlob::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), QQmlScriptBlob::initializeFromCachedUnit(), QQmlTypeData::initializeFromCachedUnit(), and setError().
|
friend |
Definition at line 131 of file qqmldatablob_p.h.
|
friend |
Definition at line 132 of file qqmldatablob_p.h.
|
protected |
Definition at line 128 of file qqmldatablob_p.h.
Referenced by QQmlDataBlob(), and errors().
|
protected |
Definition at line 219 of file qqmldatablob_p.h.
Referenced by ~QQmlDataBlob(), and addDependency().