MailCommon::SearchPattern

Search for usage in LXR

#include <searchpattern.h>

Inheritance diagram for MailCommon::SearchPattern:

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 &requiresModules, QString &code)
 
bool matches (const Akonadi::Item &item, bool ignoreBody=false) const
 
QString name () const
 
SearchPattern::Operator op () const
 
QDataStreamoperator<< (QDataStream &s)
 
const SearchPatternoperator= (const SearchPattern &aPattern)
 
QDataStreamoperator>> (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 (const QList< T > &other)
 
 QList (InputIterator first, InputIterator last)
 
 QList (QList< T > &&other)
 
 QList (std::initializer_list< T > args)
 
void append (const QList< T > &value)
 
void append (const T &value)
 
const T & at (int i) const const
 
T & back ()
 
const T & back () const const
 
QList::iterator begin ()
 
QList::const_iterator begin () const const
 
QList::const_iterator cbegin () const const
 
QList::const_iterator cend () const const
 
void clear ()
 
QList::const_iterator constBegin () const const
 
QList::const_iterator constEnd () const const
 
const T & constFirst () const const
 
const T & constLast () const const
 
bool contains (const T &value) const const
 
int count () const const
 
int count (const T &value) const const
 
QList::const_reverse_iterator crbegin () const const
 
QList::const_reverse_iterator crend () const const
 
bool empty () const const
 
QList::iterator end ()
 
QList::const_iterator end () const const
 
bool endsWith (const T &value) const const
 
QList::iterator erase (QList::iterator begin, QList::iterator end)
 
QList::iterator erase (QList::iterator pos)
 
T & first ()
 
const T & first () const const
 
T & front ()
 
const T & front () const const
 
int indexOf (const T &value, int from) const const
 
void insert (int i, const T &value)
 
QList::iterator insert (QList::iterator before, const T &value)
 
bool isEmpty () const const
 
T & last ()
 
const T & last () const const
 
int lastIndexOf (const T &value, int from) const const
 
int length () const const
 
QList< T > mid (int pos, int length) const const
 
void move (int from, int to)
 
bool operator!= (const QList< T > &other) const const
 
QList< T > operator+ (const QList< T > &other) const const
 
QList< T > & operator+= (const QList< T > &other)
 
QList< T > & operator+= (const T &value)
 
bool operator< (const QList< T > &lhs, const QList< T > &rhs)
 
QList< T > & operator<< (const QList< T > &other)
 
QList< T > & operator<< (const T &value)
 
QDataStreamoperator<< (QDataStream &out, const QList< T > &list)
 
bool operator<= (const QList< T > &lhs, const QList< T > &rhs)
 
QList< T > & operator= (const QList< T > &other)
 
QList< T > & operator= (QList< T > &&other)
 
bool operator== (const QList< T > &other) const const
 
bool operator> (const QList< T > &lhs, const QList< T > &rhs)
 
bool operator>= (const QList< T > &lhs, const QList< T > &rhs)
 
QDataStreamoperator>> (QDataStream &in, QList< T > &list)
 
T & operator[] (int i)
 
const T & operator[] (int i) const const
 
void pop_back ()
 
void pop_front ()
 
void prepend (const T &value)
 
void push_back (const T &value)
 
void push_front (const T &value)
 
uint qHash (const QList< T > &key, uint seed)
 
QList::reverse_iterator rbegin ()
 
QList::const_reverse_iterator rbegin () const const
 
int removeAll (const T &value)
 
void removeAt (int i)
 
void removeFirst ()
 
void removeLast ()
 
bool removeOne (const T &value)
 
QList::reverse_iterator rend ()
 
QList::const_reverse_iterator rend () const const
 
void replace (int i, const T &value)
 
void reserve (int alloc)
 
int size () const const
 
bool startsWith (const T &value) const const
 
void swap (int i, int j)
 
void swap (QList< T > &other)
 
void swapItemsAt (int i, int j)
 
takeAt (int i)
 
takeFirst ()
 
takeLast ()
 
QSet< T > toSet () const const
 
std::list< T > toStdList () const const
 
QVector< T > toVector () const const
 
value (int i) const const
 
value (int i, const T &defaultValue) const const
 

Static Public Member Functions

static int filterRulesMaximumSize ()
 
- 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)
 

Additional Inherited Members

- Public Attributes inherited from QList< SearchRule::Ptr >
typedef const_pointer
 
typedef const_reference
 
typedef const_reverse_iterator
 
typedef ConstIterator
 
typedef difference_type
 
typedef Iterator
 
typedef pointer
 
typedef reference
 
typedef reverse_iterator
 
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 [email protected][email protected]kde.[email protected]org

Definition at line 58 of file searchpattern.h.

Member Enumeration Documentation

◆ 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.

Definition at line 67 of file searchpattern.h.

Constructor & Destructor Documentation

◆ SearchPattern() [1/2]

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 32 of file searchpattern.cpp.

◆ SearchPattern() [2/2]

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 38 of file searchpattern.cpp.

◆ ~SearchPattern()

SearchPattern::~SearchPattern ( )
default

Destructor.

Deletes all stored rules!

Member Function Documentation

◆ asAkonadiQuery()

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

Returns the pattern as akonadi query.

Definition at line 262 of file searchpattern.cpp.

◆ asString()

QString SearchPattern::asString ( ) const

Returns the pattern as string.

For debugging.

Definition at line 238 of file searchpattern.cpp.

◆ deserialize()

void SearchPattern::deserialize ( const QByteArray str)

Constructs the pattern from a byte array serialization.

Definition at line 319 of file searchpattern.cpp.

◆ matches()

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 46 of file searchpattern.cpp.

◆ name()

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

Returns the name of the search pattern.

Definition at line 149 of file searchpattern.h.

◆ op()

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

Returns the filter operator.

Definition at line 166 of file searchpattern.h.

◆ operator=()

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

Overloaded assignment operator.

Makes a deep copy.

Definition at line 292 of file searchpattern.cpp.

◆ purify()

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 98 of file searchpattern.cpp.

◆ readConfig()

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 121 of file searchpattern.cpp.

◆ requiredPart()

SearchRule::RequiredPart SearchPattern::requiredPart ( ) const

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

See SearchRule::RequiredPart

Definition at line 86 of file searchpattern.cpp.

◆ serialize()

QByteArray SearchPattern::serialize ( ) const

Writes the pattern into a byte array for persistence purposes.

Definition at line 311 of file searchpattern.cpp.

◆ setName()

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 158 of file searchpattern.h.

◆ setOp()

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

Sets the filter operator.

Definition at line 174 of file searchpattern.h.

◆ writeConfig()

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 194 of file searchpattern.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Jun 9 2023 04:00:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.