File indexing completed on 2024-05-19 05:11:52
0001 /* 0002 * This file is part of the KDE Akonadi Search Project 0003 * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 * 0007 */ 0008 0009 #pragma once 0010 0011 #include "query.h" 0012 #include "search_pim_export.h" 0013 0014 #include <Akonadi/Collection> 0015 #include <QStringList> 0016 0017 #include <memory> 0018 0019 namespace Akonadi 0020 { 0021 namespace Search 0022 { 0023 namespace PIM 0024 { 0025 class EmailQueryPrivate; 0026 0027 /** Email query. */ 0028 class AKONADI_SEARCH_PIM_EXPORT EmailQuery : public Query 0029 { 0030 public: 0031 EmailQuery(); 0032 ~EmailQuery() override; 0033 0034 enum OpType { 0035 OpAnd = 0, 0036 OpOr, 0037 }; 0038 0039 void setSplitSearchMatchString(bool split); 0040 0041 void setSearchType(OpType op); 0042 0043 void setInvolves(const QStringList &involves); 0044 void addInvolves(const QString &email); 0045 0046 void setTo(const QStringList &to); 0047 void addTo(const QString &to); 0048 0049 void setFrom(const QString &from); 0050 void addFrom(const QString &from); 0051 0052 void setCc(const QStringList &cc); 0053 void addCc(const QString &cc); 0054 0055 void setBcc(const QStringList &bcc); 0056 void addBcc(const QString &bcc); 0057 0058 void setCollection(const QList<Akonadi::Collection::Id> &collections); 0059 void addCollection(Akonadi::Collection::Id id); 0060 0061 /** 0062 * By default the importance is ignored 0063 */ 0064 void setImportant(bool important = true); 0065 0066 /** 0067 * By default the read status is ignored 0068 */ 0069 void setRead(bool read = true); 0070 0071 /** 0072 * By default the attachment status is ignored 0073 */ 0074 void setAttachment(bool hasAttachment = true); 0075 0076 /** 0077 * Matches the string \p match anywhere in the entire email 0078 * body 0079 */ 0080 void matches(const QString &match); 0081 0082 /** 0083 * Matches the string \p subjectMatch specifically in the 0084 * email subject 0085 */ 0086 void subjectMatches(const QString &subjectMatch); 0087 0088 /** 0089 * Matches the string \p bodyMatch specifically in the body email 0090 */ 0091 void bodyMatches(const QString &bodyMatch); 0092 0093 void setLimit(int limit); 0094 [[nodiscard]] int limit() const; 0095 0096 /** 0097 * Execute the query and return an iterator to fetch 0098 * the results 0099 */ 0100 ResultIterator exec() override; 0101 0102 private: 0103 //@cond PRIVATE 0104 std::unique_ptr<EmailQueryPrivate> const d; 0105 //@endcond 0106 }; 0107 } 0108 } 0109 }