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

mailcommon

  • MailCommon
  • SearchPattern
Public Types | Public Member Functions | List of all members
MailCommon::SearchPattern Class Reference

#include <searchpattern.h>

Inheritance diagram for MailCommon::SearchPattern:
Inheritance graph
[legend]

Public Types

enum  Operator { OpAnd, OpOr, OpAll }
 
enum  SparqlQueryError {
  NoError = 0, MissingCheck, FolderEmptyOrNotIndexed, EmptyResult,
  NotEnoughCharacters
}
 

Public Member Functions

 SearchPattern ()
 
 SearchPattern (const KConfigGroup &config)
 
 ~SearchPattern ()
 
SparqlQueryError asAkonadiQuery (Akonadi::SearchQuery &) const
 
QString asString () const
 
void deserialize (const QByteArray &)
 
void generateSieveScript (QStringList &requires, QString &code)
 
bool matches (const Akonadi::Item &item, bool ignoreBody=false) const
 
QString name () const
 
SearchPattern::Operator op () const
 
QDataStream & operator<< (QDataStream &s)
 
const SearchPattern & operator= (const SearchPattern &aPattern)
 
QDataStream & operator>> (QDataStream &s) const
 
QString purify (bool removeAction=true)
 
void readConfig (const KConfigGroup &config)
 
SearchRule::RequiredPart requiredPart () const
 
QByteArray serialize () const
 
void setName (const QString &newName)
 
void setOp (SearchPattern::Operator aOp)
 
void writeConfig (KConfigGroup &config) const
 
- Public Member Functions inherited from QList< SearchRule::Ptr >
 QList ()
 
 QList (const QList< T > &other)
 
 QList (std::initializer_list< T > args)
 
 ~QList ()
 
void append (const T &value)
 
void append (const QList< T > &value)
 
const T & at (int i) const
 
T & back ()
 
const T & back () const
 
iterator begin ()
 
const_iterator begin () const
 
void clear ()
 
const_iterator constBegin () const
 
const_iterator constEnd () const
 
bool contains (const T &value) const
 
int count (const T &value) const
 
int count () const
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
bool endsWith (const T &value) const
 
iterator erase (iterator pos)
 
iterator erase (iterator begin, iterator end)
 
iterator find (iterator from, const T &t)
 
iterator find (const T &t)
 
const_iterator find (const T &t) const
 
const_iterator find (const_iterator from, const T &t) const
 
int findIndex (const T &t) const
 
T & first ()
 
const T & first () const
 
T & front ()
 
const T & front () const
 
int indexOf (const T &value, int from) const
 
void insert (int i, const T &value)
 
iterator insert (iterator before, const T &value)
 
bool isEmpty () const
 
T & last ()
 
const T & last () const
 
int lastIndexOf (const T &value, int from) const
 
int length () const
 
QList< T > mid (int pos, int length) const
 
void move (int from, int to)
 
bool operator!= (const QList< T > &other) const
 
QList< T > operator+ (const QList< T > &other) const
 
QList< T > & operator+= (const QList< T > &other)
 
QList< T > & operator+= (const T &value)
 
QList< T > & operator<< (const T &value)
 
QList< T > & operator<< (const QList< T > &other)
 
QList< T > & operator= (const QList< T > &other)
 
bool operator== (const QList< T > &other) const
 
T & operator[] (int i)
 
const T & operator[] (int i) const
 
void pop_back ()
 
void pop_front ()
 
void prepend (const T &value)
 
void push_back (const T &value)
 
void push_front (const T &value)
 
iterator remove (iterator pos)
 
int remove (const T &t)
 
int removeAll (const T &value)
 
void removeAt (int i)
 
void removeFirst ()
 
void removeLast ()
 
bool removeOne (const T &value)
 
void replace (int i, const T &value)
 
void reserve (int alloc)
 
int size () const
 
bool startsWith (const T &value) const
 
void swap (int i, int j)
 
void swap (QList< T > &other)
 
T takeAt (int i)
 
T takeFirst ()
 
T takeLast ()
 
QSet< T > toSet () const
 
std::list< T > toStdList () const
 
QVector< T > toVector () const
 
T value (int i, const T &defaultValue) const
 
T value (int i) const
 

Additional Inherited Members

- Static Public Member Functions inherited from QList< SearchRule::Ptr >
QList< T > fromSet (const QSet< T > &set)
 
QList< T > fromStdList (const std::list< T > &list)
 
QList< T > fromVector (const QVector< T > &vector)
 
- Public Attributes inherited from QList< SearchRule::Ptr >
typedef const_pointer
 
typedef const_reference
 
typedef ConstIterator
 
typedef difference_type
 
typedef Iterator
 
typedef pointer
 
typedef reference
 
typedef size_type
 
typedef value_type
 

Detailed Description

This class is an abstraction of a search over messages.

