Akonadi::ContactGroupSearchJob Class

Job that searches for contact groups in the Akonadi storage. More...

Header: #include <Akonadi/ContactGroupSearchJob>
CMake: find_package(KPim6AkonadiContactCore REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiContactCore)

Public Types

enum Criterion { Name }
enum Match { ExactMatch, StartsWithMatch, ContainsMatch }

Public Functions

ContactGroupSearchJob(QObject *parent = nullptr)
virtual ~ContactGroupSearchJob() override
KContacts::ContactGroup::List contactGroups() const
void setLimit(int limit)
void setQuery(Akonadi::ContactGroupSearchJob::Criterion criterion, const QString &value)
void setQuery(Akonadi::ContactGroupSearchJob::Criterion criterion, const QString &value, Akonadi::ContactGroupSearchJob::Match match)

Detailed Description

This job searches for contact groups that match given search criteria and returns the list of contact groups.

Akonadi::ContactGroupSearchJob *job = new Akonadi::ContactGroupSearchJob();
job->setQuery( Akonadi::ContactGroupSearchJob::Name, "Family Members" );
connect( job, SIGNAL(result(KJob*)), this, SLOT(searchResult(KJob*)) );

...

MyClass::searchResult( KJob *job )
{
  Akonadi::ContactGroupSearchJob *searchJob = qobject_cast<Akonadi::ContactGroupSearchJob*>( job );
  const KContacts::ContactGroup::List contactGroups = searchJob->contactGroups();
  // do something with the contact groups
}

Author: Tobias Koenig <tokoe@kde.org>

Member Type Documentation

enum ContactGroupSearchJob::Criterion

Describes the criteria that can be searched for.

enum ContactGroupSearchJob::Match

Describes the type of pattern matching that shall be used.

Member Function Documentation

[explicit] ContactGroupSearchJob::ContactGroupSearchJob(QObject *parent = nullptr)

Creates a new contact group search job.

parent The parent object.

[override virtual noexcept] ContactGroupSearchJob::~ContactGroupSearchJob()

Destroys the contact group search job.

KContacts::ContactGroup::List ContactGroupSearchJob::contactGroups() const

Returns the contact groups that matched the search criteria.

void ContactGroupSearchJob::setLimit(int limit)

Sets a limit on how many results will be returned by this search job. This is useful in situation where for example only the first search result is needed anyway, setting a limit of 1 here will greatly reduce the resource usage during the search. limit the limit to set

Note: this needs to be called before calling setQuery() to have an effect. By default, the number of results is unlimited.

void ContactGroupSearchJob::setQuery(Akonadi::ContactGroupSearchJob::Criterion criterion, const QString &value)

Sets the criterion and value for the search.

void ContactGroupSearchJob::setQuery(Akonadi::ContactGroupSearchJob::Criterion criterion, const QString &value, Akonadi::ContactGroupSearchJob::Match match)

Sets the criterion and value for the search with match. criterion the query criterion to compare with value the value to match against match how to match the given value