1 | /* |
2 | Copyright (c) 2014 Christian Mollekopf <mollekopf@kolabsys.com> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef TAGFETCHSCOPE_H |
21 | #define TAGFETCHSCOPE_H |
22 | |
23 | #include "akonadi_export.h" |
24 | #include <QSharedPointer> |
25 | |
26 | namespace Akonadi { |
27 | |
28 | /** |
29 | * @short Specifies which parts of a tag should be fetched from the Akonadi storage. |
30 | * |
31 | * @since 4.13 |
32 | */ |
33 | class AKONADI_EXPORT TagFetchScope |
34 | { |
35 | public: |
36 | |
37 | /** |
38 | * Creates an empty tag fetch scope. |
39 | * |
40 | * Using an empty scope will only fetch the very basic meta data of tags, |
41 | * e.g. local id, remote id and mime type |
42 | */ |
43 | TagFetchScope(); |
44 | |
45 | /** |
46 | * Creates a new tag fetch scope from an @p other. |
47 | */ |
48 | TagFetchScope(const TagFetchScope &other); |
49 | |
50 | /** |
51 | * Destroys the tag fetch scope. |
52 | */ |
53 | ~TagFetchScope(); |
54 | |
55 | /** |
56 | * Assigns the @p other to this scope and returns a reference to this scope. |
57 | */ |
58 | TagFetchScope &operator=(const TagFetchScope &other); |
59 | |
60 | /** |
61 | * Returns all explicitly fetched attributes. |
62 | * |
63 | * Undefined if fetchAllAttributes() returns true. |
64 | * |
65 | * @see fetchAttribute() |
66 | */ |
67 | QSet<QByteArray> attributes() const; |
68 | |
69 | /** |
70 | * Sets whether the attribute of the given @p type should be fetched. |
71 | * |
72 | * @param type The attribute type to fetch. |
73 | * @param fetch @c true if the attribute should be fetched, @c false otherwise. |
74 | */ |
75 | void fetchAttribute(const QByteArray &type, bool fetch = true); |
76 | |
77 | /** |
78 | * Sets whether the attribute of the requested type should be fetched. |
79 | * |
80 | * @param fetch @c true if the attribute should be fetched, @c false otherwise. |
81 | */ |
82 | template <typename T> inline void fetchAttribute(bool fetch = true) |
83 | { |
84 | T dummy; |
85 | fetchAttribute(dummy.type(), fetch); |
86 | } |
87 | |
88 | private: |
89 | class Private; |
90 | //@cond PRIVATE |
91 | QSharedPointer<Private> d; |
92 | //@endcond |
93 | }; |
94 | |
95 | } |
96 | |
97 | // Q_DECLARE_METATYPE(Akonadi::TagFetchScope) |
98 | |
99 | #endif |
100 | |