Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
void resetTypeLoader ()
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.
bool isAsync () const
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.
template<typename Loader = QQmlTypeLoader>
void assertTypeLoaderThreadIfRunning () const
template<typename Loader = QQmlTypeLoader>
void assertTypeLoaderThread () const
template<typename Loader = QQmlTypeLoader>
void assertEngineThreadIfRunning () const
template<typename Loader = QQmlTypeLoader>
void assertEngineThread () const
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 (const QQmlDataBlob::Ptr &)
 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 (const QQmlDataBlob::Ptr &)
 Called if blob, which was previously waited for, has an error.
virtual void dependencyComplete (const QQmlDataBlob::Ptr &)
 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 58 of file qqmldatablob.cpp.

◆ ~QQmlDataBlob()

QQmlDataBlob::~QQmlDataBlob ( )
virtual

Definition at line 70 of file qqmldatablob.cpp.

Member Function Documentation

◆ addDependency()

void QQmlDataBlob::addDependency ( const QQmlDataBlob::Ptr & 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 326 of file qqmldatablob.cpp.

◆ 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 466 of file qqmldatablob.cpp.

◆ assertEngineThread()

template<typename Loader = QQmlTypeLoader>
void QQmlDataBlob::assertEngineThread ( ) const
inline

Definition at line 128 of file qqmldatablob_p.h.

◆ assertEngineThreadIfRunning()

template<typename Loader = QQmlTypeLoader>
void QQmlDataBlob::assertEngineThreadIfRunning ( ) const
inline

Definition at line 121 of file qqmldatablob_p.h.

◆ assertTypeLoaderThread()

template<typename Loader = QQmlTypeLoader>
void QQmlDataBlob::assertTypeLoaderThread ( ) const
inline

Definition at line 114 of file qqmldatablob_p.h.

◆ assertTypeLoaderThreadIfRunning()

template<typename Loader = QQmlTypeLoader>
void QQmlDataBlob::assertTypeLoaderThreadIfRunning ( ) const
inline

Definition at line 107 of file qqmldatablob_p.h.

◆ 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 LoadHelper, and QQmlNotifyingBlob.

Definition at line 503 of file qqmldatablob.cpp.

◆ dataReceived()

virtual 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 ( const QQmlDataBlob::Ptr & blob)
protectedvirtual

Called if blob, which was previously waited for, has completed.

The default implementation does nothing.

Reimplemented in QQmlTypeLoader::Blob.

Definition at line 454 of file qqmldatablob.cpp.

◆ dependencyError()

void QQmlDataBlob::dependencyError ( const QQmlDataBlob::Ptr & blob)
protectedvirtual

Called if blob, which was previously waited for, has an error.

The default implementation does nothing.

Definition at line 443 of file qqmldatablob.cpp.

◆ 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 LoadHelper, QQmlScriptBlob, and QQmlTypeData.

Definition at line 376 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 QQmlNotifyingBlob.

Definition at line 483 of file qqmldatablob.cpp.

◆ 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 239 of file qqmldatablob.cpp.

◆ 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 216 of file qqmldatablob.cpp.

◆ finalUrlString()

QString QQmlDataBlob::finalUrlString ( ) const

Returns the finalUrl() as a string.

Definition at line 224 of file qqmldatablob.cpp.

◆ initializeFromCachedUnit()

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

◆ isAsync()

bool QQmlDataBlob::isAsync ( ) const

Definition at line 169 of file qqmldatablob.cpp.

◆ isComplete()

bool QQmlDataBlob::isComplete ( ) const

Returns true if the status is Complete.

Definition at line 147 of file qqmldatablob.cpp.

◆ isCompleteOrError()

bool QQmlDataBlob::isCompleteOrError ( ) const

Returns true if the status is Complete or Error.

Definition at line 163 of file qqmldatablob.cpp.

◆ isError()

bool QQmlDataBlob::isError ( ) const

Returns true if the status is Error.

Definition at line 155 of file qqmldatablob.cpp.

◆ isLoading()

bool QQmlDataBlob::isLoading ( ) const

Returns true if the status is Loading.

Definition at line 130 of file qqmldatablob.cpp.

◆ isNull()

bool QQmlDataBlob::isNull ( ) const

Returns true if the status is Null.

Definition at line 122 of file qqmldatablob.cpp.

◆ isWaiting()

bool QQmlDataBlob::isWaiting ( ) const

Returns true if the status is WaitingForDependencies.

Definition at line 138 of file qqmldatablob.cpp.

◆ progress()

qreal QQmlDataBlob::progress ( ) const

Returns the data download progress from 0 to 1.

Definition at line 177 of file qqmldatablob.cpp.

◆ resetTypeLoader()

void QQmlDataBlob::resetTypeLoader ( )
inline

Definition at line 63 of file qqmldatablob_p.h.

◆ 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 268 of file qqmldatablob.cpp.

◆ 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 256 of file qqmldatablob.cpp.

◆ setError() [3/4]

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

Definition at line 300 of file qqmldatablob.cpp.

◆ setError() [4/4]

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

Definition at line 311 of file qqmldatablob.cpp.

◆ startLoading()

void QQmlDataBlob::startLoading ( )

Must be called before loading can occur.

Definition at line 95 of file qqmldatablob.cpp.

◆ status()

QQmlDataBlob::Status QQmlDataBlob::status ( ) const

Returns the blob's status.

Definition at line 114 of file qqmldatablob.cpp.

◆ type()

QQmlDataBlob::Type QQmlDataBlob::type ( ) const

Returns the type provided to the constructor.

Definition at line 106 of file qqmldatablob.cpp.

◆ typeLoader()

QQmlTypeLoader * QQmlDataBlob::typeLoader ( ) const
inline

Definition at line 62 of file qqmldatablob_p.h.

◆ 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 189 of file qqmldatablob.cpp.

◆ urlString()

QString QQmlDataBlob::urlString ( ) const

Definition at line 194 of file qqmldatablob.cpp.

◆ QQmlTypeLoader

friend class QQmlTypeLoader
friend

Definition at line 162 of file qqmldatablob_p.h.

◆ QQmlTypeLoaderThread

friend class QQmlTypeLoaderThread
friend

Definition at line 163 of file qqmldatablob_p.h.

Member Data Documentation

◆ m_typeLoader

QQmlTypeLoader* QQmlDataBlob::m_typeLoader
protected

Definition at line 159 of file qqmldatablob_p.h.

◆ m_waitingOnMe

QList<QQmlDataBlob *> QQmlDataBlob::m_waitingOnMe
protected

Definition at line 273 of file qqmldatablob_p.h.


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