File indexing completed on 2024-12-22 04:52:51

0001 /*
0002     SPDX-FileCopyrightText: 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
0003     based on kdepimlibs/akonadi/tests/benchmarker.cpp wrote by Robert Zwerus <arzie@dds.nl>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "maildir20percentread.h"
0009 
0010 #include <QDebug>
0011 
0012 #include <Akonadi/CollectionFetchJob>
0013 #include <Akonadi/CollectionFetchScope>
0014 #include <Akonadi/ItemFetchJob>
0015 #include <Akonadi/ItemModifyJob>
0016 
0017 using namespace Akonadi;
0018 
0019 MailDir20PercentAsRead::MailDir20PercentAsRead()
0020     : MailDir()
0021 {
0022 }
0023 
0024 void MailDir20PercentAsRead::runTest()
0025 {
0026     timer.start();
0027     qDebug() << "  Marking 20% of messages as read.";
0028     auto clj2 = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive);
0029     clj2->fetchScope().setResource(currentInstance.identifier());
0030     clj2->exec();
0031     const Collection::List list2 = clj2->collections();
0032     for (const Collection &collection : list2) {
0033         auto ifj = new ItemFetchJob(collection, this);
0034         ifj->exec();
0035         Item::List itemlist = ifj->items();
0036         for (int i = ifj->items().count() - 1; i >= 0; i -= 5) {
0037             Item item = itemlist[i];
0038             item.setFlag("\\SEEN");
0039             auto isj = new ItemModifyJob(item, this);
0040             isj->exec();
0041         }
0042     }
0043     outputStats(QStringLiteral("mark20percentread"));
0044 }
0045 
0046 #include "moc_maildir20percentread.cpp"