aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@rim.com>2013-02-28 17:03:43 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-07 19:41:26 +0200
commit223313479bf8ec80158ba0f6cba4dd5e74d92718 (patch)
treebc39fb195736657dec6a09106ad9609253074d77 /src/qml/qml/qqmltypeloader.cpp
parent40d90b50c555a968f1ae540527199042fbcf1a32 (diff)
Add a URL interceptor to the QML engine
Allows for custom file handling to a greater extent than the QNetworkAccessManager. Change-Id: Ifd3946bf33530c40ca2edeeb9f441f712e4941f6 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index bbce8e625e..8d8503f344 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qqmltypeloader_p.h"
+#include "qqmlabstracturlinterceptor_p.h"
#include <private/qqmlengine_p.h>
#include <private/qqmlglobal_p.h>
@@ -250,6 +251,23 @@ QQmlDataBlob::~QQmlDataBlob()
}
/*!
+ Sets the manager, and does stuff like selection which needs access to the manager.
+ Must be called before loading can occur.
+*/
+void QQmlDataBlob::startLoading(QQmlDataLoader *manager)
+{
+ Q_ASSERT(status() == QQmlDataBlob::Null);
+ Q_ASSERT(m_manager == 0);
+ m_data.setStatus(QQmlDataBlob::Loading);
+ m_manager = manager;
+
+ //Set here because we need to get the engine from the manager
+ if (manager && manager->engine() && manager->engine()->urlInterceptor())
+ m_url = manager->engine()->urlInterceptor()->intercept(m_url,
+ (QQmlAbstractUrlInterceptor::DataType)m_type);
+}
+
+/*!
Returns the type provided to the constructor.
*/
QQmlDataBlob::Type QQmlDataBlob::type() const
@@ -892,12 +910,7 @@ void QQmlDataLoader::load(QQmlDataBlob *blob, Mode mode)
qWarning("QQmlDataLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()),
m_thread->isThisThread()?"Compile":"Engine");
#endif
-
- Q_ASSERT(blob->status() == QQmlDataBlob::Null);
- Q_ASSERT(blob->m_manager == 0);
-
- blob->m_data.setStatus(QQmlDataBlob::Loading);
- blob->m_manager = this;
+ blob->startLoading(this);
if (m_thread->isThisThread()) {
unlock();
@@ -930,11 +943,7 @@ void QQmlDataLoader::loadWithStaticData(QQmlDataBlob *blob, const QByteArray &da
m_thread->isThisThread()?"Compile":"Engine");
#endif
- Q_ASSERT(blob->status() == QQmlDataBlob::Null);
- Q_ASSERT(blob->m_manager == 0);
-
- blob->m_data.setStatus(QQmlDataBlob::Loading);
- blob->m_manager = this;
+ blob->startLoading(this);
if (m_thread->isThisThread()) {
unlock();