Akonadi

collectionfetchscope.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Kevin Krammer <[email protected]>
3  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "collectionfetchscope.h"
9 
10 #include <QScopedPointer>
11 #include <QString>
12 
13 namespace Akonadi
14 {
15 class CollectionFetchScopePrivate : public QSharedData
16 {
17 public:
18  CollectionFetchScopePrivate()
19  : ancestorDepth(CollectionFetchScope::None)
20  , listFilter(CollectionFetchScope::Enabled)
21  {
22  }
23 
24  CollectionFetchScopePrivate(const CollectionFetchScopePrivate &other)
25  : QSharedData(other)
26  {
27  resource = other.resource;
28  contentMimeTypes = other.contentMimeTypes;
29  ancestorDepth = other.ancestorDepth;
30  statistics = other.statistics;
31  listFilter = other.listFilter;
32  attributes = other.attributes;
33  if (!ancestorFetchScope && other.ancestorFetchScope) {
34  ancestorFetchScope.reset(new CollectionFetchScope());
35  *ancestorFetchScope = *other.ancestorFetchScope;
36  } else if (ancestorFetchScope && !other.ancestorFetchScope) {
37  ancestorFetchScope.reset(nullptr);
38  }
39  fetchIdOnly = other.fetchIdOnly;
40  mIgnoreRetrievalErrors = other.mIgnoreRetrievalErrors;
41  }
42 
43 public:
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 
61  : d(other.d)
62 {
63 }
64 
66 {
67 }
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 
114 {
115  return d->ancestorDepth;
116 }
117 
119 {
120  d->ancestorDepth = ancestorDepth;
121 }
122 
124 {
125  return d->listFilter;
126 }
127 
129 {
130  d->listFilter = listFilter;
131 }
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) {
185  }
186  return *d->ancestorFetchScope;
187 }
188 
189 } // namespace Akonadi
CollectionFetchScope()
Creates an empty collection fetch scope.
bool isEmpty() const
Returns true if there is nothing to fetch.
void setFetchIdOnly(bool fetchIdOnly)
Sets whether only the id or the complete tag should be fetched.
bool fetchIdOnly() const
Sets whether only the id of the tags should be retrieved or the complete tag.
QStringList contentMimeTypes() const
Returns the content mimetypes filter.
ListFilter listFilter() const
Returns the list filter.
CollectionFetchScope & operator=(const CollectionFetchScope &other)
Assigns the other to this scope and returns a reference to this scope.
CollectionFetchScope ancestorFetchScope() const
Returns the fetch scope for ancestor retrieval.
Specifies which parts of a collection should be fetched from the Akonadi storage.
QAction * statistics(const QObject *recvr, const char *slot, QObject *parent)
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
void setListFilter(ListFilter)
Sets a filter for the collections to be listed.
void setIgnoreRetrievalErrors(bool enabled)
Ignore retrieval errors while fetching collections, and always deliver what is available.
ListFilter
Describes the list filter.
bool includeStatistics() const
Returns 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.
@ Enabled
Only retrieve enabled collections, ignoring the local preference.
QString resource() const
Returns the resource identifier that is used as filter.
void setIncludeStatistics(bool include)
Sets whether collection statistics should be included in the retrieved results.
void setContentMimeTypes(const QStringList &mimeTypes)
Sets a content mimetypes filter, that is only collections that contain at least one of the given mime...
AncestorRetrieval
Describes the ancestor retrieval depth.
void setAncestorRetrieval(AncestorRetrieval ancestorDepth)
Sets how many levels of ancestor collections should be included in the retrieval.
~CollectionFetchScope()
Destroys the collection fetch scope.
@ None
No ancestor retrieval at all (the default)
void setAncestorFetchScope(const CollectionFetchScope &scope)
Sets the fetch scope for ancestor retrieval.
void fetchAttribute(const QByteArray &type, bool fetch=true)
Sets whether the attribute of the given type should be fetched.
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.