Use plain old Akonadi::CollectionFetchJob

wilder
Daniel Vrátil 6 years ago
parent 05a7f93b38
commit d299035927
No known key found for this signature in database
GPG Key ID: 4D69557AECB13683
  1. 21
      src/job/markallmessagesasreadinfolderandsubfolderjob.cpp
  2. 20
      src/job/removeduplicatemessageinfolderandsubfolderjob.cpp

@ -19,9 +19,11 @@
*/
#include "markallmessagesasreadinfolderandsubfolderjob.h"
#include <PimCommonAkonadi/FetchRecursiveCollectionsJob>
#include "kmail_debug.h"
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
MarkAllMessagesAsReadInFolderAndSubFolderJob::MarkAllMessagesAsReadInFolderAndSubFolderJob(QObject *parent)
: QObject(parent)
{
@ -39,11 +41,18 @@ void MarkAllMessagesAsReadInFolderAndSubFolderJob::setTopLevelCollection(const A
void MarkAllMessagesAsReadInFolderAndSubFolderJob::start()
{
if (mTopLevelCollection.isValid()) {
PimCommon::FetchRecursiveCollectionsJob *fetchJob = new PimCommon::FetchRecursiveCollectionsJob(this);
fetchJob->setTopCollection(mTopLevelCollection);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFailed, this, &MarkAllMessagesAsReadInFolderAndSubFolderJob::slotFetchCollectionFailed);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFinished, this, &MarkAllMessagesAsReadInFolderAndSubFolderJob::slotFetchCollectionDone);
fetchJob->start();
auto fetchJob = new Akonadi::CollectionFetchJob(mTopLevelCollection, Akonadi::CollectionFetchJob::Recursive, this);
fetchJob->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
connect(fetchJob, &Akonadi::CollectionFetchJob::finished,
this, [this](KJob *job) {
if (job->error()) {
qCWarning(KMAIL_LOG) << job->errorString();
slotFetchCollectionFailed();
} else {
auto fetch = static_cast<Akonadi::CollectionFetchJob*>(job);
slotFetchCollectionDone(fetch->collections());
}
});
} else {
qCDebug(KMAIL_LOG()) << "Invalid toplevel collection";
deleteLater();

@ -19,12 +19,13 @@
*/
#include "removeduplicatemessageinfolderandsubfolderjob.h"
#include <PimCommonAkonadi/FetchRecursiveCollectionsJob>
#include "kmail_debug.h"
#include <Akonadi/KMime/RemoveDuplicatesJob>
#include <Libkdepim/ProgressManager>
#include <KLocalizedString>
#include <KMessageBox>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
RemoveDuplicateMessageInFolderAndSubFolderJob::RemoveDuplicateMessageInFolderAndSubFolderJob(QObject *parent, QWidget *parentWidget)
: QObject(parent)
@ -39,11 +40,18 @@ RemoveDuplicateMessageInFolderAndSubFolderJob::~RemoveDuplicateMessageInFolderAn
void RemoveDuplicateMessageInFolderAndSubFolderJob::start()
{
if (mTopLevelCollection.isValid()) {
PimCommon::FetchRecursiveCollectionsJob *fetchJob = new PimCommon::FetchRecursiveCollectionsJob(this);
fetchJob->setTopCollection(mTopLevelCollection);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFailed, this, &RemoveDuplicateMessageInFolderAndSubFolderJob::slotFetchCollectionFailed);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFinished, this, &RemoveDuplicateMessageInFolderAndSubFolderJob::slotFetchCollectionDone);
fetchJob->start();
auto fetchJob = new Akonadi::CollectionFetchJob(mTopLevelCollection, Akonadi::CollectionFetchJob::Recursive, this);
fetchJob->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
connect(fetchJob, &Akonadi::CollectionFetchJob::result,
this, [this](KJob *job) {
if (job->error()) {
qCWarning(KMAIL_LOG) << job->errorString();
slotFetchCollectionFailed();
} else {
auto fetch = static_cast<Akonadi::CollectionFetchJob*>(job);
slotFetchCollectionDone(fetch->collections());
}
});
} else {
qCDebug(KMAIL_LOG()) << "Invalid toplevel collection";
deleteLater();

Loading…
Cancel
Save