Commit 40acdbc3 authored by Tobias Koenig's avatar Tobias Koenig

Converted Akonadi::Job to KJob and fixed email search query

svn path=/trunk/KDE/kdepim/akonadi/contact/; revision=1010958
parent 03f8cead
......@@ -36,15 +36,15 @@ class ContactSearchJob::Private
void searchResult( KJob *job )
{
ItemSearchJob *searchJob = qobject_cast<ItemSearchJob*>( job );
const Item::List items = searchJob->items();
mSearchResults = items.count();
mItems = searchJob->items();
mSearchResults = mItems.count();
if ( mSearchResults == 0 ) {
mParent->slotResult( mParent );
mParent->emitResult();
return;
}
foreach ( const Item &item, items ) {
foreach ( const Item &item, mItems ) {
ItemFetchJob *job = new ItemFetchJob( item );
job->fetchScope().fetchFullPayload();
......@@ -64,18 +64,19 @@ class ContactSearchJob::Private
mSearchResults--;
if ( mSearchResults == 0 )
mParent->slotResult( mParent );
mParent->emitResult();
}
ContactSearchJob *mParent;
ContactSearchJob::Criterion mCriterion;
QString mValue;
KABC::Addressee::List mContacts;
Item::List mItems;
int mSearchResults;
};
ContactSearchJob::ContactSearchJob( QObject * parent )
: Job( parent ), d( new Private( this ) )
: KJob( parent ), d( new Private( this ) )
{
}
......@@ -89,7 +90,7 @@ void ContactSearchJob::setQuery( Criterion criterion, const QString &value )
d->mValue = value;
}
void ContactSearchJob::doStart()
void ContactSearchJob::start()
{
QString query;
......@@ -101,7 +102,7 @@ void ContactSearchJob::doStart()
"}" );
} else if ( d->mCriterion == Email ) {
query = QString::fromLatin1( ""
"prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco>"
"prefix nco:<http://www.semanticdesktop.org/ontologies/2007/03/22/nco#>"
"SELECT ?person WHERE {"
" ?person nco:hasEmailAddress ?email ."
" ?email nco:emailAddress \"%1\"^^<http://www.w3.org/2001/XMLSchema#string> ."
......@@ -120,4 +121,9 @@ KABC::Addressee::List ContactSearchJob::contacts() const
return d->mContacts;
}
Item::List ContactSearchJob::items() const
{
return d->mItems;
}
#include "contactsearchjob.moc"
......@@ -22,8 +22,9 @@
#include "akonadi-contact_export.h"
#include <akonadi/job.h>
#include <akonadi/item.h>
#include <kabc/addressee.h>
#include <kjob.h>
namespace Akonadi {
......@@ -52,7 +53,7 @@ namespace Akonadi {
*
* @author Tobias Koenig <tokoe@kde.org>
*/
class AKONADI_CONTACT_EXPORT ContactSearchJob : public Job
class AKONADI_CONTACT_EXPORT ContactSearchJob : public KJob
{
Q_OBJECT
......@@ -85,13 +86,20 @@ class AKONADI_CONTACT_EXPORT ContactSearchJob : public Job
/**
* Returns the contacts that matched the search criteria.
*/
KABC::Addressee::List contacts() const;
/**
* Returns the items that matched the search criteria.
*
* @note The items only contain the uid but no payload.
*/
KABC::Addressee::List contacts() const;
Item::List items() const;
protected:
void doStart();
/**
* Starts the search job.
*/
virtual void start();
private:
//@cond PRIVATE
......
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