Akonadi

itemfetchscope.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Kevin Krammer <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "itemfetchscope.h"
8 
9 #include "itemfetchscope_p.h"
10 
11 using namespace Akonadi;
12 
14  : d(new ItemFetchScopePrivate())
15 {
16 }
17 
19  : d(other.d)
20 {
21 }
22 
24 {
25 }
26 
28 {
29  if (&other != this) {
30  d = other.d;
31  }
32 
33  return *this;
34 }
35 
37 {
38  return d->mPayloadParts;
39 }
40 
41 void 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 
65 void 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 
97 void 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 
135 void 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 
175 void ItemFetchScope::setFetchTags(bool fetchTags)
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 
210 void ItemFetchScope::setFetchRelations(bool fetchRelations)
211 {
212  d->mFetchRelations = fetchRelations;
213 }
214 
216 {
217  return d->mFetchRelations;
218 }
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
AncestorRetrieval
Describes the ancestor retrieval depth.
Specifies which parts of a tag should be fetched from the Akonadi storage.
Definition: tagfetchscope.h:22
bool cacheOnly() const
Returns whether payload data should be requested from remote sources or just from the local cache.
void setTagFetchScope(const TagFetchScope &fetchScope)
Sets the tag fetch scope.
void fetchPayloadPart(const QByteArray &part, bool fetch=true)
Sets which payload parts shall be fetched.
bool fetchModificationTime() const
Returns whether item modification time should be retrieved.
void setCacheOnly(bool cacheOnly)
Sets whether payload data should be requested from remote sources or just from the local cache.
bool fetchTags() const
Returns whether tags should be retrieved.
void fetchFullPayload(bool fetch=true)
Sets whether the full payload shall be fetched.
TagFetchScope & tagFetchScope()
Returns the tag fetch scope.
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
bool isEmpty() const
Returns true if there is nothing to fetch.
bool fetchRelations() const
Returns whether relations should be retrieved.
bool checkForCachedPayloadPartsOnly() const
Returns whether payload data should be fetched or only checked for presence in the cache.
void setFetchModificationTime(bool retrieveMtime)
Enables retrieval of the item modification time.
void setFetchChangedSince(const QDateTime &changedSince)
Only fetch items that were added or modified after given timestamp.
void setFetchTags(bool fetchTags)
Fetch tags for items.
ItemFetchScope()
Creates an empty item 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 fetchVirtualReferences() const
Returns whether virtual references should be retrieved.
~ItemFetchScope()
Destroys the item fetch scope.
bool fetchRemoteIdentification() const
Returns whether item remote identification should be retrieved.
bool fetchGid() const
Returns whether item GID should be retrieved.
QDateTime fetchChangedSince() const
Returns timestamp of the oldest item to fetch.
void setFetchVirtualReferences(bool fetchVRefs)
Returns whether to fetch list of virtual collections the item is linked to.
void setFetchRelations(bool fetchRelations)
Fetch relations for items.
void setIgnoreRetrievalErrors(bool enabled)
Ignore retrieval errors while fetching items, and always deliver what is available.
void setFetchGid(bool retrieveGID)
Enables retrieval of the item GID.
void setAncestorRetrieval(AncestorRetrieval ancestorDepth)
Sets how many levels of ancestor collections should be included in the retrieval.
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
void fetchAttribute(const QByteArray &type, bool fetch=true)
Sets whether the attribute of the given type should be fetched.
bool fullPayload() const
Returns whether the full payload should be fetched.
ItemFetchScope & operator=(const ItemFetchScope &other)
Assigns the other to this scope and returns a reference to this scope.
bool allAttributes() const
Returns whether all available attributes should be fetched.
void fetchAllAttributes(bool fetch=true)
Sets whether all available attributes should be fetched.
QSet< QByteArray > payloadParts() const
Returns the payload parts that should be fetched.
void setFetchRemoteIdentification(bool retrieveRid)
Fetch remote identification for items.
Specifies which parts of an item should be fetched from the Akonadi storage.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Jun 5 2023 03:51:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.