It is intended to be used inside a KFilter (which adds KFilterAction's), as well as in KMSearch. It can read and write itself into a KConfig group and there is a constructor, mainly used by KMFilter to initialize from a preset KConfig-Group.

From a class hierarchy point of view, it is a QPtrList of SearchRule's that adds the boolean operators (see Operator) 'and' and 'or' that connect the rules logically, and has a name under which it could be stored in the config file.

As a QPtrList with autoDelete enabled, it assumes that it is the central repository for the rules it contains. So if you want to reuse a rule in another pattern, make a deep copy of that rule.

An abstraction of a search over messages.

Author
Marc Mutz mutz@.nosp@m.kde..nosp@m.org

Definition at line 79 of file searchpattern.h.

Member Enumeration Documentation

enum MailCommon::SearchPattern::Operator

Boolean operators that connect the return values of the individual rules.

A pattern with OpAnd will match iff all it's rules match, whereas a pattern with OpOr will match if any of it's rules matches.

Enumerator
OpAnd 
OpOr 
OpAll 

Definition at line 89 of file searchpattern.h.

enum MailCommon::SearchPattern::SparqlQueryError
Enumerator
NoError 
MissingCheck 
FolderEmptyOrNotIndexed 
EmptyResult 
NotEnoughCharacters 

Definition at line 96 of file searchpattern.h.

Constructor & Destructor Documentation

SearchPattern::SearchPattern ( )

Constructor which provides a pattern with minimal, but sufficient initialization.

Unmodified, such a pattern will fail to match any KMime::Message. You can query for such an empty rule by using isEmpty, which is inherited from QPtrList.

Definition at line 67 of file searchpattern.cpp.

SearchPattern::SearchPattern ( const KConfigGroup &  config)
explicit

Constructor that initializes from a given KConfig group, if given.

This feature is mainly (solely?) used in KMFilter, as we don't allow to store search patterns in the config (yet).

Definition at line 73 of file searchpattern.cpp.

SearchPattern::~SearchPattern ( )

Destructor.

Deletes all stored rules!

Definition at line 79 of file searchpattern.cpp.

Member Function Documentation

SearchPattern::SparqlQueryError SearchPattern::asAkonadiQuery ( Akonadi::SearchQuery &  query) const

Returns the pattern as akonadi query.

Definition at line 301 of file searchpattern.cpp.

QString SearchPattern::asString ( ) const

Returns the pattern as string.

For debugging.

Definition at line 277 of file searchpattern.cpp.

void SearchPattern::deserialize ( const QByteArray &  str)

Constructs the pattern from a byte array serialization.

Definition at line 358 of file searchpattern.cpp.

void SearchPattern::generateSieveScript ( QStringList &  requires,
QString &  code 
)

Definition at line 403 of file searchpattern.cpp.

bool SearchPattern::matches ( const Akonadi::Item &  item,
bool  ignoreBody = false 
) const

The central function of this class.

Tries to match the set of rules against a KMime::Message. It's virtual to allow derived classes with added rules to reimplement it, yet reimplemented methods should and (&&) the result of this function with their own result or else most functionality is lacking, or has to be reimplemented, since the rules are private to this class.

Returns
true if the match was successful, false otherwise.

Definition at line 83 of file searchpattern.cpp.

QString MailCommon::SearchPattern::name ( ) const
inline

Returns the name of the search pattern.

Definition at line 172 of file searchpattern.h.

SearchPattern::Operator MailCommon::SearchPattern::op ( ) const
inline

Returns the filter operator.

Definition at line 189 of file searchpattern.h.

QDataStream & SearchPattern::operator<< ( QDataStream &  s)

Definition at line 384 of file searchpattern.cpp.

const SearchPattern & SearchPattern::operator= ( const SearchPattern &  aPattern)

Overloaded assignment operator.

Makes a deep copy.

Definition at line 331 of file searchpattern.cpp.

QDataStream & SearchPattern::operator>> ( QDataStream &  s) const

Definition at line 364 of file searchpattern.cpp.

QString SearchPattern::purify ( bool  removeAction = true)

Removes all empty rules from the list.

You should call this method whenever the user had had control of the rules outside of this class. (e.g. after editing it with SearchPatternEdit).

Definition at line 136 of file searchpattern.cpp.

void SearchPattern::readConfig ( const KConfigGroup &  config)

Reads a search pattern from a KConfigGroup.

If it does not find a valid saerch pattern in the preset group, initializes the pattern as if it were constructed using the default constructor.

For backwards compatibility with previous versions of KMail, it checks for old-style filter rules (e.g. using OpIgnore) in config und converts them to the new format on writeConfig.

Derived classes reimplementing readConfig() should also call this method, or else the rules will not be loaded.

Definition at line 161 of file searchpattern.cpp.

SearchRule::RequiredPart SearchPattern::requiredPart ( ) const

Returns the required part from the item that is needed for the search to operate.

See RequiredPart

Definition at line 123 of file searchpattern.cpp.

QByteArray SearchPattern::serialize ( ) const

Writes the pattern into a byte array for persistance purposes.

Definition at line 350 of file searchpattern.cpp.

void MailCommon::SearchPattern::setName ( const QString &  newName)
inline

Sets the name of the search pattern.

KMFilter uses this to store it's own name, too.

Definition at line 181 of file searchpattern.h.

void MailCommon::SearchPattern::setOp ( SearchPattern::Operator  aOp)
inline

Sets the filter operator.

Definition at line 197 of file searchpattern.h.

void SearchPattern::writeConfig ( KConfigGroup &  config) const

Writes itself into config.

Tries to delete old-style keys by overwriting them with QString().

Derived classes reimplementing writeConfig() should also call this method, or else the rules will not be stored.

Definition at line 241 of file searchpattern.cpp.


The documentation for this class was generated from the following files:
  • searchpattern.h
  • searchpattern.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:41 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