Akonadi Contacts

contactgroupsearchjob.cpp
1/*
2 This file is part of Akonadi Contact.
3
4 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "contactgroupsearchjob.h"
10
11#include <Akonadi/ItemFetchScope>
12#include <Akonadi/SearchQuery>
13#include <QStringList>
14
15using namespace Akonadi;
16
17class Akonadi::ContactGroupSearchJobPrivate
18{
19public:
20 int mLimit = -1;
21};
22
24 : ItemSearchJob(parent)
25 , d(new ContactGroupSearchJobPrivate)
26{
28 d->mLimit = -1;
29
31
32 // by default search for all contact groups
34 query.addTerm(ContactSearchTerm(ContactSearchTerm::All, QVariant(), SearchTerm::CondEqual));
36}
37
39
41{
42 // Exact match was the default in 4.4, so we have to keep it and ContactSearchJob has something
43 // else as default
44 setQuery(criterion, value, ExactMatch);
45}
46
47static Akonadi::SearchTerm::Condition matchType(ContactGroupSearchJob::Match match)
48{
49 switch (match) {
51 return Akonadi::SearchTerm::CondEqual;
54 return Akonadi::SearchTerm::CondContains;
55 }
56 return Akonadi::SearchTerm::CondEqual;
57}
58
59void ContactGroupSearchJob::setQuery(Criterion criterion, const QString &value, Match match)
60{
62 if (criterion == Name) {
63 query.addTerm(ContactSearchTerm(ContactSearchTerm::Name, value, matchType(match)));
64 }
65
66 query.setLimit(d->mLimit);
67
69}
70
72{
73 d->mLimit = limit;
74}
75
77{
79 const Akonadi::Item::List lstItems = items();
80 for (const Item &item : lstItems) {
81 if (item.hasPayload<KContacts::ContactGroup>()) {
83 }
84 }
85
86 return contactGroups;
87}
88
89#include "moc_contactgroupsearchjob.cpp"
void setLimit(int limit)
Sets a limit on how many results will be returned by this search job.
Match
Describes the type of pattern matching that shall be used.
@ ExactMatch
The result must match exactly the pattern (case sensitive).
@ ContainsMatch
The result must contain the pattern (case insensitive).
@ StartsWithMatch
The result must start with the pattern (case insensitive).
~ContactGroupSearchJob() override
Destroys the contact group search job.
void setQuery(Criterion criterion, const QString &value)
Sets the criterion and value for the search.
KContacts::ContactGroup::List contactGroups() const
Returns the contact groups that matched the search criteria.
Criterion
Describes the criteria that can be searched for.
@ Name
The name of the contact group.
ContactGroupSearchJob(QObject *parent=nullptr)
Creates a new contact group search job.
void fetchFullPayload(bool fetch=true)
void setQuery(const SearchQuery &query)
ItemFetchScope & fetchScope()
void setMimeTypes(const QStringList &mimeTypes)
Item::List items() const
static QString mimeType()
A widget for editing the display name of a contact.
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:20 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.