Mailcommon

searchrulenumerical.h
1 /*
2  SPDX-FileCopyrightText: 2015-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "searchpattern.h"
10 #include <Akonadi/Item>
11 namespace MailCommon
12 {
13 /**
14  * @short This class represents a search pattern rule operating on numerical values.
15  *
16  * This class represents a search to be performed against a numerical value,
17  * such as the age of the message in days or its size.
18  */
20 {
21 public:
22  /**
23  * Creates new numerical search rule.
24  *
25  * @param field The field to search in.
26  * @param function The function to use for searching.
27  * @param contents The contents to search for.
28  */
29  explicit SearchRuleNumerical(const QByteArray &field = QByteArray(), Function function = FuncContains, const QString &contents = QString());
30 
31  /**
32  * @copydoc SearchRule::isEmpty()
33  */
34  Q_REQUIRED_RESULT bool isEmpty() const override;
35 
36  /**
37  * @copydoc SearchRule::matches()
38  */
39  Q_REQUIRED_RESULT bool matches(const Akonadi::Item &item) const override;
40 
41  /**
42  * @copydoc SearchRule::requiredPart()
43  */
44  Q_REQUIRED_RESULT RequiredPart requiredPart() const override;
45 
46  // Optimized matching not implemented, will use the unoptimized matching
47  // from SearchRule
48  using SearchRule::matches;
49 
50  /**
51  * A helper method for the main matches() method.
52  * Does the actual comparing.
53  */
54  bool matchesInternal(long numericalValue, long numericalContents, const QString &contents) const;
55 
56  /**
57  * @copydoc SearchRule::addQueryTerms()
58  */
59  void addQueryTerms(Akonadi::SearchTerm &groupTerm, bool &emptyIsNotAnError) const override;
60  Q_REQUIRED_RESULT QString informationAboutNotValidRules() const override;
61 };
62 }
QString contents() const
Returns the contents of the rule.
Definition: searchrule.cpp:508
This class represents a search pattern rule operating on numerical values.
virtual bool matches(const Akonadi::Item &item) const =0
Tries to match the rule against the KMime::Message in the given item.
void addQueryTerms(Akonadi::SearchTerm &groupTerm, bool &emptyIsNotAnError) const override
Adds query terms to the given term group.
RequiredPart requiredPart() const override
Returns the required part from the item that is needed for the search to operate.
bool matchesInternal(long numericalValue, long numericalContents, const QString &contents) const
A helper method for the main matches() method.
bool matches(const Akonadi::Item &item) const override
Tries to match the rule against the KMime::Message in the given item.
RequiredPart
Possible required parts.
Definition: searchrule.h:68
This class represents one search pattern rule.
Definition: searchrule.h:23
Function
Describes operators for comparison of field and contents.
Definition: searchrule.h:40
bool isEmpty() const override
Determines whether the rule is worth considering.
SearchRuleNumerical(const QByteArray &field=QByteArray(), Function function=FuncContains, const QString &contents=QString())
Creates new numerical search rule.
QByteArray field() const
Returns the message header field name (without the trailing ':').
Definition: searchrule.cpp:498
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 04:00:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.