Akonadi

cachepolicy.cpp
1 /*
2  Copyright (c) 2008 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "cachepolicy.h"
21 #include "collection.h"
22 
23 using namespace Akonadi;
24 
28 class Q_DECL_HIDDEN CachePolicy::Private : public QSharedData
29 {
30 public:
31  Private()
32  : QSharedData()
33  {
34  }
35 
36  Private(const Private &other)
37  : QSharedData(other)
38  {
39  inherit = other.inherit;
40  localParts = other.localParts;
41  timeout = other.timeout;
42  interval = other.interval;
43  syncOnDemand = other.syncOnDemand;
44  }
45 
46  QStringList localParts;
47  int timeout = -1;
48  int interval = -1;
49  bool inherit = true;
50  bool syncOnDemand = false;
51 };
52 
54 {
55  static QSharedDataPointer<Private> sharedPrivate(new Private);
56  d = sharedPrivate;
57 }
58 
60  : d(other.d)
61 {
62 }
63 
65 {
66 }
67 
69 {
70  d = other.d;
71  return *this;
72 }
73 
75 {
76  if (!d->inherit && !other.d->inherit) {
77  return d->localParts == other.d->localParts
78  && d->timeout == other.d->timeout
79  && d->interval == other.d->interval
80  && d->syncOnDemand == other.d->syncOnDemand;
81  }
82  return d->inherit == other.d->inherit;
83 }
84 
86 {
87  return d->inherit;
88 }
89 
91 {
92  d->inherit = inherit;
93 }
94 
96 {
97  return d->localParts;
98 }
99 
101 {
102  d->localParts = parts;
103 }
104 
106 {
107  return d->timeout;
108 }
109 
111 {
112  d->timeout = timeout;
113 }
114 
116 {
117  return d->interval;
118 }
119 
121 {
122  d->interval = time;
123 }
124 
126 {
127  return d->syncOnDemand;
128 }
129 
131 {
132  d->syncOnDemand = enable;
133 }
134 
135 QDebug operator<<(QDebug d, const CachePolicy &c)
136 {
137  return d << "CachePolicy: \n"
138  << " inherit:" << c.inheritFromParent() << '\n'
139  << " interval:" << c.intervalCheckTime() << '\n'
140  << " timeout:" << c.cacheTimeout() << '\n'
141  << " sync on demand:" << c.syncOnDemand() << '\n'
142  << " local parts:" << c.localParts();
143 }
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
int intervalCheckTime() const
Returns the interval check time in minutes, -1 for never.
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
CachePolicy()
Creates an empty cache policy.
Definition: cachepolicy.cpp:53
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
Definition: cachepolicy.cpp:85
void setIntervalCheckTime(int time)
Sets interval check time.
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
bool operator==(const CachePolicy &other) const
Definition: cachepolicy.cpp:74
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
Represents the caching policy for a collection.
Definition: cachepolicy.h:72
void setLocalParts(const QStringList &parts)
Specifies the parts to permanently cache locally.
Helper integration between Akonadi and Qt.
~CachePolicy()
Destroys the cache policy.
Definition: cachepolicy.cpp:64
QStringList localParts() const
Returns the parts to permanently cache locally.
Definition: cachepolicy.cpp:95
void setInheritFromParent(bool inherit)
Sets whether the cache policy should be inherited from the parent collection.
Definition: cachepolicy.cpp:90
CachePolicy & operator=(const CachePolicy &other)
Definition: cachepolicy.cpp:68
bool syncOnDemand() const
Returns whether the collection will be synced automatically when necessary, i.e.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue May 26 2020 22:46:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.