summaryrefslogtreecommitdiffstats
path: root/examples/declarative/loader
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-08-24 03:54:07 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-08-24 03:54:07 (GMT)
commit678c4bc25da24def57d57f9c94d4163320f5e67c (patch)
treef0f5a09625947ea7d5b5747faf5ccd5ce7b13312 /examples/declarative/loader
parent525e6674b002180d691a2d8a787dc512c259ae95 (diff)
downloadQt-678c4bc25da24def57d57f9c94d4163320f5e67c.zip
Qt-678c4bc25da24def57d57f9c94d4163320f5e67c.tar.gz
Qt-678c4bc25da24def57d57f9c94d4163320f5e67c.tar.bz2
Centralize QNetworkRequest attribute setting, turn on pipelining.
... in two places. Qt expects the "application" to configure caching, proxy, pipelining, etc., on a QNetworkAccessManager, so now we do that in the two most important cases: the loader example and qmlviewer tool.
Diffstat (limited to 'examples/declarative/loader')
-rw-r--r--examples/declarative/loader/loader.pro2
-rw-r--r--examples/declarative/loader/main.cpp23
2 files changed, 24 insertions, 1 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();