Akonadi

cachepolicy.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "cachepolicy.h"
8#include <QDebug>
9
10using namespace Akonadi;
11
12/**
13 * @internal
14 */
15class Akonadi::CachePolicyPrivate : public QSharedData
16{
17public:
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
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
105QDebug 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}
Represents the caching policy for a collection.
Definition cachepolicy.h:60
bool operator==(const CachePolicy &other) const
~CachePolicy()
Destroys the cache policy.
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
int intervalCheckTime() const
Returns the interval check time in minutes, -1 for never.
void setLocalParts(const QStringList &parts)
Specifies the parts to permanently cache locally.
CachePolicy & operator=(const CachePolicy &other)
QStringList localParts() const
Returns the parts to permanently cache locally.
bool syncOnDemand() const
Returns whether the collection will be synced automatically when necessary, i.e.
void setIntervalCheckTime(int time)
Sets interval check time.
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
void setInheritFromParent(bool inherit)
Sets whether the cache policy should be inherited from the parent collection.
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
CachePolicy()
Creates an empty cache policy.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.