akonadi/contact
contactgroupsearchjob.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "contactgroupsearchjob.h"
00023
00024 #include <akonadi/itemfetchscope.h>
00025
00026 using namespace Akonadi;
00027
00028 ContactGroupSearchJob::ContactGroupSearchJob( QObject * parent )
00029 : ItemSearchJob( QString(), parent ), d( 0 )
00030 {
00031 fetchScope().fetchFullPayload();
00032
00033
00034 ItemSearchJob::setQuery( QLatin1String( ""
00035 "prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>"
00036 "SELECT ?r WHERE { ?r a nco:ContactGroup }" ) );
00037 }
00038
00039 ContactGroupSearchJob::~ContactGroupSearchJob()
00040 {
00041 }
00042
00043 void ContactGroupSearchJob::setQuery( Criterion criterion, const QString &value )
00044 {
00045 QString query;
00046
00047 if ( criterion == Name ) {
00048 query = QString::fromLatin1( ""
00049 "prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>"
00050 "SELECT ?group WHERE {"
00051 " ?group nco:contactGroupName \"%1\"^^<http://www.w3.org/2001/XMLSchema#string>."
00052 "}" );
00053 }
00054
00055 query = query.arg( value );
00056
00057 ItemSearchJob::setQuery( query );
00058 }
00059
00060 KABC::ContactGroup::List ContactGroupSearchJob::contactGroups() const
00061 {
00062 KABC::ContactGroup::List contactGroups;
00063
00064 foreach ( const Item &item, items() ) {
00065 if ( item.hasPayload<KABC::ContactGroup>() )
00066 contactGroups.append( item.payload<KABC::ContactGroup>() );
00067 }
00068
00069 return contactGroups;
00070 }
00071
00072 #include "contactgroupsearchjob.moc"