Akonadi::ContactSearchJob Class
Job that searches for contacts in the Akonadi storage. More...
| Header: | #include <Akonadi/ContactSearchJob> |
| CMake: | find_package(KPim6AkonadiContactCore REQUIRED)target_link_libraries(mytarget PRIVATE KPim6::AkonadiContactCore) |
Public Types
| enum | Criterion { Name, Email, NickName, NameOrEmail, ContactUid } |
| enum | Match { ExactMatch, StartsWithMatch, ContainsMatch, ContainsWordBoundaryMatch } |
Public Functions
| ContactSearchJob(QObject *parent = nullptr) | |
| virtual | ~ContactSearchJob() override |
| KContacts::Addressee::List | contacts() const |
| void | setLimit(int limit) |
| void | setQuery(Akonadi::ContactSearchJob::Criterion criterion, const QString &value, Akonadi::ContactSearchJob::Match match = ExactMatch) |
Detailed Description
This job searches for contacts that match given search criteria and returns the list of contacts.
Examples:
// Search all contacts with email address tokoe@kde.org
Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
job->setQuery( Akonadi::ContactSearchJob::Email, "tokoe@kde.org" );
connect( job, SIGNAL(result(KJob*)), this, SLOT(searchResult(KJob*)) );
...
MyClass::searchResult( KJob *job )
{
Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob*>( job );
const KContacts::Addressee::List contacts = searchJob->contacts();
// do something with the contacts
}
// Search for all existing contacts
Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
connect( job, SIGNAL(result(KJob*)), this, SLOT(searchResult(KJob*)) );
...
MyClass::searchResult( KJob *job )
{
Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob*>( job );
const KContacts::Addressee::List contacts = searchJob->contacts();
// do something with the contacts
}
Author: Tobias Koenig <tokoe@kde.org>
Member Type Documentation
enum ContactSearchJob::Criterion
Describes the criteria that can be searched for.
enum ContactSearchJob::Match
Describes the type of pattern matching that shall be used.
Member Function Documentation
[explicit] ContactSearchJob::ContactSearchJob(QObject *parent = nullptr)
Creates a new contact search job.
parent The parent object.
[override virtual noexcept] ContactSearchJob::~ContactSearchJob()
Destroys the contact search job.
KContacts::Addressee::List ContactSearchJob::contacts() const
Returns the contacts that matched the search criteria.
void ContactSearchJob::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. This needs to be called before calling setQuery() to have an effect. By default, the number of results is unlimited. limit the upper limit for number of search results
void ContactSearchJob::setQuery(Akonadi::ContactSearchJob::Criterion criterion, const QString &value, Akonadi::ContactSearchJob::Match match = ExactMatch)
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