diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-20 03:16:07 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-20 03:16:07 (GMT) |
commit | ecc71bebda5cdc842932f29757d869c8a1288962 (patch) | |
tree | 907f405070741205e94efa88c5407171a7c61b00 | |
parent | c6474a6dcbf92d780cd868c5162a69ed9f93f1bc (diff) | |
download | Qt-ecc71bebda5cdc842932f29757d869c8a1288962.zip Qt-ecc71bebda5cdc842932f29757d869c8a1288962.tar.gz Qt-ecc71bebda5cdc842932f29757d869c8a1288962.tar.bz2 |
Make network cache size settable.
-rw-r--r-- | tools/qmlviewer/main.cpp | 10 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 19 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.h | 2 |
3 files changed, 18 insertions, 13 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index ae9c356..e786edb 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -36,7 +36,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -cache ................................... disk cache remote content"); + qWarning(" -netcache <size> ......................... set disk cache to size bytes"); qWarning(" -recordtest <directory> .................. record an autotest"); qWarning(" -runtest <directory> ..................... run a previously recorded test"); qWarning(" -translation <translationfile> ........... set the language to run in"); @@ -74,7 +74,7 @@ int main(int argc, char ** argv) QStringList libraries; QString skin; bool devkeys = false; - bool cache = false; + int cache = 0; QString translationFile; for (int i = 1; i < argc; ++i) { @@ -83,8 +83,8 @@ int main(int argc, char ** argv) frameless = true; } else if (arg == "-skin") { skin = QString(argv[++i]); - } else if (arg == "-cache") { - cache = true; + } else if (arg == "-netcache") { + cache = QString(argv[++i]).toInt(); } else if (arg == "-recordperiod") { period = QString(argv[++i]).toInt(); } else if (arg == "-recordfile") { @@ -127,7 +127,7 @@ int main(int argc, char ** argv) QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget); foreach (QString lib, libraries) viewer.addLibraryPath(lib); - viewer.setCacheEnabled(cache); + viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); if (period>0) viewer.setRecordPeriod(period); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index c9d70e8..8f99206 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -699,17 +699,22 @@ void QmlViewer::setupProxy() nam->setProxyFactory(new SystemProxyFactory); } -void QmlViewer::setCacheEnabled(bool on) +void QmlViewer::setNetworkCacheSize(int size) { QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - if (on == !!nam->cache()) - return; - if (on) { - // Setup a caching network manager - QNetworkDiskCache *cache = new QNetworkDiskCache; + QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>(nam->cache()); + if (!cache) { + if (size==0) + return; + cache = new QNetworkDiskCache; cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); - cache->setMaximumCacheSize(8000000); nam->setCache(cache); + } + if (size == cache->maximumCacheSize()) + return; + if (size>0) { + // Setup a caching network manager + cache->setMaximumCacheSize(size); } else { nam->setCache(0); } diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 4714bdc..62ee908 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -42,7 +42,7 @@ public: bool isRecording() const { return recordTimer.isActive(); } void setAutoRecord(int from, int to); void setDeviceKeys(bool); - void setCacheEnabled(bool); + void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); QMenuBar *menuBar() const; |