summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-05-17 07:53:32 +0200
committerMontel Laurent <[email protected]>2015-05-17 07:53:32 +0200
commitcc834e4f4472bd198da5a03a33b52f529ccc183b (patch)
treeb01388143edda25448dfd863ef4622edbfd493d8
parent832fbe96becced96112fb9c2931a481d3de6de63 (diff)
Move clear cache directly in gravatarcach
-rw-r--r--messageviewer/widgets/gravatarconfigwidget.cpp15
-rw-r--r--pimcommon/gravatar/gravatarcache.cpp16
-rw-r--r--pimcommon/gravatar/gravatarcache.h1
3 files changed, 18 insertions, 14 deletions
diff --git a/messageviewer/widgets/gravatarconfigwidget.cpp b/messageviewer/widgets/gravatarconfigwidget.cpp
index 8fc82dc..e398f72 100644
--- a/messageviewer/widgets/gravatarconfigwidget.cpp
+++ b/messageviewer/widgets/gravatarconfigwidget.cpp
@@ -18,12 +18,10 @@
#include "gravatarconfigwidget.h"
#include "pimcommon/gravatar/gravatarcache.h"
#include <QDebug>
-#include <KStandardDirs>
#include <QVBoxLayout>
#include <KLocalizedString>
#include <QCheckBox>
#include <QPushButton>
-#include <KGlobal>
#include <QLabel>
#include <QDir>
#include <KIntNumInput>
@@ -107,18 +105,7 @@ void GravatarConfigWidget::doResetToDefaultsOther()
void GravatarConfigWidget::slotClearGravatarCache()
{
- const QString path = KGlobal::dirs()->locateLocal("data", QLatin1String("gravatar/"));
- if (!path.isEmpty()) {
- QDir dir(path);
- if (dir.exists()) {
- QFileInfoList list = dir.entryInfoList(); // get list of matching files and delete all
- QFileInfo it;
- Q_FOREACH( it, list ) {
- dir.remove(it.fileName());
- }
- }
- }
- PimCommon::GravatarCache::self()->clear();
+ PimCommon::GravatarCache::self()->clearAllCache();
}
void GravatarConfigWidget::slotGravatarCacheSizeChanged()
diff --git a/pimcommon/gravatar/gravatarcache.cpp b/pimcommon/gravatar/gravatarcache.cpp
index 3a63beb..ca814b9 100644
--- a/pimcommon/gravatar/gravatarcache.cpp
+++ b/pimcommon/gravatar/gravatarcache.cpp
@@ -17,6 +17,7 @@
#include "gravatarcache.h"
#include <KGlobal>
+#include <QDir>
#include <KStandardDirs>
#include <QDebug>
#include <QFile>
@@ -101,3 +102,18 @@ void GravatarCache::clear()
mCachePixmap.clear();
}
+void GravatarCache::clearAllCache()
+{
+ const QString path = KGlobal::dirs()->locateLocal("data", QLatin1String("gravatar/"));
+ if (!path.isEmpty()) {
+ QDir dir(path);
+ if (dir.exists()) {
+ QFileInfoList list = dir.entryInfoList(); // get list of matching files and delete all
+ QFileInfo it;
+ Q_FOREACH( it, list ) {
+ dir.remove(it.fileName());
+ }
+ }
+ }
+ clear();
+}
diff --git a/pimcommon/gravatar/gravatarcache.h b/pimcommon/gravatar/gravatarcache.h
index 60b8c80..fe8ab0f 100644
--- a/pimcommon/gravatar/gravatarcache.h
+++ b/pimcommon/gravatar/gravatarcache.h
@@ -41,6 +41,7 @@ public:
void setMaximumSize(int maximumSize);
void clear();
+ void clearAllCache();
private:
QCache<QString, QPixmap> mCachePixmap;
int mMaximumSize;