Akonadi

collectionfetchscope.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Kevin Krammer <kevin.krammer@gmx.at>
3 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "collectionfetchscope.h"
9
10#include <QScopedPointer>
11#include <QString>
12
13namespace Akonadi
14{
15class CollectionFetchScopePrivate : public QSharedData
16{
17public:
18 CollectionFetchScopePrivate()
19 : ancestorDepth(CollectionFetchScope::None)
20 , listFilter(CollectionFetchScope::Enabled)
21 {
22 }
23
24 CollectionFetchScopePrivate(const CollectionFetchScopePrivate &other)
25 : QSharedData(other)
26 , resource(other.resource)
27 , contentMimeTypes(other.contentMimeTypes)
28 , ancestorDepth(other.ancestorDepth)
29 , listFilter(other.listFilter)
30 , attributes(other.attributes)
31 , statistics(other.statistics)
32 , fetchIdOnly(other.fetchIdOnly)
33 , mIgnoreRetrievalErrors(other.mIgnoreRetrievalErrors)
34 {
35 if (!ancestorFetchScope && other.ancestorFetchScope) {
36 ancestorFetchScope.reset(new CollectionFetchScope());
37 *ancestorFetchScope = *other.ancestorFetchScope;
38 } else if (ancestorFetchScope && !other.ancestorFetchScope) {
39 ancestorFetchScope.reset(nullptr);
40 }
41 }
42
43public:
44 QString resource;
45 QStringList contentMimeTypes;
48 QSet<QByteArray> attributes;
49 QScopedPointer<CollectionFetchScope> ancestorFetchScope;
50 bool statistics = false;
51 bool fetchIdOnly = true;
52 bool mIgnoreRetrievalErrors = false;
53};
54
56 : d(new CollectionFetchScopePrivate())
57{
58}
59
64
68
70{
71 if (&other != this) {
72 d = other.d;
73 }
74
75 return *this;
76}
77
79{
80 return d->resource.isEmpty() && d->contentMimeTypes.isEmpty() && !d->statistics && d->ancestorDepth == None && d->listFilter == Enabled;
81}
82
84{
85 return d->statistics;
86}
87
89{
90 d->statistics = include;
91}
92
94{
95 return d->resource;
96}
97
99{
100 d->resource = resource;
101}
102
104{
105 return d->contentMimeTypes;
106}
107
109{
110 d->contentMimeTypes = mimeTypes;
111}
112
117
119{
120 d->ancestorDepth = ancestorDepth;
121}
122
124{
125 return d->listFilter;
126}
127
132
134{
135 return d->attributes;
136}
137
139{
140 d->fetchIdOnly = false;
141 if (fetch) {
142 d->attributes.insert(type);
143 } else {
144 d->attributes.remove(type);
145 }
146}
147
149{
150 d->fetchIdOnly = fetchIdOnly;
151}
152
154{
155 return d->fetchIdOnly;
156}
157
159{
160 d->mIgnoreRetrievalErrors = enable;
161}
162
164{
165 return d->mIgnoreRetrievalErrors;
166}
167
169{
170 *d->ancestorFetchScope = scope;
171}
172
174{
175 if (!d->ancestorFetchScope) {
176 return CollectionFetchScope();
177 }
178 return *d->ancestorFetchScope;
179}
180
182{
183 if (!d->ancestorFetchScope) {
184 d->ancestorFetchScope.reset(new CollectionFetchScope());
185 }
186 return *d->ancestorFetchScope;
187}
188
189} // namespace Akonadi
Specifies which parts of a collection should be fetched from the Akonadi storage.
bool isEmpty() const
Returns true if there is nothing to fetch.
~CollectionFetchScope()
Destroys the collection fetch scope.
ListFilter
Describes the list filter.
@ Enabled
Only retrieve enabled collections, ignoring the local preference.
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
void setIncludeStatistics(bool include)
Sets whether collection statistics should be included in the retrieved results.
void setResource(const QString &resource)
Sets a resource filter, that is only collections owned by the specified resource are retrieved.
CollectionFetchScope & operator=(const CollectionFetchScope &other)
Assigns the other to this scope and returns a reference to this scope.
ListFilter listFilter() const
Returns the list filter.
void setIgnoreRetrievalErrors(bool enabled)
Ignore retrieval errors while fetching collections, and always deliver what is available.
void fetchAttribute(const QByteArray &type, bool fetch=true)
Sets whether the attribute of the given type should be fetched.
void setFetchIdOnly(bool fetchIdOnly)
Sets whether only the id or the complete tag should be fetched.
void setContentMimeTypes(const QStringList &mimeTypes)
Sets a content mimetypes filter, that is only collections that contain at least one of the given mime...
void setAncestorFetchScope(const CollectionFetchScope &scope)
Sets the fetch scope for ancestor retrieval.
CollectionFetchScope ancestorFetchScope() const
Returns the fetch scope for ancestor retrieval.
QStringList contentMimeTypes() const
Returns the content mimetypes filter.
void setAncestorRetrieval(AncestorRetrieval ancestorDepth)
Sets how many levels of ancestor collections should be included in the retrieval.
bool includeStatistics() const
Returns whether collection statistics should be included in the retrieved results.
QString resource() const
Returns the resource identifier that is used as filter.
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
void setListFilter(ListFilter)
Sets a filter for the collections to be listed.
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
AncestorRetrieval
Describes the ancestor retrieval depth.
@ None
No ancestor retrieval at all (the default)
CollectionFetchScope()
Creates an empty collection fetch scope.
bool fetchIdOnly() const
Sets whether only the id of the tags should be retrieved or the complete tag.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:00:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.