kmail

KMSearchPattern Class Reference

#include <kmsearchpattern.h>

Inherits TQPtrList< T >.

Public Types

enum  Operator { OpAnd , OpOr }
 

Public Member Functions

 KMSearchPattern (const TDEConfig *config=0)
 
 ~KMSearchPattern ()
 
bool matches (const KMMessage *msg, bool ignoreBody=false) const
 
bool matches (const DwString &str, bool ignoreBody=false) const
 
bool matches (TQ_UINT32 sernum, bool ignoreBody=false) const
 
bool requiresBody () const
 
void purify ()
 
void readConfig (const TDEConfig *config)
 
void writeConfig (TDEConfig *config) const
 
TQString name () const
 
void setName (const TQString &newName)
 
KMSearchPattern::Operator op () const
 
void setOp (KMSearchPattern::Operator aOp)
 
TQString asString () const
 
const KMSearchPatternoperator= (const KMSearchPattern &aPattern)
 

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 TDEConfig group and there is a constructor, mainly used by KMFilter to initialize from a preset TDEConfig-Group.

From a class hierarchy point of view, it is a TQPtrList of KMSearchRule'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 TQPtrList 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 Marc@.nosp@m.Mutz.nosp@m..com

Definition at line 307 of file kmsearchpattern.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 iff any of it's rules matches.

Definition at line 316 of file kmsearchpattern.h.

Constructor & Destructor Documentation

◆ KMSearchPattern()

KMSearchPattern::KMSearchPattern ( const TDEConfig *  config = 0)

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

This feature is mainly (solely?) used in KMFilter, as we don't allow to store search patterns in the config (yet). If config is 0, provides a pattern with minimal, but sufficient initialization. Unmodified, such a pattern will fail to match any KMMessage. You can query for such an empty rule by using isEmpty, which is inherited from TQPtrList.

Definition at line 714 of file kmsearchpattern.cpp.

◆ ~KMSearchPattern()

KMSearchPattern::~KMSearchPattern ( )

Destructor.

Deletes all stored rules!

Definition at line 724 of file kmsearchpattern.cpp.

Member Function Documentation

◆ asString()

TQString KMSearchPattern::asString ( ) const

Returns the pattern as string.

For debugging.

Definition at line 915 of file kmsearchpattern.cpp.

◆ matches()

bool KMSearchPattern::matches ( const KMMessage msg,
bool  ignoreBody = false 
) const

The central function of this class.

Tries to match the set of rules against a KMMessage. 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 728 of file kmsearchpattern.cpp.

◆ name()

TQString KMSearchPattern::name ( ) const
inline

Get the name of the search pattern.

Definition at line 375 of file kmsearchpattern.h.

◆ op()

KMSearchPattern::Operator KMSearchPattern::op ( ) const
inline

Get the filter operator.

Definition at line 381 of file kmsearchpattern.h.

◆ operator=()

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

Overloaded assignment operator.

Makes a deep copy.

Definition at line 928 of file kmsearchpattern.cpp.

◆ purify()

void KMSearchPattern::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 KMSearchPatternEdit).

Definition at line 815 of file kmsearchpattern.cpp.

◆ readConfig()

void KMSearchPattern::readConfig ( const TDEConfig *  config)

Reads a search pattern from a TDEConfig.

The group has to be preset. 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 829 of file kmsearchpattern.cpp.

◆ requiresBody()

bool KMSearchPattern::requiresBody ( ) const

Returns true if the pattern only depends the DwString that backs a message.

Definition at line 807 of file kmsearchpattern.cpp.

◆ setName()

void KMSearchPattern::setName ( const TQString &  newName)
inline

Set the name of the search pattern.

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

Definition at line 378 of file kmsearchpattern.h.

◆ setOp()

void KMSearchPattern::setOp ( KMSearchPattern::Operator  aOp)
inline

Set the filter operator.

Definition at line 383 of file kmsearchpattern.h.

◆ writeConfig()

void KMSearchPattern::writeConfig ( TDEConfig *  config) const

Writes itself into config.

The group has to be preset. Tries to delete old-style keys by overwriting them with TQString().

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

Definition at line 895 of file kmsearchpattern.cpp.


The documentation for this class was generated from the following files: