Akonadi

cachepolicy.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "cachepolicy.h"
8 #include "collection.h"
9 
10 using namespace Akonadi;
11 
12 /**
13  * @internal
14  */
15 class Akonadi::CachePolicyPrivate : public QSharedData
16 {
17 public:
18  QStringList localParts;
19  int timeout = -1;
20  int interval = -1;
21  bool inherit = true;
22  bool syncOnDemand = false;
23 };
24 
26 {
27  static QSharedDataPointer<CachePolicyPrivate> sharedPrivate(new CachePolicyPrivate);
28  d = sharedPrivate;
29 }
30 
32  : d(other.d)
33 {
34 }
35 
37 {
38 }
39 
41 {
42  d = other.d;
43  return *this;
44 }
45 
47 {
48  if (!d->inherit && !other.d->inherit) {
49  return d->localParts == other.d->localParts && d->timeout == other.d->timeout && d->interval == other.d->interval
50  && d->syncOnDemand == other.d->syncOnDemand;
51  }
52  return d->inherit == other.d->inherit;
53 }
54 
56 {
57  return d->inherit;
58 }
59 
61 {
62  d->inherit = inherit;
63 }
64 
66 {
67  return d->localParts;
68 }
69 
71 {
72  d->localParts = parts;
73 }
74 
76 {
77  return d->timeout;
78 }
79 
81 {
82  d->timeout = timeout;
83 }
84 
86 {
87  return d->interval;
88 }
89 
91 {
92  d->interval = time;
93 }
94 
96 {
97  return d->syncOnDemand;
98 }
99 
101 {
102  d->syncOnDemand = enable;
103 }
104 
105 QDebug operator<<(QDebug d, const CachePolicy &c)
106 {
107  return d << "CachePolicy: \n"
108  << " inherit:" << c.inheritFromParent() << '\n'
109  << " interval:" << c.intervalCheckTime() << '\n'
110  << " timeout:" << c.cacheTimeout() << '\n'
111  << " sync on demand:" << c.syncOnDemand() << '\n'
112  << " local parts:" << c.localParts();
113 }
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
Definition: cachepolicy.cpp:75
~CachePolicy()
Destroys the cache policy.
Definition: cachepolicy.cpp:36
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
int intervalCheckTime() const
Returns the interval check time in minutes, -1 for never.
Definition: cachepolicy.cpp:85
Represents the caching policy for a collection.
Definition: cachepolicy.h:59
void setInheritFromParent(bool inherit)
Sets whether the cache policy should be inherited from the parent collection.
Definition: cachepolicy.cpp:60
CachePolicy & operator=(const CachePolicy &other)
Definition: cachepolicy.cpp:40
CachePolicy()
Creates an empty cache policy.
Definition: cachepolicy.cpp:25
bool operator==(const CachePolicy &other) const
Definition: cachepolicy.cpp:46
QStringList localParts() const
Returns the parts to permanently cache locally.
Definition: cachepolicy.cpp:65
bool syncOnDemand() const
Returns whether the collection will be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:95
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
Definition: cachepolicy.cpp:80
void setIntervalCheckTime(int time)
Sets interval check time.
Definition: cachepolicy.cpp:90
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
Definition: cachepolicy.cpp:55
Helper integration between Akonadi and Qt.
void setLocalParts(const QStringList &parts)
Specifies the parts to permanently cache locally.
Definition: cachepolicy.cpp:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.