• 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 asSparqlQuery (QString &queryStr, const KUrl::List &url=KUrl::List()) 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
 
void purify ()
 
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
 

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

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

Definition at line 612 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 1510 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 1516 of file searchpattern.cpp.

SearchPattern::~SearchPattern ( )

Destructor.

Deletes all stored rules!

Definition at line 1522 of file searchpattern.cpp.

Member Function Documentation

MailCommon::SearchPattern::SparqlQueryError SearchPattern::asSparqlQuery ( QString &  queryStr,
const KUrl::List &  url = KUrl::List() 
) const

Returns the pattern as a SPARQL query.

Definition at line 1755 of file searchpattern.cpp.

QString SearchPattern::asString ( ) const

Returns the pattern as string.

For debugging.

Definition at line 1710 of file searchpattern.cpp.

void SearchPattern::deserialize ( const QByteArray &  str)

Constructs the pattern from a byte array serialization.

Definition at line 1849 of file searchpattern.cpp.

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

Definition at line 1894 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 1526 of file searchpattern.cpp.

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

Returns the name of the search pattern.

Definition at line 688 of file searchpattern.h.

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

Returns the filter operator.

Definition at line 705 of file searchpattern.h.

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

Definition at line 1875 of file searchpattern.cpp.

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

Overloaded assignment operator.

Makes a deep copy.

Definition at line 1822 of file searchpattern.cpp.

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

Definition at line 1855 of file searchpattern.cpp.

void SearchPattern::purify ( )

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 1579 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 1594 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 1566 of file searchpattern.cpp.

QByteArray SearchPattern::serialize ( ) const

Writes the pattern into a byte array for persistance purposes.

Definition at line 1841 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 697 of file searchpattern.h.

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

Sets the filter operator.

Definition at line 713 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 1674 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-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:15 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

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