Mailcommon

searchrulenumerical.h
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "searchpattern.h"
10#include <Akonadi/Item>
11namespace 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{
21public:
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 [[nodiscard]] bool isEmpty() const override;
35
36 /**
37 * @copydoc SearchRule::matches()
38 */
39 [[nodiscard]] bool matches(const Akonadi::Item &item) const override;
40
41 /**
42 * @copydoc SearchRule::requiredPart()
43 */
44 [[nodiscard]] RequiredPart requiredPart() const override;
45
46 // Optimized matching not implemented, will use the unoptimized matching
47 // from SearchRule
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 [[nodiscard]] QString informationAboutNotValidRules() const override;
61};
62}
This class represents a search pattern rule operating on numerical values.
bool matches(const Akonadi::Item &item) const override
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 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.
bool matchesInternal(long numericalValue, long numericalContents, const QString &contents) const
A helper method for the main matches() method.
This class represents one search pattern rule.
Definition searchrule.h:24
QByteArray field() const
Returns the message header field name (without the trailing ':').
Function function() const
Returns the filter function of the rule.
QString contents() const
Returns the contents of the rule.
Function
Describes operators for comparison of field and contents.
Definition searchrule.h:40
RequiredPart
Possible required parts.
Definition searchrule.h:68
virtual bool matches(const Akonadi::Item &item) const =0
Tries to match the rule against the KMime::Message in the given item.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.