Akonadi

collectionfetchscope.cpp
1 /*
2  Copyright (c) 2008 Kevin Krammer <[email protected]>
3  Copyright (c) 2009 Volker Krause <[email protected]>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "collectionfetchscope.h"
22 
23 #include <QString>
24 #include <QStringList>
25 #include <QScopedPointer>
26 
27 namespace Akonadi
28 {
29 
30 class CollectionFetchScopePrivate : public QSharedData
31 {
32 public:
33  CollectionFetchScopePrivate()
34  : ancestorDepth(CollectionFetchScope::None)
35  , listFilter(CollectionFetchScope::Enabled)
36  , statistics(false)
37  , fetchIdOnly(true)
38  , mIgnoreRetrievalErrors(false)
39  {
40  }
41 
42  CollectionFetchScopePrivate(const CollectionFetchScopePrivate &other)
43  : QSharedData(other)
44  {
45  resource = other.resource;
46  contentMimeTypes = other.contentMimeTypes;
47  ancestorDepth = other.ancestorDepth;
48  statistics = other.statistics;
49  listFilter = other.listFilter;
50  attributes = other.attributes;
51  if (!ancestorFetchScope && other.ancestorFetchScope) {
52  ancestorFetchScope.reset(new CollectionFetchScope());
53  *ancestorFetchScope = *other.ancestorFetchScope;
54  } else if (ancestorFetchScope && !other.ancestorFetchScope) {
55  ancestorFetchScope.reset(nullptr);
56  }
57  fetchIdOnly = other.fetchIdOnly;
58  mIgnoreRetrievalErrors = other.mIgnoreRetrievalErrors;
59  }
60 
61 public:
62  QString resource;
63  QStringList contentMimeTypes;
66  QSet<QByteArray> attributes;
67  QScopedPointer<CollectionFetchScope> ancestorFetchScope;
68  bool statistics;
69  bool fetchIdOnly;
70  bool mIgnoreRetrievalErrors;
71 };
72 
74  : d(new CollectionFetchScopePrivate())
75 {
76 }
77 
79  : d(other.d)
80 {
81 }
82 
84 {
85 }
86 
88 {
89  if (&other != this) {
90  d = other.d;
91  }
92 
93  return *this;
94 }
95 
97 {
98  return d->resource.isEmpty() && d->contentMimeTypes.isEmpty() && !d->statistics && d->ancestorDepth == None && d->listFilter == Enabled;
99 }
100 
102 {
103  return d->statistics;
104 }
105 
107 {
108  d->statistics = include;
109 }
110 
112 {
113  return d->resource;
114 }
115 
117 {
118  d->resource = resource;
119 }
120 
122 {
123  return d->contentMimeTypes;
124 }
125 
127 {
128  d->contentMimeTypes = mimeTypes;
129 }
130 
132 {
133  return d->ancestorDepth;
134 }
135 
137 {
138  d->ancestorDepth = ancestorDepth;
139 }
140 
142 {
143  return d->listFilter;
144 }
145 
147 {
148  d->listFilter = listFilter;
149 }
150 
152 {
153  return d->attributes;
154 }
155 
157 {
158  d->fetchIdOnly = false;
159  if (fetch) {
160  d->attributes.insert(type);
161  } else {
162  d->attributes.remove(type);
163  }
164 }
165 
167 {
168  d->fetchIdOnly = fetchIdOnly;
169 }
170 
172 {
173  return d->fetchIdOnly;
174 }
175 
177 {
178  d->mIgnoreRetrievalErrors = enable;
179 }
180 
182 {
183  return d->mIgnoreRetrievalErrors;
184 }
185 
187 {
188  *d->ancestorFetchScope = scope;
189 }
190 
192 {
193  if (!d->ancestorFetchScope) {
194  return CollectionFetchScope();
195  }
196  return *d->ancestorFetchScope;
197 }
198 
200 {
201  if (!d->ancestorFetchScope) {
203  }
204  return *d->ancestorFetchScope;
205 }
206 
207 }
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
CollectionFetchScope()
Creates an empty collection fetch scope.
void setIgnoreRetrievalErrors(bool enabled)
Ignore retrieval errors while fetching collections, and always deliver what is available.
void setAncestorRetrieval(AncestorRetrieval ancestorDepth)
Sets how many levels of ancestor collections should be included in the retrieval. ...
Specifies which parts of a collection should be fetched from the Akonadi storage. ...
void setResource(const QString &resource)
Sets a resource filter, that is only collections owned by the specified resource are retrieved...
void setListFilter(ListFilter)
Sets a filter for the collections to be listed.
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
void setIncludeStatistics(bool include)
Sets whether collection statistics should be included in the retrieved results.
QString resource() const
Returns the resource identifier that is used as filter.
bool fetchIdOnly() const
Sets whether only the id of the tags should be retieved or the complete tag.
ListFilter
Describes the list filter.
CollectionFetchScope & operator=(const CollectionFetchScope &other)
Assigns the other to this scope and returns a reference to this scope.
bool isEmpty() const
Returns true if there is nothing to fetch.
void setContentMimeTypes(const QStringList &mimeTypes)
Sets a content mimetypes filter, that is only collections that contain at least one of the given mime...
CollectionFetchScope ancestorFetchScope() const
Returns the fetch scope for ancestor retrieval.
bool includeStatistics() const
Returns whether collection statistics should be included in the retrieved results.
void setAncestorFetchScope(const CollectionFetchScope &scope)
Sets the fetch scope for ancestor retrieval.
QStringList contentMimeTypes() const
Returns the content mimetypes filter.
void fetchAttribute(const QByteArray &type, bool fetch=true)
Sets whether the attribute of the given type should be fetched.
AncestorRetrieval
Describes the ancestor retrieval depth.
Helper integration between Akonadi and Qt.
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
Only retrieve enabled collections, ignoring the local preference.
~CollectionFetchScope()
Destroys the collection fetch scope.
No ancestor retrieval at all (the default)
void setFetchIdOnly(bool fetchIdOnly)
Sets whether only the id or the complete tag should be fetched.
ListFilter listFilter() const
Returns the list filter.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 30 2020 22:46:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.