20 #include "filteractionjob_p.h"
22 #include <akonadi/collection.h>
23 #include <akonadi/itemfetchjob.h>
24 #include <akonadi/itemfetchscope.h>
28 using namespace Akonadi;
30 class Akonadi::FilterActionJob::Private
34 : q( qq ), functor( 0 )
44 Collection collection;
47 ItemFetchScope fetchScope;
50 void fetchResult( KJob *job );
55 void FilterActionJob::Private::fetchResult( KJob *job )
62 ItemFetchJob *fjob =
dynamic_cast<ItemFetchJob*
>( job );
64 Q_ASSERT( items.isEmpty() );
65 items = fjob->items();
69 void FilterActionJob::Private::traverseItems()
72 kDebug() <<
"Traversing" << items.count() <<
"items.";
73 foreach (
const Item &item, items ) {
74 if ( functor->itemAccepted( item ) ) {
75 functor->itemAction( item, q );
76 kDebug() <<
"Added subjob for item" << item.id();
79 if ( q->subjobs().isEmpty() ) {
80 kDebug() <<
"No subjobs; I am done";
82 kDebug() <<
"Have subjobs; Done when last of them is";
92 : TransactionSequence( parent ), d( new Private( this ) )
99 : TransactionSequence( parent ), d( new Private( this ) )
101 d->functor = functor;
107 : TransactionSequence( parent ), d( new Private( this ) )
109 d->functor = functor;
110 Q_ASSERT( collection.isValid() );
111 d->collection = collection;
119 void FilterActionJob::doStart()
121 if ( d->collection.isValid() ) {
122 kDebug() <<
"Fetching collection" << d->collection.id();
123 ItemFetchJob *fjob =
new ItemFetchJob( d->collection,
this );
124 Q_ASSERT( d->functor );
125 d->fetchScope = d->functor->fetchScope();
126 fjob->setFetchScope( d->fetchScope );
127 connect( fjob, SIGNAL(result(KJob*)),
this, SLOT(fetchResult(KJob*)) );
133 #include "moc_filteractionjob_p.cpp"
Job to filter and apply an action on a set of items.
FilterActionJob(const Item &item, FilterAction *functor, QObject *parent=0)
Creates a filter action job to act on a single item.
virtual ~FilterAction()
Destroys this filter action.
Base class for a filter/action for FilterActionJob.
~FilterActionJob()
Destroys the filter action job.