Akonadi

searchquery.h
1 /*
2  Copyright (c) 2014 Daniel Vrátil <[email protected]>
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 AKONADI_SEARCHQUERY_H
21 #define AKONADI_SEARCHQUERY_H
22 
23 #include <QSharedPointer>
24 
25 #include "akonadicore_export.h"
26 
27 namespace Akonadi
28 {
29 
39 class AKONADICORE_EXPORT SearchTerm
40 {
41 public:
42  enum Relation {
43  RelAnd,
44  RelOr
45  };
46 
47  enum Condition {
48  CondEqual,
49  CondGreaterThan,
50  CondGreaterOrEqual,
51  CondLessThan,
52  CondLessOrEqual,
53  CondContains
54  };
55 
59  explicit SearchTerm(SearchTerm::Relation relation = SearchTerm::RelAnd);
60 
64  SearchTerm(const QString &key, const QVariant &value, SearchTerm::Condition condition = SearchTerm::CondEqual);
65 
66  SearchTerm(const SearchTerm &other);
67  ~SearchTerm();
68 
69  SearchTerm &operator=(const SearchTerm &other);
70  Q_REQUIRED_RESULT bool operator==(const SearchTerm &other) const;
71 
72  Q_REQUIRED_RESULT bool isNull() const;
73 
77  Q_REQUIRED_RESULT QString key() const;
78 
82  Q_REQUIRED_RESULT QVariant value() const;
83 
87  Q_REQUIRED_RESULT SearchTerm::Condition condition() const;
88 
96  void addSubTerm(const SearchTerm &term);
97 
101  Q_REQUIRED_RESULT QList<SearchTerm> subTerms() const;
102 
106  Q_REQUIRED_RESULT SearchTerm::Relation relation() const;
107 
111  void setIsNegated(bool negated);
112 
116  Q_REQUIRED_RESULT bool isNegated() const;
117 
118 private:
119  class Private;
121 };
122 
128 class AKONADICORE_EXPORT SearchQuery
129 {
130 public:
134  explicit SearchQuery(SearchTerm::Relation rel = SearchTerm::RelAnd);
135 
136  ~SearchQuery();
137  SearchQuery(const SearchQuery &other);
138  SearchQuery &operator=(const SearchQuery &other);
139  bool operator==(const SearchQuery &other) const;
140 
141  bool isNull() const;
142 
146  void addTerm(const QString &key, const QVariant &value, SearchTerm::Condition condition = SearchTerm::CondEqual);
147 
151  void addTerm(const SearchTerm &term);
152 
156  void setTerm(const SearchTerm &term);
157 
161  SearchTerm term() const;
162 
169  void setLimit(int limit);
170 
176  int limit() const;
177 
178  QByteArray toJSON() const;
179  static SearchQuery fromJSON(const QByteArray &json);
180 
181 private:
182  class Private;
184 
185 };
186 
194 class AKONADICORE_EXPORT EmailSearchTerm : public SearchTerm
195 {
196 public:
197 
202  Unknown,
203  Subject,
204  Body,
205  Message, //Complete message including headers, body and attachment
206  Headers, //All headers
207  HeaderFrom,
208  HeaderTo,
209  HeaderCC,
210  HeaderBCC,
211  HeaderReplyTo,
212  HeaderOrganization,
213  HeaderListId,
214  HeaderResentFrom,
215  HeaderXLoop,
216  HeaderXMailingList,
217  HeaderXSpamFlag,
218  HeaderDate, //Expects QDateTime
219  HeaderOnlyDate, //Expectes QDate
220  MessageStatus, //Expects message flag from Akonadi::MessageFlags. Boolean filter.
221  ByteSize, //Expects int
222  Attachment, //Textsearch on attachment
223  MessageTag
224  };
225 
229  EmailSearchTerm(EmailSearchField field, const QVariant &value, SearchTerm::Condition condition = SearchTerm::CondEqual);
230 
234  static QString toKey(EmailSearchField);
235 
239  static EmailSearchField fromKey(const QString &key);
240 };
241 
249 class AKONADICORE_EXPORT ContactSearchTerm : public SearchTerm
250 {
251 public:
252  enum ContactSearchField {
253  Unknown,
254  Name,
255  Email,
256  Nickname,
257  Uid,
258  All //Special field: matches all contacts.
259  };
260 
261  ContactSearchTerm(ContactSearchField field, const QVariant &value, SearchTerm::Condition condition = SearchTerm::CondEqual);
262 
266  static QString toKey(ContactSearchField);
267 
271  static ContactSearchField fromKey(const QString &key);
272 };
273 
281 class AKONADICORE_EXPORT IncidenceSearchTerm : public SearchTerm
282 {
283 public:
284  enum IncidenceSearchField {
285  Unknown,
286  All,
287  PartStatus, // Own PartStatus
288  Organizer,
289  Summary,
290  Location
291  };
292 
293  IncidenceSearchTerm(IncidenceSearchField field, const QVariant &value, SearchTerm::Condition condition = SearchTerm::CondEqual);
294 
298  static QString toKey(IncidenceSearchField);
299 
303  static IncidenceSearchField fromKey(const QString &key);
304 };
305 
306 }
307 
308 #endif // AKONADI_SEARCHQUERY_H
Subject
A query that can be passed to ItemSearchJob or others.
Definition: searchquery.h:128
A search term for a incidence field.
Definition: searchquery.h:281
Helper integration between Akonadi and Qt.
Search term represents the actual condition within query.
Definition: searchquery.h:39
Location
A search term for an email field.
Definition: searchquery.h:194
A search term for a contact field.
Definition: searchquery.h:249
EmailSearchField
All fields expect a search string unless noted otherwise.
Definition: searchquery.h:201
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.