• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.14
  • kdepim
  • mailcommon
  • search
searchpattern.h
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 
3  Author: Marc Mutz <mutz@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef MAILCOMMON_SEARCHPATTERN_H
21 #define MAILCOMMON_SEARCHPATTERN_H
22 
23 #include "mailcommon_export.h"
24 #include "searchrule/searchrule.h"
25 #include <KLocale>
26 #include <KUrl>
27 
28 #include <QList>
29 #include <QString>
30 
31 #ifndef Q_MOC_RUN
32 #include <boost/shared_ptr.hpp>
33 #endif
34 #include <akonadi/searchquery.h>
35 
36 namespace Akonadi {
37 class Item;
38 }
39 
40 namespace KMime {
41 class Message;
42 }
43 
44 class KConfigGroup;
45 
46 namespace MailCommon {
47 
48 // maximum number of filter rules per filter
49 const int FILTER_MAX_RULES = 8;
50 
51 
52 // Needed for MSVC 2010, as it seems to not implicit cast for a pointer anymore
53 #ifdef _MSC_VER
54 uint qHash( SearchRule::Ptr sr );
55 #endif
56 
57 
58 
59 // ------------------------------------------------------------------------
60 
79 class MAILCOMMON_EXPORT SearchPattern : public QList<SearchRule::Ptr>
80 {
81 
82 public:
89  enum Operator {
90  OpAnd,
91  OpOr,
92  OpAll
93  };
94 
95 
96  enum SparqlQueryError {
97  NoError = 0,
98  MissingCheck,
99  FolderEmptyOrNotIndexed,
100  EmptyResult,
101  NotEnoughCharacters
102  };
103 
110  SearchPattern();
111 
117  explicit SearchPattern( const KConfigGroup &config );
118 
120  ~SearchPattern();
121 
132  bool matches( const Akonadi::Item &item, bool ignoreBody = false ) const;
133 
137  SearchRule::RequiredPart requiredPart() const;
138 
144  QString purify(bool removeAction = true);
145 
158  void readConfig( const KConfigGroup &config );
159 
167  void writeConfig( KConfigGroup &config ) const;
168 
172  QString name() const
173  {
174  return mName;
175  }
176 
181  void setName( const QString &newName )
182  {
183  mName = newName;
184  }
185 
189  SearchPattern::Operator op() const
190  {
191  return mOperator;
192  }
193 
197  void setOp( SearchPattern::Operator aOp )
198  {
199  mOperator = aOp;
200  }
201 
205  QString asString() const;
206 
210  SparqlQueryError asAkonadiQuery(Akonadi::SearchQuery &) const;
211 
215  const SearchPattern &operator=( const SearchPattern &aPattern );
216 
220  QByteArray serialize() const;
221 
225  void deserialize( const QByteArray & );
226 
227  QDataStream &operator>>( QDataStream &s ) const;
228  QDataStream &operator<<( QDataStream &s );
229 
230 
231  void generateSieveScript(QStringList &requires, QString &code);
232 
233 private:
241  void importLegacyConfig( const KConfigGroup &config );
242 
247  void init();
248  QString mName;
249  Operator mOperator;
250 };
251 
252 }
253 
254 Q_DECLARE_METATYPE(MailCommon::SearchRule::RequiredPart)
255 
256 #endif /* MAILCOMMON_SEARCHPATTERN_H_ */
MailCommon::SearchPattern::op
SearchPattern::Operator op() const
Returns the filter operator.
Definition: searchpattern.h:189
MailCommon::SearchPattern::MissingCheck
Definition: searchpattern.h:98
QByteArray
MailCommon::SearchPattern::OpOr
Definition: searchpattern.h:91
QDataStream
MailCommon::SearchRule::Ptr
boost::shared_ptr< SearchRule > Ptr
Defines a pointer to a search rule.
Definition: searchrule.h:44
MailCommon::SearchPattern::Operator
Operator
Boolean operators that connect the return values of the individual rules.
Definition: searchpattern.h:89
mailcommon_export.h
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchrule.h:79
MailCommon::SearchPattern::FolderEmptyOrNotIndexed
Definition: searchpattern.h:99
QString
QList
MailCommon::SearchPattern
This class is an abstraction of a search over messages.
Definition: searchpattern.h:79
QStringList
MAILCOMMON_EXPORT
#define MAILCOMMON_EXPORT
Definition: mailcommon_export.h:35
MailCommon::SearchPattern::OpAnd
Definition: searchpattern.h:90
MailCommon::operator>>
MAILCOMMON_EXPORT QDataStream & operator>>(QDataStream &stream, MailFilter &filter)
Definition: mailfilter.cpp:668
MailCommon::operator<<
MAILCOMMON_EXPORT QDataStream & operator<<(QDataStream &stream, const MailFilter &filter)
Definition: mailfilter.cpp:637
searchrule.h
MailCommon::SearchPattern::SparqlQueryError
SparqlQueryError
Definition: searchpattern.h:96
MailCommon::SearchPattern::setOp
void setOp(SearchPattern::Operator aOp)
Sets the filter operator.
Definition: searchpattern.h:197
MailCommon::SearchPattern::EmptyResult
Definition: searchpattern.h:100
MailCommon::FILTER_MAX_RULES
const int FILTER_MAX_RULES
Definition: searchpattern.h:49
MailCommon::SearchPattern::setName
void setName(const QString &newName)
Sets the name of the search pattern.
Definition: searchpattern.h:181
MailCommon::SearchPattern::name
QString name() const
Returns the name of the search pattern.
Definition: searchpattern.h:172
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal