diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 10:21:15 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 10:36:36 +0200 |
commit | f1e496f7c12ebc787ed47a4c048015f2098e65d9 (patch) | |
tree | ab903283757f4a19b4957992316a1eed4276091f /common/standardqueries.h | |
parent | c9a99b4f544adb3ae7eef8f07e0b52b714d919b1 (diff) | |
download | sink-f1e496f7c12ebc787ed47a4c048015f2098e65d9.tar.gz sink-f1e496f7c12ebc787ed47a4c048015f2098e65d9.zip |
Moved standard quries to a separate header.
Diffstat (limited to 'common/standardqueries.h')
-rw-r--r-- | common/standardqueries.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/common/standardqueries.h b/common/standardqueries.h new file mode 100644 index 0000000..06ce396 --- /dev/null +++ b/common/standardqueries.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | #pragma once | ||
21 | |||
22 | #include "query.h" | ||
23 | |||
24 | namespace Sink { | ||
25 | namespace StandardQueries { | ||
26 | |||
27 | /** | ||
28 | * Returns the complete thread, containing all mails from all folders. | ||
29 | */ | ||
30 | static Query completeThread(const ApplicationDomain::Mail &mail) | ||
31 | { | ||
32 | Sink::Query query; | ||
33 | if (!mail.resourceInstanceIdentifier().isEmpty()) { | ||
34 | query.resourceFilter(mail.resourceInstanceIdentifier()); | ||
35 | } | ||
36 | query.filter(mail.identifier()); | ||
37 | query.sort<ApplicationDomain::Mail::Date>(); | ||
38 | query.bloom<ApplicationDomain::Mail::ThreadId>(); | ||
39 | return query; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Returns thread leaders only, sorted by date. | ||
44 | */ | ||
45 | static Query threadLeaders(const ApplicationDomain::Folder &folder) | ||
46 | { | ||
47 | Sink::Query query; | ||
48 | if (!folder.resourceInstanceIdentifier().isEmpty()) { | ||
49 | query.resourceFilter(folder.resourceInstanceIdentifier()); | ||
50 | } | ||
51 | query.filter<ApplicationDomain::Mail::Folder>(folder); | ||
52 | query.sort<ApplicationDomain::Mail::Date>(); | ||
53 | query.reduce<ApplicationDomain::Mail::ThreadId>(Query::Reduce::Selector::max<ApplicationDomain::Mail::Date>()); | ||
54 | return query; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * Outgoing mails. | ||
59 | */ | ||
60 | static Query outboxMails() | ||
61 | { | ||
62 | Sink::Query query; | ||
63 | query.resourceContainsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); | ||
64 | query.sort<ApplicationDomain::Mail::Date>(); | ||
65 | return query; | ||
66 | } | ||
67 | |||
68 | } | ||
69 | } | ||