• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • folderarchive
folderarchivecache.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "folderarchivecache.h"
19 #include "folderarchiveaccountinfo.h"
20 
21 FolderArchiveCache::FolderArchiveCache(QObject *parent)
22  : QObject(parent)
23 {
24 }
25 
26 FolderArchiveCache::~FolderArchiveCache()
27 {
28 
29 }
30 
31 void FolderArchiveCache::clearCache()
32 {
33  mCache.clear();
34 }
35 
36 void FolderArchiveCache::clearCacheWithContainsCollection(Akonadi::Collection::Id id)
37 {
38  QHash<QString, ArchiveCache>::iterator i = mCache.begin();
39  while (i!=mCache.end()) {
40  if (i.value().colId == id) {
41  i = mCache.erase(i);
42  } else {
43  ++i;
44  }
45  }
46 }
47 
48 Akonadi::Collection::Id FolderArchiveCache::collectionId(FolderArchiveAccountInfo *info)
49 {
50  //qDebug()<<" Look at Cache ";
51  if (mCache.contains(info->instanceName())) {
52  //qDebug()<<"instance name : "<<info->instanceName();
53  switch(info->folderArchiveType()) {
54  case FolderArchiveAccountInfo::UniqueFolder: {
55  qDebug()<<"FolderArchiveAccountInfo::UniqueFolder has cache "<<mCache.value(info->instanceName()).colId;
56  return mCache.value(info->instanceName()).colId;
57  }
58  case FolderArchiveAccountInfo::FolderByMonths:
59  //qDebug()<<"FolderArchiveAccountInfo::ByMonths has cache ?";
60  if (mCache.value(info->instanceName()).date.month() != QDate::currentDate().month()) {
61  //qDebug()<<"need to remove current cache month is not good";
62  mCache.remove(info->instanceName());
63  return -1;
64  } else {
65  return mCache.value(info->instanceName()).colId;
66  }
67  case FolderArchiveAccountInfo::FolderByYears:
68  //qDebug()<<"FolderArchiveAccountInfo::ByYears has cache ?";
69  if (mCache.value(info->instanceName()).date.year() != QDate::currentDate().year()) {
70  //qDebug()<<"need to remove current cache year is not good";
71  mCache.remove(info->instanceName());
72  return -1;
73  } else {
74  return mCache.value(info->instanceName()).colId;
75  }
76  break;
77  }
78  return mCache.value(info->instanceName()).colId;
79  }
80  //qDebug()<<" Don't have cache for this instancename "<<info->instanceName();
81  return -1;
82 }
83 
84 void FolderArchiveCache::addToCache(const QString &resourceName, Akonadi::Collection::Id id)
85 {
86  if (mCache.contains(resourceName)) {
87  ArchiveCache cache = mCache.value(resourceName);
88  cache.colId = id;
89  mCache.insert(resourceName, cache);
90  } else {
91  ArchiveCache cache;
92  cache.colId = id;
93  mCache.insert(resourceName, cache);
94  }
95 }
96 
FolderArchiveAccountInfo::folderArchiveType
FolderArchiveType folderArchiveType() const
Definition: folderarchiveaccountinfo.cpp:53
FolderArchiveAccountInfo::FolderByMonths
Definition: folderarchiveaccountinfo.h:33
QHash::insert
iterator insert(const Key &key, const T &value)
ArchiveCache
Definition: folderarchivecache.h:28
date
time_t date() const
FolderArchiveAccountInfo::instanceName
QString instanceName() const
Definition: folderarchiveaccountinfo.cpp:68
FolderArchiveCache::clearCache
void clearCache()
Definition: folderarchivecache.cpp:31
FolderArchiveAccountInfo::FolderByYears
Definition: folderarchiveaccountinfo.h:34
QDate::month
int month() const
FolderArchiveCache::addToCache
void addToCache(const QString &resourceName, Akonadi::Collection::Id id)
Definition: folderarchivecache.cpp:84
folderarchiveaccountinfo.h
FolderArchiveCache::collectionId
Akonadi::Collection::Id collectionId(FolderArchiveAccountInfo *info)
Definition: folderarchivecache.cpp:48
QHash
QObject
QHash::begin
iterator begin()
QDate::year
int year() const
QString
FolderArchiveAccountInfo
Definition: folderarchiveaccountinfo.h:24
QHash::remove
int remove(const Key &key)
QHash::erase
iterator erase(iterator pos)
FolderArchiveCache::FolderArchiveCache
FolderArchiveCache(QObject *parent=0)
Definition: folderarchivecache.cpp:21
QHash::clear
void clear()
QHash::value
const T value(const Key &key) const
FolderArchiveCache::~FolderArchiveCache
~FolderArchiveCache()
Definition: folderarchivecache.cpp:26
FolderArchiveCache::clearCacheWithContainsCollection
void clearCacheWithContainsCollection(Akonadi::Collection::Id id)
Definition: folderarchivecache.cpp:36
FolderArchiveAccountInfo::UniqueFolder
Definition: folderarchiveaccountinfo.h:32
QDate::currentDate
QDate currentDate()
ArchiveCache::colId
Akonadi::Collection::Id colId
Definition: folderarchivecache.h:37
QHash::contains
bool contains(const Key &key) const
QHash::end
iterator end()
folderarchivecache.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal