Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > cf746698214707f972e669b661d0ae59 > files > 63

kdepim4-4.14.10-1.3.mga5.src.rpm

From 17b2b0b769a30630321e0e112222e1b4ebb22dd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= <daniel.vratil@kdab.com>
Date: Mon, 23 May 2016 11:51:33 +0200
Subject: [PATCH 63/74] Only show warning about not fully indexed collections
 for offline IMAP accounts

Online IMAP collections (i.e. collections without RFC822 CachePolicy) cannot
be indexed by Baloo and as such will always be incomplete. Don't show warning
or option to reindex them in the UI then (because we can't index them, not
even forcefully.
---
 kmail/searchdialog/searchwindow.cpp                   | 19 +++++++++++++++----
 .../core/widgets/searchcollectionindexingwarning.cpp  |  3 ++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/kmail/searchdialog/searchwindow.cpp b/kmail/searchdialog/searchwindow.cpp
index e2b1af45ad..63baf4590c 100644
--- a/kmail/searchdialog/searchwindow.cpp
+++ b/kmail/searchdialog/searchwindow.cpp
@@ -39,6 +39,7 @@
 
 #include <Akonadi/CollectionModifyJob>
 #include <Akonadi/CollectionFetchJob>
+#include <Akonadi/CachePolicy>
 #include <Akonadi/EntityTreeView>
 #include <Akonadi/EntityHiddenAttribute>
 #include <akonadi/persistentsearchattribute.h>
@@ -893,7 +894,11 @@ QVector<qint64> SearchWindow::checkIncompleteIndex(const Akonadi::Collection::Li
         Q_FOREACH (const Akonadi::Collection &col, searchCols) {
             QAbstractItemModel *etm = KMKernel::self()->collectionModel();
             const QModelIndex idx = Akonadi::EntityTreeModel::modelIndexForCollection(etm, col);
-            cols.push_back(etm->data(idx, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>());
+            const Akonadi::Collection modelCol = etm->data(idx, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
+            // Only index offline IMAP collections
+            if (modelCol.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
+              cols.push_back(modelCol);
+            }
         }
     }
 
@@ -930,10 +935,13 @@ Akonadi::Collection::List SearchWindow::searchCollectionsRecursive(const Akonadi
     Q_FOREACH (const Akonadi::Collection &col, cols) {
         const QModelIndex colIdx = Akonadi::EntityTreeModel::modelIndexForCollection(etm, col);
         if (col.statistics().count() > -1) {
-            result.push_back(col);
+            if (col.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
+              result.push_back(col);
+            }
         } else {
             const Akonadi::Collection collection = etm->data(colIdx, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
-            if (!collection.hasAttribute<Akonadi::EntityHiddenAttribute>()) {
+            if (!collection.hasAttribute<Akonadi::EntityHiddenAttribute>()
+              && collection.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
                 result.push_back(collection);
             }
         }
@@ -944,7 +952,10 @@ Akonadi::Collection::List SearchWindow::searchCollectionsRecursive(const Akonadi
             subCols.reserve(childrenCount);
             for (int i = 0; i < childrenCount; ++i) {
                 const QModelIndex idx = etm->index(i, 0, colIdx);
-                subCols.push_back(etm->data(idx, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>());
+                const Akonadi::Collection child = etm->data(idx, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
+                if (child.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
+                  subCols.push_back(child);
+                }
             }
 
             result += searchCollectionsRecursive(subCols);
diff --git a/messagelist/core/widgets/searchcollectionindexingwarning.cpp b/messagelist/core/widgets/searchcollectionindexingwarning.cpp
index 8eaf581295..ec5156381f 100644
--- a/messagelist/core/widgets/searchcollectionindexingwarning.cpp
+++ b/messagelist/core/widgets/searchcollectionindexingwarning.cpp
@@ -24,6 +24,7 @@
 #include <akonadi/collectionfetchscope.h>
 #include <akonadi/collectionstatistics.h>
 #include <akonadi/entityhiddenattribute.h>
+#include <akonadi/cachepolicy.h>
 
 #include <pimcommon/util/indexerutils.h>
 
@@ -136,7 +137,7 @@ void SearchCollectionIndexingWarning::indexerStatsFetchFinished(KJob* job)
     bool allFullyIndexed = true;
     QMap<qint64, qint64> stats = qobject_cast<PimCommon::CollectionIndexStatusJob*>(job)->resultStats();
     Q_FOREACH (const Akonadi::Collection &col, mCollections) {
-        if (col.hasAttribute<Akonadi::EntityHiddenAttribute>()) {
+        if (col.hasAttribute<Akonadi::EntityHiddenAttribute>() || !col.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
             continue;
         }
         kDebug() << "Collection:" << col.displayName() << "(" << col.id() << "), count:" << col.statistics().count() << ", index:" << stats.value(col.id());
-- 
2.14.1