7#include "filteractionjob_p.h"
9#include <Akonadi/Collection>
10#include <Akonadi/ItemFetchJob>
11#include <Akonadi/ItemFetchScope>
13#include "akonadi_mime_debug.h"
17class Akonadi::FilterActionJobPrivate
20 explicit FilterActionJobPrivate(FilterActionJob *qq)
25 ~FilterActionJobPrivate()
30 FilterActionJob *
const q;
33 FilterAction *functor =
nullptr;
37 void fetchResult(
KJob *job);
42void FilterActionJobPrivate::fetchResult(
KJob *job)
49 auto fjob = qobject_cast<ItemFetchJob *>(job);
52 items = fjob->items();
56void FilterActionJobPrivate::traverseItems()
59 qCDebug(AKONADIMIME_LOG) <<
"Traversing" << items.
count() <<
"items.";
60 for (
const Item &item : std::as_const(items)) {
61 if (functor->itemAccepted(item)) {
62 functor->itemAction(item, q);
63 qCDebug(AKONADIMIME_LOG) <<
"Added subjob for item" << item.id();
66 if (q->subjobs().isEmpty()) {
67 qCDebug(AKONADIMIME_LOG) <<
"No subjobs; I am done";
69 qCDebug(AKONADIMIME_LOG) <<
"Have subjobs; Done when last of them is";
74FilterAction::~FilterAction() =
default;
76FilterActionJob::FilterActionJob(
const Item &item, FilterAction *functor,
QObject *parent)
78 , d(new FilterActionJobPrivate(this))
84FilterActionJob::FilterActionJob(
const Item::List &items, FilterAction *functor,
QObject *parent)
86 , d(new FilterActionJobPrivate(this))
92FilterActionJob::FilterActionJob(
const Collection &collection, FilterAction *functor,
QObject *parent)
94 , d(new FilterActionJobPrivate(this))
98 d->collection = collection;
101FilterActionJob::~FilterActionJob() =
default;
103void FilterActionJob::doStart()
105 if (d->collection.isValid()) {
106 qCDebug(AKONADIMIME_LOG) <<
"Fetching collection" << d->collection.id();
108 Q_ASSERT(d->functor);
109 d->fetchScope = d->functor->fetchScope();
110 fjob->setFetchScope(d->fetchScope);
111 connect(fjob, &ItemFetchJob::result,
this, [
this](
KJob *job) {
119#include "moc_filteractionjob_p.cpp"
qsizetype count() const const
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)