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
9#include "itemfetchscope_p.h"
10
11using namespace Akonadi;
12
13ItemFetchScope::ItemFetchScope()
14 : d(new ItemFetchScopePrivate())
15{
16}
17
19 : d(other.d)
20{
21}
22
26
28{
29 if (&other != this) {
30 d = other.d;
31 }
32
33 return *this;
34}
35
37{
38 return d->mPayloadParts;
39}
40
41void ItemFetchScope::fetchPayloadPart(const QByteArray &part, bool fetch)
42{
43 if (fetch) {
44 d->mPayloadParts.insert(part);
45 } else {
46 d->mPayloadParts.remove(part);
47 }
48}
49
51{
52 return d->mFullPayload;
53}
54
56{
57 d->mFullPayload = fetch;
58}
59
61{
62 return d->mAttributes;
63}
64
65void ItemFetchScope::fetchAttribute(const QByteArray &type, bool fetch)
66{
67 if (fetch) {
68 d->mAttributes.insert(type);
69 } else {
70 d->mAttributes.remove(type);
71 }
72}
73
75{
76 return d->mAllAttributes;
77}
78
80{
81 d->mAllAttributes = fetch;
82}
83
85{
86 return d->mPayloadParts.isEmpty() && d->mAttributes.isEmpty() && !d->mFullPayload && !d->mAllAttributes && !d->mCacheOnly
87 && !d->mCheckCachedPayloadPartsOnly && d->mFetchMtime // true by default -> false = non-empty
88 && !d->mIgnoreRetrievalErrors && d->mFetchRid // true by default
89 && !d->mFetchGid && !d->mFetchTags && !d->mFetchVRefs && !d->mFetchRelations && d->mAncestorDepth == AncestorRetrieval::None;
90}
91
93{
94 return d->mCacheOnly;
95}
96
97void ItemFetchScope::setCacheOnly(bool cacheOnly)
98{
99 d->mCacheOnly = cacheOnly;
100}
101
103{
104 if (check) {
105 setCacheOnly(true);
106 }
107 d->mCheckCachedPayloadPartsOnly = check;
108}
109
111{
112 return d->mCheckCachedPayloadPartsOnly;
113}
114
116{
117 return d->mAncestorDepth;
118}
119
121{
122 d->mAncestorDepth = depth;
123}
124
126{
127 d->mFetchMtime = retrieveMtime;
128}
129
131{
132 return d->mFetchMtime;
133}
134
135void ItemFetchScope::setFetchGid(bool retrieveGid)
136{
137 d->mFetchGid = retrieveGid;
138}
139
141{
142 return d->mFetchGid;
143}
144
146{
147 d->mIgnoreRetrievalErrors = ignore;
148}
149
151{
152 return d->mIgnoreRetrievalErrors;
153}
154
156{
157 d->mChangedSince = changedSince;
158}
159
161{
162 return d->mChangedSince;
163}
164
166{
167 d->mFetchRid = retrieveRid;
168}
169
171{
172 return d->mFetchRid;
173}
174
176{
177 d->mFetchTags = fetchTags;
178}
179
181{
182 return d->mFetchTags;
183}
184
186{
187 d->mTagFetchScope = tagFetchScope;
188}
189
191{
192 return d->mTagFetchScope;
193}
194
196{
197 return d->mTagFetchScope;
198}
199
201{
202 d->mFetchVRefs = fetchVRefs;
203}
204
206{
207 return d->mFetchVRefs;
208}
209
210void ItemFetchScope::setFetchRelations(bool fetchRelations)
211{
212 d->mFetchRelations = fetchRelations;
213}
214
216{
217 return d->mFetchRelations;
218}
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.
bool fetchRelations() const
Returns whether relations should be retrieved.
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 setFetchRelations(bool fetchRelations)
Fetch relations for items.
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 Jun 14 2024 11:51:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.