summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/loader/loader.pro2
-rw-r--r--examples/declarative/loader/main.cpp23
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.cpp1
-rw-r--r--src/declarative/extra/qmlfontloader.cpp1
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp1
-rw-r--r--src/declarative/fx/qfxborderimage.cpp1
-rw-r--r--src/declarative/fx/qfxpixmapcache.cpp1
-rw-r--r--src/declarative/util/qmlscript.cpp1
-rw-r--r--tools/qmlviewer/qmlviewer.cpp16
9 files changed, 39 insertions, 8 deletions
diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro
index baa5b8c..089eaff 100644
--- a/examples/declarative/loader/loader.pro
+++ b/examples/declarative/loader/loader.pro
@@ -1,7 +1,7 @@
SOURCES = main.cpp
RESOURCES = loader.qrc
-QT += script declarative
+QT += script declarative network
target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro
diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp
index d018181..68f20d4 100644
--- a/examples/declarative/loader/main.cpp
+++ b/examples/declarative/loader/main.cpp
@@ -10,8 +10,11 @@
#include <QDebug>
#include <QmlContext>
#include <QmlComponent>
+#include <QmlEngine>
#include <qfxview.h>
#include <QDebug>
+#include <QNetworkDiskCache>
+#include <QNetworkAccessManager>
QFxView *canvas = 0;
@@ -148,6 +151,24 @@ public slots:
}
};
+class ConfiguredNetworkAccessManager : public QNetworkAccessManager {
+public:
+ ConfiguredNetworkAccessManager()
+ {
+ QNetworkDiskCache *cache = new QNetworkDiskCache;
+ cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-loader-network-cache"));
+ setCache(cache);
+ }
+
+ QNetworkReply *createRequest (Operation op, const QNetworkRequest &req, QIODevice * outgoingData)
+ {
+ QNetworkRequest request = req;
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+ request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ return QNetworkAccessManager::createRequest(op,request,outgoingData);
+ }
+};
+
int main(int argc, char *argv[])
{
@@ -162,6 +183,8 @@ int main(int argc, char *argv[])
canvas = new QFxView;
canvas->setFocusPolicy(Qt::StrongFocus);
+ canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager);
+
mw->setCentralWidget(canvas);
QMenuBar *mb = mw->menuBar();
diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp
index d366111..5a491e0 100644
--- a/src/declarative/extra/qfxanimatedimageitem.cpp
+++ b/src/declarative/extra/qfxanimatedimageitem.cpp
@@ -201,7 +201,6 @@ void QFxAnimatedImageItem::setSource(const QUrl &url)
} else {
d->status = Loading;
QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(movieRequestFinished()));
diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp
index 2f54f24..5373d02 100644
--- a/src/declarative/extra/qmlfontloader.cpp
+++ b/src/declarative/extra/qmlfontloader.cpp
@@ -121,7 +121,6 @@ void QmlFontLoader::setSource(const QUrl &url)
#endif
{
QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 077e9a9..9b74799 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -605,7 +605,6 @@ void QmlXmlListModel::reload()
emit statusChanged(d->status);
QNetworkRequest req(d->src);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp
index 16677e0..60faa84 100644
--- a/src/declarative/fx/qfxborderimage.cpp
+++ b/src/declarative/fx/qfxborderimage.cpp
@@ -187,7 +187,6 @@ void QFxBorderImage::setSource(const QUrl &url)
#endif
{
QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->sciReply, SIGNAL(finished()),
this, SLOT(sciRequestFinished()));
diff --git a/src/declarative/fx/qfxpixmapcache.cpp b/src/declarative/fx/qfxpixmapcache.cpp
index 0ca77c3..7fc713b 100644
--- a/src/declarative/fx/qfxpixmapcache.cpp
+++ b/src/declarative/fx/qfxpixmapcache.cpp
@@ -218,7 +218,6 @@ QNetworkReply *QFxPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *
QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key);
if (iter == qfxActiveNetworkReplies.end()) {
QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
QSharedNetworkReply *item = new QSharedNetworkReply(engine->networkAccessManager()->get(req));
iter = qfxActiveNetworkReplies.insert(key, item);
} else {
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp
index 0bff047..de2128d 100644
--- a/src/declarative/util/qmlscript.cpp
+++ b/src/declarative/util/qmlscript.cpp
@@ -151,7 +151,6 @@ void QmlScript::setSource(const QUrl &source)
#endif
{
QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(replyFinished()));
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index ae61fd0..272ebcb 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -191,6 +191,19 @@ private:
QString customargs;
};
+class ConfiguredNetworkAccessManager : public QNetworkAccessManager {
+public:
+ ConfiguredNetworkAccessManager() { }
+
+ QNetworkReply *createRequest (Operation op, const QNetworkRequest &req, QIODevice * outgoingData)
+ {
+ QNetworkRequest request = req;
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+ request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ return QNetworkAccessManager::createRequest(op,request,outgoingData);
+ }
+};
+
QString QmlViewer::getVideoFileName()
{
QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames");
@@ -240,6 +253,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setAttribute(Qt::WA_OpaquePaintEvent);
canvas->setAttribute(Qt::WA_NoSystemBackground);
canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager);
canvas->setFocus();
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
@@ -966,7 +980,7 @@ void QmlViewer::setupProxy()
else
proxyFactory->unsetHttpProxy();
nam->setProxyFactory(proxyFactory);
- }
+}
void QmlViewer::setNetworkCacheSize(int size)
{