mailcommon
#include <searchpattern.h>
Public Types | |
enum | Function { FuncNone = -1, FuncContains = 0, FuncContainsNot, FuncEquals, FuncNotEqual, FuncRegExp, FuncNotRegExp, FuncIsGreater, FuncIsLessOrEqual, FuncIsLess, FuncIsGreaterOrEqual, FuncIsInAddressbook, FuncIsNotInAddressbook, FuncIsInCategory, FuncIsNotInCategory, FuncHasAttachment, FuncHasNoAttachment, FuncStartWith, FuncNotStartWith, FuncEndWith, FuncNotEndWith } |
typedef boost::shared_ptr < SearchRule > | Ptr |
enum | RequiredPart { Envelope = 0, Header, CompleteMessage } |
Public Member Functions | |
SearchRule (const QByteArray &field=0, Function function=FuncContains, const QString &contents=QString()) | |
SearchRule (const SearchRule &other) | |
virtual | ~SearchRule () |
virtual void | addQueryTerms (Nepomuk2::Query::GroupTerm &groupTerm, bool &emptyIsNotAnError) const =0 |
const QString | asString () const |
QString | contents () const |
QByteArray | field () const |
Function | function () const |
void | generateSieveScript (QStringList &requires, QString &code) |
virtual bool | isEmpty () const =0 |
virtual bool | matches (const Akonadi::Item &item) const =0 |
const SearchRule & | operator= (const SearchRule &other) |
QDataStream & | operator>> (QDataStream &) const |
virtual SearchRule::RequiredPart | requiredPart () const =0 |
void | setContents (const QString &contents) |
void | setField (const QByteArray &name) |
void | setFunction (Function function) |
void | writeConfig (KConfigGroup &group, int index) const |
Static Public Member Functions | |
static SearchRule::Ptr | createInstance (const QByteArray &field=0, Function function=FuncContains, const QString &contents=QString()) |
static SearchRule::Ptr | createInstance (const QByteArray &field, const char *function, const QString &contents) |
static SearchRule::Ptr | createInstance (const SearchRule &other) |
static SearchRule::Ptr | createInstance (QDataStream &stream) |
static SearchRule::Ptr | createInstanceFromConfig (const KConfigGroup &group, int index) |
Protected Member Functions | |
void | addAndNegateTerm (const Nepomuk2::Query::Term &term, Nepomuk2::Query::GroupTerm &termGroup) const |
bool | isNegated () const |
Nepomuk2::Query::ComparisonTerm::Comparator | nepomukComparator () const |
QString | quote (const QString &content) const |
Detailed Description
This class represents one search pattern rule.
Incoming mail is sent through the list of mail filter rules before it is placed in the associated mail folder (usually "inbox"). This class represents one mail filter rule. It is also used to represent a search rule as used by the search dialog and folders.
Definition at line 63 of file searchpattern.h.
Member Typedef Documentation
typedef boost::shared_ptr<SearchRule> MailCommon::SearchRule::Ptr |
Defines a pointer to a search rule.
Definition at line 69 of file searchpattern.h.
Member Enumeration Documentation
Describes operators for comparison of field and contents.
If you change the order or contents of the enum: do not forget to change funcConfigNames[], sFilterFuncList and matches() in SearchRule, too. Also, it is assumed that these functions come in pairs of logical opposites (ie. "=" <-> "!=", ">" <-> "<=", etc.).
Definition at line 80 of file searchpattern.h.
Enumerator | |
---|---|
Envelope | |
Header | |
CompleteMessage |
Definition at line 104 of file searchpattern.h.
Constructor & Destructor Documentation
|
explicit |
Creates new new search rule.
- Parameters
-
field The field to search in. function The function to use for searching. contents The contents to search for.
Definition at line 113 of file searchpattern.cpp.
SearchRule::SearchRule | ( | const SearchRule & | other | ) |
Creates a new search rule from an other
rule.
Definition at line 120 of file searchpattern.cpp.
|
virtual |
Destroys the search rule.
Definition at line 201 of file searchpattern.cpp.
Member Function Documentation
|
protected |
Adds term
to termGroup
and adds a negation term inbetween if needed.
Definition at line 633 of file searchpattern.cpp.
|
pure virtual |
Adds query terms to the given term group.
Implemented in MailCommon::SearchRuleStatus, MailCommon::SearchRuleDate, MailCommon::SearchRuleNumerical, and MailCommon::SearchRuleString.
const QString SearchRule::asString | ( | ) | const |
Returns the rule as string for debugging purpose.
Definition at line 565 of file searchpattern.cpp.
QString SearchRule::contents | ( | ) | const |
Returns the contents of the rule.
Definition at line 560 of file searchpattern.cpp.
|
static |
Creates a new search rule of a certain type by instantiating the appropriate subclass depending on the field
.
- Parameters
-
field The field to search in. function The function to use for searching. contents The contents to search for.
Definition at line 140 of file searchpattern.cpp.
|
static |
Creates a new search rule of a certain type by instantiating the appropriate subclass depending on the field
.
- Parameters
-
field The field to search in. function The name of the function to use for searching. contents The contents to search for.
Definition at line 158 of file searchpattern.cpp.
|
static |
Creates a new search rule by cloning an other
rule.
Definition at line 165 of file searchpattern.cpp.
|
static |
Creates a new search rule by deseralizing its structure from a data stream
.
Definition at line 189 of file searchpattern.cpp.
|
static |
Creates a new search rule from a given config group
.
- Parameters
-
group The config group to read the structure from. index The identifier that is used to distinguish rules within a single config group.
- Note
- This function does no validation of the data obtained from the config file. You should call isEmpty yourself if you need valid rules.
Definition at line 170 of file searchpattern.cpp.
QByteArray SearchRule::field | ( | ) | const |
Returns the message header field name (without the trailing ':').
There are also six pseudo-headers:
- <message>: Try to match against the whole message.
- <body>: Try to match against the body of the message.
- <any header>: Try to match against any header field.
- <recipients>: Try to match against both To: and Cc: header fields.
- <size>: Try to match against size of message (numerical).
- <age in days>: Try to match against age of message (numerical).
- <status>: Try to match against status of message (status).
- <tag>: Try to match against message tags.
Definition at line 550 of file searchpattern.cpp.
SearchRule::Function SearchRule::function | ( | ) | const |
Returns the filter function of the rule.
Definition at line 540 of file searchpattern.cpp.
void SearchRule::generateSieveScript | ( | QStringList & | requires, |
QString & | code | ||
) |
Definition at line 312 of file searchpattern.cpp.
|
pure virtual |
Determines whether the rule is worth considering.
It isn't if either the field is not set or the contents is empty. The calling code should make sure that it's rule list contains only non-empty rules, as matches doesn't check this.
Implemented in MailCommon::SearchRuleStatus, MailCommon::SearchRuleDate, MailCommon::SearchRuleNumerical, and MailCommon::SearchRuleString.
|
protected |
Helper that returns whether the rule has a negated function.
Definition at line 614 of file searchpattern.cpp.
|
pure virtual |
Tries to match the rule against the KMime::Message in the given item
.
- Returns
- true if the rule matched, false otherwise.
- Note
- Must be implemented by subclasses.
Implemented in MailCommon::SearchRuleStatus, MailCommon::SearchRuleDate, MailCommon::SearchRuleNumerical, and MailCommon::SearchRuleString.
|
protected |
Converts the rule function into the corresponding Nepomuk query operator.
Definition at line 575 of file searchpattern.cpp.
const SearchRule & SearchRule::operator= | ( | const SearchRule & | other | ) |
Initializes this rule with an other
rule.
Definition at line 127 of file searchpattern.cpp.
QDataStream & SearchRule::operator>> | ( | QDataStream & | s | ) | const |
Definition at line 645 of file searchpattern.cpp.
|
protected |
Definition at line 800 of file searchpattern.cpp.
|
pure virtual |
Returns the required part from the item that is needed for the search to operate.
See RequiredPart
Implemented in MailCommon::SearchRuleStatus, MailCommon::SearchRuleDate, MailCommon::SearchRuleNumerical, and MailCommon::SearchRuleString.
void SearchRule::setContents | ( | const QString & | contents | ) |
Set the contents
of the rule.
This can be either a substring to search for in or a regexp pattern to match against the header.
Definition at line 555 of file searchpattern.cpp.
void SearchRule::setField | ( | const QByteArray & | name | ) |
Sets the message header field name
.
- Note
- Make sure the name contains no trailing ':'.
Definition at line 545 of file searchpattern.cpp.
void SearchRule::setFunction | ( | Function | function | ) |
Sets the filter function
of the rule.
Definition at line 535 of file searchpattern.cpp.
void SearchRule::writeConfig | ( | KConfigGroup & | group, |
int | index | ||
) | const |
Saves the object into a given config group
.
- Parameters
-
index The identifier that is used to distinguish rules within a single config group.
- Note
- This function will happily write itself even when it's not valid, assuming higher layers to Do The Right Thing(TM).
Definition at line 229 of file searchpattern.cpp.
The documentation for this class was generated from the following files:
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.