[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim/KDE/4.14] libkdepim/addressline: Allow to disable some addressbook
From:       Montel Laurent <montel () kde ! org>
Date:       2015-02-18 20:51:23
Message-ID: E1YOBad-0006bo-7v () scm ! kde ! org
[Download RAW message or body]

Git commit 7a0e37f71e68588cf23f7400eb8d80d1985454db by Montel Laurent.
Committed on 18/02/2015 at 20:26.
Pushed by mlaurent into branch 'KDE/4.14'.

Allow to disable some addressbook

M  +31   -13   libkdepim/addressline/addresseelineedit_p.cpp

http://commits.kde.org/kdepim/7a0e37f71e68588cf23f7400eb8d80d1985454db

diff --git a/libkdepim/addressline/addresseelineedit_p.cpp \
b/libkdepim/addressline/addresseelineedit_p.cpp index bb1b2ee..9be4867 100644
--- a/libkdepim/addressline/addresseelineedit_p.cpp
+++ b/libkdepim/addressline/addresseelineedit_p.cpp
@@ -120,7 +120,18 @@ public:
     // does not hold when clients are added later on
     QMap<int, int> ldapClientToCompletionSourceMap;
     // holds the cached mapping from akonadi collection id to the completion source \
                index
-    QMap<Akonadi::Collection::Id, int> akonadiCollectionToCompletionSourceMap;
+    struct collectionInfo {
+        collectionInfo()
+            : index(-1),
+              enabled(true)
+        {
+
+        }
+        int index;
+        bool enabled;
+    };
+
+    QMap<Akonadi::Collection::Id, collectionInfo> \
                akonadiCollectionToCompletionSourceMap;
     // a list of akonadi items (contacts) that have not had their collection fetched \
yet  Akonadi::Item::List akonadiPendingItems;
     Akonadi::Session *akonadiSession;
@@ -630,11 +641,13 @@ void AddresseeLineEdit::Private::akonadiHandlePending()
     while ( it != s_static->akonadiPendingItems.end() ) {
         const Akonadi::Item item = *it;
 
-        const int sourceIndex =
-                s_static->akonadiCollectionToCompletionSourceMap.value( \
                item.parentCollection().id(), -1 );
-        if ( sourceIndex >= 0 ) {
-            kDebug() << "identified collection: " << \
                s_static->completionSources[sourceIndex];
-            q->addItem( item, 1, sourceIndex );
+        const AddresseeLineEditStatic::collectionInfo sourceIndex =
+                s_static->akonadiCollectionToCompletionSourceMap.value( \
item.parentCollection().id(), AddresseeLineEditStatic::collectionInfo() ); +        \
if ( sourceIndex.index >= 0 ) { +            kDebug() << "identified collection: " << \
s_static->completionSources[sourceIndex.index]; +            if (sourceIndex.enabled) \
{ +                q->addItem( item, 1, sourceIndex.index );
+            }
 
             // remove from the pending
             it = s_static->akonadiPendingItems.erase( it );
@@ -883,9 +896,9 @@ void AddresseeLineEdit::Private::slotAkonadiHandleItems( const \
Akonadi::Item::Li  foreach ( const Akonadi::Item &item, items ) {
 
         // check the local cache of collections
-        const int sourceIndex =
-                s_static->akonadiCollectionToCompletionSourceMap.value( \
                item.parentCollection().id(), -1 );
-        if ( sourceIndex == -1 ) {
+        const AddresseeLineEditStatic::collectionInfo sourceIndex =
+                s_static->akonadiCollectionToCompletionSourceMap.value( \
item.parentCollection().id(), AddresseeLineEditStatic::collectionInfo() ); +        \
                if ( sourceIndex.index == -1 ) {
             kDebug() << "Fetching New collection: " << item.parentCollection().id();
             // the collection isn't there, start the fetch job.
             Akonadi::CollectionFetchJob *collectionJob =
@@ -896,14 +909,17 @@ void AddresseeLineEdit::Private::slotAkonadiHandleItems( const \
                Akonadi::Item::Li
                      q, \
                SLOT(slotAkonadiCollectionsReceived(Akonadi::Collection::List)) );
             /* we don't want to start multiple fetch jobs for the same collection,
            so insert the collection with an index value of -2 */
-            s_static->akonadiCollectionToCompletionSourceMap.insert( \
item.parentCollection().id(), -2 ); +            \
AddresseeLineEditStatic::collectionInfo info; +            info.index = -2;
+            s_static->akonadiCollectionToCompletionSourceMap.insert( \
item.parentCollection().id(), info );  s_static->akonadiPendingItems.append( item );
-        } else if ( sourceIndex == -2 ) {
+        } else if ( sourceIndex.index == -2 ) {
             /* fetch job already started, don't need to start another one,
            so just append the item as pending */
             s_static->akonadiPendingItems.append( item );
         } else {
-            q->addItem( item, 1, sourceIndex );
+            if (sourceIndex.enabled)
+                q->addItem( item, 1, sourceIndex.index );
         }
     }
 
@@ -938,8 +954,10 @@ void AddresseeLineEdit::Private::slotAkonadiCollectionsReceived(
             const QString sourceString = collection.displayName();
             const int weight = group.readEntry( QString::number(collection.id()), 1 \
                );
             const int index = q->addCompletionSource( sourceString, weight );
+            AddresseeLineEditStatic::collectionInfo info;
+            info.index = index;
             kDebug() << "\treceived: " << sourceString << "index: " << index;
-            s_static->akonadiCollectionToCompletionSourceMap.insert( \
collection.id(), index ); +            \
s_static->akonadiCollectionToCompletionSourceMap.insert( collection.id(), info );  }
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic