1/*
2 Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
3 Copyright (c) 2009 Volker Krause <vkrause@kde.org>
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
26namespace Akonadi {
27
28class CollectionFetchScopePrivate : public QSharedData
29{
30public:
31 CollectionFetchScopePrivate()
32 : ancestorDepth(CollectionFetchScope::None)
33 , statistics(false)
34 , listFilter(CollectionFetchScope::Enabled)
35 {
36 }
37
38 CollectionFetchScopePrivate(const CollectionFetchScopePrivate &other)
39 : QSharedData(other)
40 {
41 resource = other.resource;
42 contentMimeTypes = other.contentMimeTypes;
43 ancestorDepth = other.ancestorDepth;
44 statistics = other.statistics;
45 listFilter = other.listFilter;
46 }
47
48public:
49 QString resource;
50 QStringList contentMimeTypes;
51 CollectionFetchScope::AncestorRetrieval ancestorDepth;
52 bool statistics;
53 CollectionFetchScope::ListFilter listFilter;
54};
55
56CollectionFetchScope::CollectionFetchScope()
57{
58 d = new CollectionFetchScopePrivate();
59}
60
61CollectionFetchScope::CollectionFetchScope(const CollectionFetchScope &other)
62 : d(other.d)
63{
64}
65
66CollectionFetchScope::~CollectionFetchScope()
67{
68}
69
70CollectionFetchScope &CollectionFetchScope::operator=(const CollectionFetchScope &other)
71{
72 if (&other != this) {
73 d = other.d;
74 }
75
76 return *this;
77}
78
79bool CollectionFetchScope::isEmpty() const
80{
81 return d->resource.isEmpty() && d->contentMimeTypes.isEmpty() && !d->statistics && d->ancestorDepth == None && d->listFilter == Enabled;
82}
83
84bool CollectionFetchScope::includeUnubscribed() const
85{
86 return includeUnsubscribed();
87}
88
89bool CollectionFetchScope::includeUnsubscribed() const
90{
91 return (d->listFilter == NoFilter);
92}
93
94void CollectionFetchScope::setIncludeUnsubscribed(bool include)
95{
96 if (include) {
97 d->listFilter = NoFilter;
98 } else {
99 d->listFilter = Enabled;
100 }
101}
102
103bool CollectionFetchScope::includeStatistics() const
104{
105 return d->statistics;
106}
107
108void CollectionFetchScope::setIncludeStatistics(bool include)
109{
110 d->statistics = include;
111}
112
113QString CollectionFetchScope::resource() const
114{
115 return d->resource;
116}
117
118void CollectionFetchScope::setResource(const QString &resource)
119{
120 d->resource = resource;
121}
122
123QStringList CollectionFetchScope::contentMimeTypes() const
124{
125 return d->contentMimeTypes;
126}
127
128void CollectionFetchScope::setContentMimeTypes(const QStringList &mimeTypes)
129{
130 d->contentMimeTypes = mimeTypes;
131}
132
133CollectionFetchScope::AncestorRetrieval CollectionFetchScope::ancestorRetrieval() const
134{
135 return d->ancestorDepth;
136}
137
138void CollectionFetchScope::setAncestorRetrieval(AncestorRetrieval ancestorDepth)
139{
140 d->ancestorDepth = ancestorDepth;
141}
142
143CollectionFetchScope::ListFilter CollectionFetchScope::listFilter() const
144{
145 return d->listFilter;
146}
147
148void CollectionFetchScope::setListFilter(CollectionFetchScope::ListFilter listFilter)
149{
150 d->listFilter = listFilter;
151}
152
153
154}
155