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
QQmlDataBlob Class Referenceabstract

The QQmlDataBlob encapsulates a data request that can be issued to a QQmlTypeLoader. More...

#include <qqmldatablob_p.h>

+ Inheritance diagram for QQmlDataBlob:
+ Collaboration diagram for QQmlDataBlob:

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.
 
QQmlTypeLoadertypeLoader () 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< QQmlErrorerrors () const
 Return the errors on this blob.
 
- Public Member Functions inherited from QQmlRefCounted< QQmlDataBlob >
void release () const
 
- Public Member Functions inherited from QQmlRefCount
 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.
 
- Protected Member Functions inherited from QQmlRefCounted< QQmlDataBlob >
 ~QQmlRefCounted ()
 

Protected Attributes

QQmlTypeLoaderm_typeLoader
 
QList< QQmlDataBlob * > m_waitingOnMe
 

Friends

class QQmlTypeLoader
 
class QQmlTypeLoaderThread
 

Detailed Description

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 37 of file qqmldatablob_p.h.

Member Typedef Documentation

◆ Ptr

Definition at line 40 of file qqmldatablob_p.h.

Member Enumeration Documentation

◆ 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 42 of file qqmldatablob_p.h.

◆ 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 51 of file qqmldatablob_p.h.

Constructor & Destructor Documentation

◆ QQmlDataBlob()

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().

+ Here is the call graph for this function:

◆ ~QQmlDataBlob()

QQmlDataBlob::~QQmlDataBlob ( )
virtual

Definition at line 75 of file qqmldatablob.cpp.

References QList< T >::isEmpty(), m_waitingOnMe, and Q_ASSERT.

+ Here is the call graph for this function:

Member Function Documentation

◆ addDependency()

void QQmlDataBlob::addDependency ( QQmlDataBlob * blob)
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.

+ Here is the call graph for this function:

◆ allDependenciesDone()

void QQmlDataBlob::allDependenciesDone ( )
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().

+ Here is the caller graph for this function:

◆ completed()

void QQmlDataBlob::completed ( )
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.

◆ dataReceived()

void QQmlDataBlob::dataReceived ( const SourceCodeData & )
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.

◆ dependencyComplete()

void QQmlDataBlob::dependencyComplete ( QQmlDataBlob * blob)
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.

◆ dependencyError()

void QQmlDataBlob::dependencyError ( QQmlDataBlob * blob)
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.

◆ done()

void QQmlDataBlob::done ( )
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.

◆ downloadProgressChanged()

void QQmlDataBlob::downloadProgressChanged ( qreal progress)
protectedvirtual

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.

+ Here is the call graph for this function:

◆ errors()

QList< QQmlError > QQmlDataBlob::errors ( ) const

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().

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

◆ finalUrl()

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.

See also
url()

Definition at line 200 of file qqmldatablob.cpp.

Referenced by QQmlTypeData::done(), and QQmlTypeCompiler::url().

+ Here is the caller graph for this function:

◆ finalUrlString()

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().

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

◆ initializeFromCachedUnit()

virtual void QQmlDataBlob::initializeFromCachedUnit ( const QQmlPrivate::CachedQmlUnit * )
protectedpure virtual

◆ isComplete()

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().

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

◆ isCompleteOrError()

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().

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

◆ isError()

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().

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

◆ isLoading()

bool QQmlDataBlob::isLoading ( ) const

Returns true if the status is Loading.

Definition at line 118 of file qqmldatablob.cpp.

References Loading, and status().

+ Here is the call graph for this function:

◆ isNull()

bool QQmlDataBlob::isNull ( ) const

Returns true if the status is Null.

Definition at line 110 of file qqmldatablob.cpp.

References Null, and status().

+ Here is the call graph for this function:

◆ isWaiting()

bool QQmlDataBlob::isWaiting ( ) const

Returns true if the status is WaitingForDependencies.

Definition at line 126 of file qqmldatablob.cpp.

References ResolvingDependencies, status(), and WaitingForDependencies.

+ Here is the call graph for this function:

◆ progress()

qreal QQmlDataBlob::progress ( ) const

Returns the data download progress from 0 to 1.

Definition at line 160 of file qqmldatablob.cpp.

Referenced by downloadProgressChanged().

+ Here is the caller graph for this function:

◆ setError() [1/4]

void QQmlDataBlob::setError ( const QList< QQmlError > & errors)
protected

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(), QList< T >::size(), status(), QQmlError::toString(), url(), and urlString().

+ Here is the call graph for this function:

◆ setError() [2/4]

void QQmlDataBlob::setError ( const QQmlError & errors)
protected

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().

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

◆ setError() [3/4]

void QQmlDataBlob::setError ( const QQmlJS::DiagnosticMessage & error)
protected

Definition at line 279 of file qqmldatablob.cpp.

References error, QQmlError::setColumn(), QQmlError::setDescription(), setError(), QQmlError::setLine(), QQmlError::setUrl(), and url().

+ Here is the call graph for this function:

◆ setError() [4/4]

void QQmlDataBlob::setError ( const QString & description)
protected

Definition at line 289 of file qqmldatablob.cpp.

References QQmlError::setDescription(), setError(), QQmlError::setUrl(), and url().

+ Here is the call graph for this function:

◆ startLoading()

void QQmlDataBlob::startLoading ( )

Must be called before loading can occur.

Definition at line 85 of file qqmldatablob.cpp.

References Loading, Null, Q_ASSERT, and status().

+ Here is the call graph for this function:

◆ status()

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().

+ Here is the caller graph for this function:

◆ type()

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().

+ Here is the caller graph for this function:

◆ typeLoader()

QQmlTypeLoader * QQmlDataBlob::typeLoader ( ) const
inline

Definition at line 62 of file qqmldatablob_p.h.

Referenced by QQmlTypeData::done(), and LoadHelper::resolveType().

+ Here is the caller graph for this function:

◆ url()

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.

See also
finalUrl()

Definition at line 174 of file qqmldatablob.cpp.

Referenced by addDependency(), QQmlScriptBlob::dataReceived(), QQmlScriptBlob::done(), QQmlTypeData::done(), QQmlTypeLoader::getType(), setError(), setError(), and setError().

+ Here is the caller graph for this function:

◆ urlString()

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().

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

Friends And Related Symbol Documentation

◆ QQmlTypeLoader

friend class QQmlTypeLoader
friend

Definition at line 130 of file qqmldatablob_p.h.

◆ QQmlTypeLoaderThread

friend class QQmlTypeLoaderThread
friend

Definition at line 131 of file qqmldatablob_p.h.

Member Data Documentation

◆ m_typeLoader

QQmlTypeLoader* QQmlDataBlob::m_typeLoader
protected

Definition at line 127 of file qqmldatablob_p.h.

Referenced by QQmlDataBlob(), and errors().

◆ m_waitingOnMe

QList<QQmlDataBlob *> QQmlDataBlob::m_waitingOnMe
protected

Definition at line 218 of file qqmldatablob_p.h.

Referenced by ~QQmlDataBlob(), and addDependency().


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