Commit 43f2cde6 authored by Martin Koller's avatar Martin Koller

delay filtering to the point when a new item gets its remote id

Differential Revision: https://phabricator.kde.org/D5667
parent 0c869ccc
......@@ -121,6 +121,11 @@ MailFilterAgent::MailFilterAgent(const QString &id)
mProgressCounter = 0;
mProgressTimer = new QTimer(this);
connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(emitProgress()));
itemMonitor = new Akonadi::Monitor(this);
itemMonitor->itemFetchScope().setFetchRemoteIdentification(true);
itemMonitor->itemFetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
connect(itemMonitor, &Akonadi::Monitor::itemChanged, this, &MailFilterAgent::slotItemChanged);
}
MailFilterAgent::~MailFilterAgent()
......@@ -189,6 +194,26 @@ void MailFilterAgent::itemAdded(const Akonadi::Item &item, const Akonadi::Collec
return;
}
if (item.remoteId().isEmpty()) {
itemMonitor->setItemMonitored(item);
} else {
filterItem(item, collection);
}
}
void MailFilterAgent::slotItemChanged(const Akonadi::Item &item)
{
if (item.remoteId().isEmpty()) {
return;
}
// now we have the remoteId
itemMonitor->setItemMonitored(item, false);
filterItem(item, item.parentCollection());
}
void MailFilterAgent::filterItem(const Akonadi::Item &item, const Akonadi::Collection &collection)
{
MailCommon::SearchRule::RequiredPart requiredPart = m_filterManager->requiredPart(collection.resource());
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item);
......
......@@ -33,6 +33,11 @@ class FilterManager;
class KJob;
class DummyKernel;
namespace Akonadi
{
class Monitor;
}
class MailFilterAgent : public Akonadi::AgentBase, public Akonadi::AgentBase::ObserverV3
{
Q_OBJECT
......@@ -70,6 +75,8 @@ private Q_SLOTS:
void itemsReceiviedForFiltering(const Akonadi::Item::List &items);
void clearMessage();
void slotInstanceRemoved(const Akonadi::AgentInstance &instance);
void slotItemChanged(const Akonadi::Item &item);
public Q_SLOTS:
void configure(WId windowId) Q_DECL_OVERRIDE;
......@@ -80,6 +87,9 @@ private:
QTimer *mProgressTimer;
DummyKernel *mMailFilterKernel;
int mProgressCounter;
Akonadi::Monitor *itemMonitor;
void filterItem(const Akonadi::Item &item, const Akonadi::Collection &collection);
};
#endif
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