diff --git a/akonadi/contact/contactgroupsearchjob.cpp b/akonadi/contact/contactgroupsearchjob.cpp index c3ca6fbb5..e22472ef0 100644 --- a/akonadi/contact/contactgroupsearchjob.cpp +++ b/akonadi/contact/contactgroupsearchjob.cpp @@ -1,70 +1,72 @@ /* This file is part of Akonadi Contact. Copyright (c) 2009 Tobias Koenig This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "contactgroupsearchjob.h" +#include + 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:" "SELECT ?r WHERE { ?r a nco:ContactGroup }" ) ); } ContactGroupSearchJob::~ContactGroupSearchJob() { } void ContactGroupSearchJob::setQuery( Criterion criterion, const QString &value ) { QString query; if ( criterion == Name ) { query = QString::fromLatin1( "" "prefix nco:" "SELECT ?group WHERE {" " ?group nco:contactGroupName \"%1\"^^." "}" ); } query = query.arg( value ); ItemSearchJob::setQuery( query ); } KABC::ContactGroup::List ContactGroupSearchJob::contactGroups() const { KABC::ContactGroup::List contactGroups; foreach ( const Item &item, items() ) { if ( item.hasPayload() ) contactGroups.append( item.payload() ); } return contactGroups; } #include "contactgroupsearchjob.moc" diff --git a/akonadi/contact/contactsearchjob.cpp b/akonadi/contact/contactsearchjob.cpp index a377bf6b4..bd0919dc9 100644 --- a/akonadi/contact/contactsearchjob.cpp +++ b/akonadi/contact/contactsearchjob.cpp @@ -1,77 +1,79 @@ /* This file is part of Akonadi Contact. Copyright (c) 2009 Tobias Koenig This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "contactsearchjob.h" +#include + 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:" "SELECT ?r WHERE { ?r a nco:PersonContact }" ) ); } ContactSearchJob::~ContactSearchJob() { } void ContactSearchJob::setQuery( Criterion criterion, const QString &value ) { QString query; if ( criterion == Name ) { query = QString::fromLatin1( "" "prefix nco:" "SELECT ?r WHERE {" " ?r nco:fullname \"%1\"^^." "}" ); } else if ( criterion == Email ) { query = QString::fromLatin1( "" "prefix nco:" "SELECT ?person WHERE {" " ?person nco:hasEmailAddress ?email ." " ?email nco:emailAddress \"%1\"^^ ." " }" ); } query = query.arg( value ); ItemSearchJob::setQuery( query ); } KABC::Addressee::List ContactSearchJob::contacts() const { KABC::Addressee::List contacts; foreach ( const Item &item, items() ) { if ( item.hasPayload() ) contacts.append( item.payload() ); } return contacts; } #include "contactsearchjob.moc"