Skip to content

Commit

Permalink
Add disk cache support when compiled against Qt 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
icefox committed Jul 30, 2008
1 parent 5be2cd4 commit 44c468b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/clearprivatedata.cpp
Expand Up @@ -57,7 +57,10 @@ ClearPrivateData::ClearPrivateData(QWidget *parent)
layout->addWidget(m_cookies);

m_cache = new QCheckBox(tr("C&ached Web Pages"));
#if QT_VERSION < 0x040500
m_cache->setEnabled(false);
#endif
m_cookies->setChecked(true);
layout->addWidget(m_cache);

m_favIcons = new QCheckBox(tr("Website &Icons"));
Expand Down Expand Up @@ -97,7 +100,9 @@ void ClearPrivateData::accept()
BrowserApplication::cookieJar()->clear();
}
if (m_cache->isChecked()) {
//not implemented
#if QT_VERSION < 0x040500
BrowserApplication::downloadManager()->networkCache()->clear();
#endif
}
if (m_favIcons->isChecked()) {
QWebSettings::clearIconDatabase();
Expand Down
13 changes: 13 additions & 0 deletions src/networkaccessmanager.cpp
Expand Up @@ -79,6 +79,11 @@
#include <qsslconfiguration.h>
#include <qsslerror.h>

#if QT_VERSION >= 0x040500
#include <qnetworkdiskcache.h>
#include <qdesktopservices.h>
#endif

NetworkAccessManager::NetworkAccessManager(QObject *parent)
: QNetworkAccessManager(parent)
{
Expand All @@ -91,6 +96,14 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)));
#endif
loadSettings();

#if QT_VERSION >= 0x040500
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+ QLatin1String("/cache");
diskCache->setCacheDirectory(location);
setCache(diskCache);
#endif
}

void NetworkAccessManager::loadSettings()
Expand Down

0 comments on commit 44c468b

Please sign in to comment.