From f1e496f7c12ebc787ed47a4c048015f2098e65d9 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 6 Oct 2016 10:21:15 +0200 Subject: Moved standard quries to a separate header. --- common/CMakeLists.txt | 1 + common/query.h | 46 +------------------------------- common/standardqueries.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 common/standardqueries.h (limited to 'common') diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0fc8d81..84fe474 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -123,6 +123,7 @@ install(FILES resourcecontrol.h domain/applicationdomaintype.h query.h + standardqueries.h inspection.h notification.h bufferadaptor.h diff --git a/common/query.h b/common/query.h index 85307aa..00ae086 100644 --- a/common/query.h +++ b/common/query.h @@ -59,7 +59,6 @@ public: Comparators comparator; }; - template Query &request() { @@ -289,7 +288,7 @@ public: * a result set is generated containing all entries with the same value. * * Example: - * For an input result set of one mail; return all emails with the same threadId. + * For an input set of one mail; return all emails with the same threadId. */ class Bloom : public FilterStage { public: @@ -308,49 +307,6 @@ public: mFilterStages << bloom; } - //Query fixtures - - /** - * Returns the complete thread, containing all mails from all folders. - */ - static Query completeThread(const ApplicationDomain::Mail &mail) - { - Sink::Query query; - if (!mail.resourceInstanceIdentifier().isEmpty()) { - query.resourceFilter(mail.resourceInstanceIdentifier()); - } - query.filter(mail.identifier()); - query.sort(); - query.bloom(); - return query; - } - - /** - * Returns thread leaders only, sorted by date. - */ - static Query threadLeaders(const ApplicationDomain::Folder &folder) - { - Sink::Query query; - if (!folder.resourceInstanceIdentifier().isEmpty()) { - query.resourceFilter(folder.resourceInstanceIdentifier()); - } - query.filter(folder); - query.sort(); - query.reduce(Query::Reduce::Selector::max()); - return query; - } - - /** - * Outgoing mails. - */ - static Query outboxMails() - { - Sink::Query query; - query.resourceContainsFilter(ApplicationDomain::ResourceCapabilities::Mail::transport); - query.sort(); - return query; - } - private: Filter mResourceFilter; Filter mBaseFilterStage; 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 @@ +/* + * Copyright (C) 2016 Christian Mollekopf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ +#pragma once + +#include "query.h" + +namespace Sink { +namespace StandardQueries { + + /** + * Returns the complete thread, containing all mails from all folders. + */ + static Query completeThread(const ApplicationDomain::Mail &mail) + { + Sink::Query query; + if (!mail.resourceInstanceIdentifier().isEmpty()) { + query.resourceFilter(mail.resourceInstanceIdentifier()); + } + query.filter(mail.identifier()); + query.sort(); + query.bloom(); + return query; + } + + /** + * Returns thread leaders only, sorted by date. + */ + static Query threadLeaders(const ApplicationDomain::Folder &folder) + { + Sink::Query query; + if (!folder.resourceInstanceIdentifier().isEmpty()) { + query.resourceFilter(folder.resourceInstanceIdentifier()); + } + query.filter(folder); + query.sort(); + query.reduce(Query::Reduce::Selector::max()); + return query; + } + + /** + * Outgoing mails. + */ + static Query outboxMails() + { + Sink::Query query; + query.resourceContainsFilter(ApplicationDomain::ResourceCapabilities::Mail::transport); + query.sort(); + return query; + } + +} +} -- cgit v1.2.3