Akonadi

itemfetchscope.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Kevin Krammer <kevin.krammer@gmx.at>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "itemfetchscope.h"
8#include "tagfetchscope.h"
9
10namespace Akonadi
11{
12/**
13 * @internal
14 */
15class ItemFetchScopePrivate : public QSharedData
16{
17public:
18 ItemFetchScopePrivate() = default;
19
20 ItemFetchScopePrivate(const ItemFetchScopePrivate &other) = default;
21
22public:
23 QSet<QByteArray> mPayloadParts;
24 QSet<QByteArray> mAttributes;
26 bool mFullPayload = false;
27 bool mAllAttributes = false;
28 bool mCacheOnly = false;
29 bool mCheckCachedPayloadPartsOnly = false;
30 bool mFetchMtime = true;
31 bool mIgnoreRetrievalErrors = false;
32 QDateTime mChangedSince;
33 bool mFetchRid = true;
34 bool mFetchGid = false;
35 bool mFetchTags = false;
36 TagFetchScope mTagFetchScope;
37 bool mFetchVRefs = false;
38};
39
40} // namespace Akonadi
41
42using namespace Akonadi;
43
44ItemFetchScope::ItemFetchScope()
45 : d(new ItemFetchScopePrivate())
46{
47}
48
50
52
54{
55 if (&other != this) {
56 d = other.d;
57 }
58
59 return *this;
60}
61
63{
64 return d->mPayloadParts;
65}
66
67void ItemFetchScope::fetchPayloadPart(const QByteArray &part, bool fetch)
68{
69 if (fetch) {
70 d->mPayloadParts.insert(part);
71 } else {
72 d->mPayloadParts.remove(part);
73 }
74}
75
77{
78 return d->mFullPayload;
79}
80
82{
83 d->mFullPayload = fetch;
84}
85
87{
88 return d->mAttributes;
89}
90
91void ItemFetchScope::fetchAttribute(const QByteArray &type, bool fetch)
92{
93 if (fetch) {
94 d->mAttributes.insert(type);
95 } else {
96 d->mAttributes.remove(type);
97 }
98}
99
101{
102 return d->mAllAttributes;
103}
104
106{
107 d->mAllAttributes = fetch;
108}
109
111{
112 return d->mPayloadParts.isEmpty() && d->mAttributes.isEmpty() && !d->mFullPayload && !d->mAllAttributes && !d->mCacheOnly
113 && !d->mCheckCachedPayloadPartsOnly && d->mFetchMtime // true by default -> false = non-empty
114 && !d->mIgnoreRetrievalErrors && d->mFetchRid // true by default
115 && !d->mFetchGid && !d->mFetchTags && !d->mFetchVRefs && d->mAncestorDepth == AncestorRetrieval::None;
116}
117
119{
120 return d->mCacheOnly;
121}
122
124{
125 d->mCacheOnly = cacheOnly;
126}
127
129{
130 if (check) {
131 setCacheOnly(true);
132 }
133 d->mCheckCachedPayloadPartsOnly = check;
134}
135
137{
138 return d->mCheckCachedPayloadPartsOnly;
139}
140
142{
143 return d->mAncestorDepth;
144}
145
147{
148 d->mAncestorDepth = depth;
149}
150
152{
153 d->mFetchMtime = retrieveMtime;
154}
155
157{
158 return d->mFetchMtime;
159}
160
161void ItemFetchScope::setFetchGid(bool retrieveGid)
162{
163 d->mFetchGid = retrieveGid;
164}
165
167{
168 return d->mFetchGid;
169}
170
172{
173 d->mIgnoreRetrievalErrors = ignore;
174}
175
177{
178 return d->mIgnoreRetrievalErrors;
179}
180
182{
183 d->mChangedSince = changedSince;
184}
185
187{
188 return d->mChangedSince;
189}
190
192{
193 d->mFetchRid = retrieveRid;
194}
195
197{
198 return d->mFetchRid;
199}
200
202{
203 d->mFetchTags = fetchTags;
204}
205
207{
208 return d->mFetchTags;
209}
210
212{
213 d->mTagFetchScope = tagFetchScope;
214}
215
217{
218 return d->mTagFetchScope;
219}
220
222{
223 return d->mTagFetchScope;
224}
225
227{
228 d->mFetchVRefs = fetchVRefs;
229}
230
232{
233 return d->mFetchVRefs;
234}
Specifies which parts of an item should be fetched from the Akonadi storage.
~ItemFetchScope()
Destroys the item fetch scope.
bool fetchVirtualReferences() const
Returns whether virtual references should be retrieved.
void setFetchTags(bool fetchTags)
Fetch tags for items.
void setFetchRemoteIdentification(bool retrieveRid)
Fetch remote identification for items.
bool allAttributes() const
Returns whether all available attributes should be fetched.
void setCacheOnly(bool cacheOnly)
Sets whether payload data should be requested from remote sources or just from the local cache.
bool fetchRemoteIdentification() const
Returns whether item remote identification should be retrieved.
bool fullPayload() const
Returns whether the full payload should be fetched.
void fetchAttribute(const QByteArray &type, bool fetch=true)
Sets whether the attribute of the given type should be fetched.
void setAncestorRetrieval(AncestorRetrieval ancestorDepth)
Sets how many levels of ancestor collections should be included in the retrieval.
bool fetchTags() const
Returns whether tags should be retrieved.
bool cacheOnly() const
Returns whether payload data should be requested from remote sources or just from the local cache.
QDateTime fetchChangedSince() const
Returns timestamp of the oldest item to fetch.
bool fetchModificationTime() const
Returns whether item modification time should be retrieved.
void setFetchGid(bool retrieveGID)
Enables retrieval of the item GID.
ItemFetchScope()
Creates an empty item fetch scope.
bool checkForCachedPayloadPartsOnly() const
Returns whether payload data should be fetched or only checked for presence in the cache.
void fetchAllAttributes(bool fetch=true)
Sets whether all available attributes should be fetched.
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
QSet< QByteArray > payloadParts() const
Returns the payload parts that should be fetched.
void setFetchModificationTime(bool retrieveMtime)
Enables retrieval of the item modification time.
bool fetchGid() const
Returns whether item GID should be retrieved.
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
TagFetchScope & tagFetchScope()
Returns the tag fetch scope.
void setTagFetchScope(const TagFetchScope &fetchScope)
Sets the tag fetch scope.
void setCheckForCachedPayloadPartsOnly(bool check=true)
Sets whether payload will be fetched or there will be only a test performed if the requested payload ...
bool isEmpty() const
Returns true if there is nothing to fetch.
void setFetchVirtualReferences(bool fetchVRefs)
Returns whether to fetch list of virtual collections the item is linked to.
void setFetchChangedSince(const QDateTime &changedSince)
Only fetch items that were added or modified after given timestamp.
void fetchFullPayload(bool fetch=true)
Sets whether the full payload shall be fetched.
void fetchPayloadPart(const QByteArray &part, bool fetch=true)
Sets which payload parts shall be fetched.
void setIgnoreRetrievalErrors(bool enabled)
Ignore retrieval errors while fetching items, and always deliver what is available.
ItemFetchScope & operator=(const ItemFetchScope &other)
Assigns the other to this scope and returns a reference to this scope.
AncestorRetrieval
Describes the ancestor retrieval depth.
@ None
No ancestor retrieval at all (the default)
Specifies which parts of a tag should be fetched from the Akonadi storage.
Helper integration between Akonadi and Qt.
iterator insert(const T &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:52:52 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.