44 #include <private/qdeclarativeengine_p.h> 45 #include <private/qdeclarativecompiler_p.h> 46 #include <private/qdeclarativecomponent_p.h> 47 #include <private/qdeclarativeglobal_p.h> 48 #include <private/qdeclarativedebugtrace_p.h> 50 #include <QtDeclarative/qdeclarativecomponent.h> 51 #include <QtCore/qdebug.h> 52 #include <QtCore/qdir.h> 53 #include <QtCore/qdiriterator.h> 54 #include <QtCore/qfile.h> 74 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) 135 : m_type(type), m_status(
Null), m_progress(0), m_url(url), m_finalUrl(url), m_manager(0),
136 m_redirectCount(0), m_inCallback(false), m_isDone(false)
331 switch (networkError) {
333 errorString =
"Network error";
336 errorString =
"Connection refused";
339 errorString =
"Remote host closed the connection";
342 errorString =
"Host not found";
345 errorString =
"Timeout";
353 errorString =
"Proxy error";
356 errorString =
"Access denied";
359 errorString =
"File not found";
362 errorString =
"Authentication required";
465 m_inCallback =
false;
579 #define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16 604 if (reply->
error()) {
626 if (bytesTotal != 0) {
627 blob->
m_progress = bytesReceived / bytesTotal;
794 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) 799 int lastSlash = lowPath.lastIndexOf(
QLatin1Char(
'/'));
832 qmldirParser->
parse();
866 :
QDeclarativeDataBlob(url, QmlFile), m_options(options), m_imports(manager), m_typesResolved(false),
867 m_compiledData(0), m_typeLoader(manager)
873 for (
int ii = 0; ii <
m_scripts.count(); ++ii)
877 for (
int ii = 0; ii <
m_types.count(); ++ii)
1006 ref.
location =
import.location.start;
1034 for (
int ii = 0; ii <
m_callbacks.count(); ++ii) {
1072 qmldircomponentsnetwork = qmldir->dirComponents();
1078 if (!
import.version.isEmpty()) {
1081 vmaj =
import.version.toInt();
1084 vmaj =
import.version.left(dot).toInt();
1085 vmin =
import.version.mid(dot+1).toInt();
1091 vmaj, vmin,
import.type, qmldircomponentsnetwork, &errorString)) {
1103 bool implicitImportLoaded =
false;
1116 &typeNamespace, &errorString) || typeNamespace) {
1120 bool typeFound =
false;
1122 if (!typeNamespace && !implicitImportLoaded) {
1123 implicitImportLoaded =
true;
1132 qmldir->dirComponents(), 0);
1139 &typeNamespace, &errorString) || typeNamespace) {
const QDeclarativeImports & imports() const
The QVariant class acts like a union for the most common Qt data types.
static QString urlToLocalFileOrQrc(const QUrl &url)
The QDeclarativeDataBlob encapsulates a data request that can be issued to a QDeclarativeDataLoader.
virtual void downloadProgressChanged(qreal)
Called when the download progress of this blob changes.
QDeclarativeTypeLoader * typeLoader() const
QString scriptSource() const
bool isError() const
Returns true if the status is Error.
QDeclarativeEngine * m_engine
static void callback(AuServer *, AuEventHandlerRec *, AuEvent *e, AuPointer p)
QDeclarativeQmldirData * getQmldir(const QUrl &)
Returns a QDeclarativeQmldirData for url.
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
NetworkError error() const
Returns the error that was found during the processing of this request.
#define QT_END_NAMESPACE
This macro expands to.
Status
This enum describes the status of the data blob.
bool hasNext() const
Returns true if there is at least one more entry in the directory; otherwise, false is returned...
void clear()
Removes all items from the hash.
void setDescription(const QString &)
Sets the error description.
QDeclarativeDataLoader * m_manager
const QChar at(int i) const
Returns the character at the given index position in the string.
void networkReplyFinished()
QUrl finalUrl() const
Returns the final url of the data.
QList< QDeclarativeError > m_errors
QDeclarativeParser::Object::ScriptBlock::Pragmas m_pragmas
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
virtual void done()
Invoked once data has either been received or a network error occurred, and all dependencies are comp...
#define it(className, varName)
void cancelAllWaitingFor()
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
virtual void dependencyComplete(QDeclarativeDataBlob *)
Called if blob, which was previously waited for, has completed.
QVariant attribute(QNetworkRequest::Attribute code) const
Returns the attribute associated with the code code.
bool addImport(QDeclarativeImportDatabase *, const QString &uri, const QString &prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType, const QDeclarativeDirComponents &qmldircomponentsnetwork, QString *errorString)
Adds information to imports such that subsequent calls to resolveType() will resolve types qualified ...
const QDeclarativeDirComponents & dirComponents() const
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
QList< TypeReference * > referencedTypes() const
QString & replace(int i, int len, QChar after)
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QByteArray class provides an array of bytes.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
int length() const
Returns the number of characters in this string.
QDeclarativeCompiledData * compiledData() const
void addDependency(QDeclarativeDataBlob *)
Wait for blob to become complete or to error.
QDeclarativeCompiledData * m_compiledData
void setColumn(int)
Sets the error column number.
NetworkError
Indicates all possible error conditions found during the processing of the request.
QDeclarativeDataLoader(QDeclarativeEngine *)
Create a new QDeclarativeDataLoader for engine.
NetworkReplies m_networkReplies
QList< TypeDataCallback * > m_callbacks
QString absoluteFilePath() const
Returns an absolute path including the file name.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
bool isCompleteOrError() const
Returns true if the status is Complete or Error.
QList< QDeclarativeError > errors() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool resolveType(const QByteArray &type, QDeclarativeType **type_return, QUrl *url_return, int *version_major, int *version_minor, QDeclarativeImportedNamespace **ns_return, QString *errorString=0) const
The given (namespace qualified) type is resolved to either.
int count(const T &t) const
Returns the number of occurrences of value in the list.
static bool isRelativePath(const QString &path)
Returns true if path is relative; returns false if it is absolute.
QList< QDeclarativeDirParser::Component > QDeclarativeDirComponents
QList< Import > imports() const
The QUrl class provides a convenient interface for working with URLs.
The QDirIterator class provides an iterator for directory entrylists.
The QString class provides a Unicode character string.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
The QHash class is a template class that provides a hash-table-based dictionary.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static QDeclarativeParser::Object::ScriptBlock::Pragmas extractPragmas(QString &)
QDeclarativeQmldirData(const QUrl &)
bool isLoading() const
Returns true if the status is Loading.
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
void notifyAllWaitingOnMe()
virtual void allDependenciesDone()
Called when all blobs waited for have completed.
QList< QDeclarativeDataBlob * > m_waitingOnMe
The QDeclarativeDataLoader class abstracts loading files and their dependencies over the network...
void networkReplyProgress(qint64, qint64)
QDeclarativeTypeData * typeData
const T value(const Key &key) const
Returns the value associated with the key.
QDeclarativeEngine * engine() const
Return the QDeclarativeEngine associated with this loader.
void setData(QDeclarativeDataBlob *, const QByteArray &)
The QDeclarativeImports class encapsulates one QML document's import statements.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
const QList< TypeReference > & resolvedTypes() const
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
qreal progress() const
Returns the data download progress from 0 to 1.
Type
This enum describes the type of the data blob.
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
QDeclarativeTypeLoader(QDeclarativeEngine *)
Constructs a new type loader that uses the given engine.
bool QDeclarative_isFileCaseCorrect(const QString &fileName)
Returns true if the case of fileName is equivalent to the file case of fileName on disk...
QString fileName() const
Returns the file name for the current directory entry, without the path prepended.
void append(const T &t)
Inserts value at the end of the list.
void loadWithStaticData(QDeclarativeDataBlob *, const QByteArray &)
Load the provided blob with data.
QUrl baseUrl() const
Returns the base URL to be used for all relative file imports added.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QList< Component > components() const
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
QDeclarativeImports m_imports
static bool isEmpty(const char *str)
virtual void typeDataReady(QDeclarativeTypeData *)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
bool contains(const T &value) const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual ~QDeclarativeDataBlob()
QList< QDeclarativeParser::Object * > refObjects
QDeclarativeParser::Location location
virtual void typeDataProgress(QDeclarativeTypeData *, qreal)
void prepend(const T &t)
Inserts value at the beginning of the list.
const T & at(int i) const
Returns the item at index position i in the list.
QList< QDeclarativeDataBlob * > m_waitingFor
ScriptCache m_scriptCache
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
const_iterator insert(const T &value)
static const char * data(const QByteArray &arr)
void unregisterCallback(TypeDataCallback *)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
virtual void allDependenciesDone()
Called when all blobs waited for have completed.
const QDeclarativeDirParser * qmlDirParser(const QString &absoluteFilePath)
Return a QDeclarativeDirParser for absoluteFilePath.
void setFileSource(const QString &filePath)
The QDeclarativeError class encapsulates a QML error.
QDeclarativeDirComponents m_components
QDeclarativeImportDatabase importDatabase
QDeclarativeScriptData(const QUrl &)
Type type() const
Returns the type provided to the constructor.
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
bool isNull() const
Returns true if the status is Null.
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
QDeclarativeScriptData * script
Status status() const
Returns the blob's status.
#define DATALOADER_MAXIMUM_REDIRECT_RECURSION
static void endRange(RangeType)
QDeclarativeQmldirData * qmldirForUrl(const QUrl &)
static void startRange(RangeType)
T & first()
Returns a reference to the first item in the list.
void setLine(int)
Sets the error line number.
bool isWaiting() const
Returns true if the status is WaitingForDependencies.
QDeclarativeParser::Object::ScriptBlock::Pragmas pragmas() const
virtual void downloadProgressChanged(qreal)
Called when the download progress of this blob changes.
QString next()
Advances the iterator to the next entry, and returns the file path of this new entry.
virtual void done()
Invoked once data has either been received or a network error occurred, and all dependencies are comp...
The QFile class provides an interface for reading from and writing to files.
bool isComplete() const
Returns true if the status is Complete.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
void setUrl(const QUrl &)
Sets the url for the file that caused this error.
QList< QDeclarativeError > errors() const
Return the errors on this blob.
QDeclarativeTypeLoader::Options m_options
The QDeclarativeEngine class provides an environment for instantiating QML components.
bool isFinished() const
Returns true when the reply has finished or was aborted.
virtual void dataReceived(const QByteArray &)
Invoked when data for the blob is received.
QUrl url() const
Returns the blob url passed to the constructor.
static QTestResult::TestLocation location
bool parse(const QByteArray &data, const QUrl &url=QUrl())
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
QmldirCache m_qmldirCache
QList< QDeclarativeError > errors() const
Return the list of errors from the last call to compile(), or an empty list if there were no errors...
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
void load(QDeclarativeDataBlob *)
Load the provided blob from the network or filesystem.
QDeclarativeTypeData(const QUrl &, QDeclarativeTypeLoader::Options, QDeclarativeTypeLoader *)
~QDeclarativeDataLoader()
void setError(const QDeclarativeError &)
Mark this blob as having errors.
QDeclarativeScriptParser scriptParser
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
virtual void dataReceived(const QByteArray &)
Invoked when data for the blob is received.
static void rangeData(RangeType, const QString &)
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
static QSet< QString > * qmlFilesInDirectory(const QString &path)
virtual void dependencyError(QDeclarativeDataBlob *)
Called if blob, which was previously waited for, has an error.
ImportDirCache m_importDirCache
QDeclarativeTypeData * get(const QUrl &url)
Returns a QDeclarativeTypeData for the specified url.
void setBaseUrl(const QUrl &url)
Sets the base URL to be used for all relative file imports added.
T takeLast()
Removes the last item in the list and returns it.
QList< QDeclarativeQmldirData * > m_qmldirs
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QList< TypeReference > m_types
QString absoluteFilePath(const QString &path)
Returns the absolute filename of path via a directory cache for files named "qmldir", "*.qml", "*.js" Returns a empty string if the path does not exist.
QDeclarativeScriptData * getScript(const QUrl &)
Returns a QDeclarativeScriptData for url.
bool compile(QDeclarativeEngine *, QDeclarativeTypeData *, QDeclarativeCompiledData *)
Compile unit, and store the output in out.
const QList< ScriptReference > & resolvedScripts() const
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
void setSource(const QString &source)
const QDeclarativeScriptParser & parser() const
QUrl url() const
Returns the URL of the content downloaded or uploaded.
QDeclarativeTypeLoader * m_typeLoader
void setUrl(const QUrl &url)
QNetworkAccessManager * networkAccessManager() const
Returns a common QNetworkAccessManager which can be used by any QML element instantiated by this engi...
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
QDeclarativeParser::Location location
The QFileInfo class provides system-independent file information.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void registerCallback(TypeDataCallback *)
static qreal dot(const QPointF &a, const QPointF &b)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QDeclarativeDataBlob(const QUrl &, Type)
Create a new QDeclarativeDataBlob for url and of the provided type.
QList< ScriptReference > m_scripts
~QDeclarativeTypeLoader()
Destroys the type loader, first clearing the cache of any information about loaded files...
void deleteLater()
Schedules this object for deletion.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
virtual void dataReceived(const QByteArray &)=0
Invoked when data for the blob is received.
virtual void dataReceived(const QByteArray &)
Invoked when data for the blob is received.
void notifyComplete(QDeclarativeDataBlob *)
ImportQmlDirCache m_importQmlDirCache
virtual void networkError(QNetworkReply::NetworkError)
Invoked if there is a network error while fetching this blob.
The QDeclarativeImportDatabase class manages the QML imports for a QDeclarativeEngine.