1 /* 2 SPDX-FileCopyrightText: 2015-2021 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> 11 namespace MailCommon 12 { 13 class SearchRuleDate : public SearchRule 14 { 15 public: 16 /** 17 * Creates new date search rule. 18 * 19 * @param field The field to search in. 20 * @param function The function to use for searching. 21 * @param contents The contents to search for. 22 */ 23 explicit SearchRuleDate(const QByteArray &field = QByteArray(), Function function = FuncContains, const QString &contents = QString()); 24 /** 25 * @copydoc SearchRule::isEmpty() 26 */ 27 bool isEmpty() const override; 28 29 /** 30 * @copydoc SearchRule::matches() 31 */ 32 bool matches(const Akonadi::Item &item) const override; 33 34 /** 35 * @copydoc SearchRule::requiredPart() 36 */ 37 RequiredPart requiredPart() const override; 38 39 // Optimized matching not implemented, will use the unoptimized matching 40 // from SearchRule 41 using SearchRule::matches; 42 43 /** 44 * A helper method for the main matches() method. 45 * Does the actual comparing. 46 */ 47 bool matchesInternal(QDate dateValue, QDate msgDate) const; 48 49 /** 50 * @copydoc SearchRule::addQueryTerms() 51 */ 52 void addQueryTerms(Akonadi::SearchTerm &groupTerm, bool &emptyIsNotAnError) const override; 53 QString informationAboutNotValidRules() const override; 54 }; 55 } 56 57