Commit 1343a9df authored by Tobias Koenig's avatar Tobias Koenig

Add support to search for all contacts or contact groups of the system

svn path=/trunk/KDE/kdepimlibs/; revision=1048707
parent 4022a3e2
......@@ -26,6 +26,12 @@ using namespace Akonadi;
ContactGroupSearchJob::ContactGroupSearchJob( QObject * parent )
: ItemSearchJob( QString(), parent ), d( 0 )
{
fetchScope().fetchFullPayload();
// by default search for all contact groups
ItemSearchJob::setQuery( QLatin1String( ""
"prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>"
"SELECT ?r WHERE { ?r a nco:ContactGroup }" ) );
}
ContactGroupSearchJob::~ContactGroupSearchJob()
......
......@@ -26,6 +26,12 @@ using namespace Akonadi;
ContactSearchJob::ContactSearchJob( QObject * parent )
: ItemSearchJob( QString(), parent ), d( 0 )
{
fetchScope().fetchFullPayload();
// by default search for all contacts
ItemSearchJob::setQuery( QLatin1String( ""
"prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>"
"SELECT ?r WHERE { ?r a nco:PersonContact }" ) );
}
ContactSearchJob::~ContactSearchJob()
......
......@@ -36,8 +36,11 @@ namespace Akonadi {
* This job searches for contacts that match given search criteria and returns
* the list of contacts.
*
* Examples:
*
* @code
*
* // 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* ) ) );
......@@ -53,6 +56,23 @@ namespace Akonadi {
*
* @endcode
*
* @code
*
* // 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 KABC::Addressee::List contacts = searchJob->contacts();
* // do something with the contacts
* }
*
* @endcode
*
* @author Tobias Koenig <tokoe@kde.org>
* @since 4.4
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment