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

List:       kde-commits
Subject:    branches/KDE/4.4/kdepim/runtime/resources/birthdays
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2010-11-30 22:41:39
Message-ID: 20101130224139.D36B7AC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202450 by tmcguire:

Backport r1202449 by krake from trunk to the 4.4 branch:

Use hashes for storing pending items instead of lists to avoid double entries.
Having the same item twice in the added/modified list will cause the resource's transaction to fail.


 M  +4 -4      birthdaysresource.cpp  
 M  +4 -2      birthdaysresource.h  


--- branches/KDE/4.4/kdepim/runtime/resources/birthdays/birthdaysresource.cpp #1202449:1202450
@@ -99,7 +99,7 @@
 void BirthdaysResource::retrieveItems(const Akonadi::Collection& collection)
 {
   Q_UNUSED( collection );
-  itemsRetrievedIncremental( mPendingItems, mDeletedItems );
+  itemsRetrievedIncremental( mPendingItems.values(), mDeletedItems.values() );
   mPendingItems.clear();
   mDeletedItems.clear();
 }
@@ -174,7 +174,7 @@
   Item i( "application/x-vnd.akonadi.calendar.event" );
   i.setRemoteId( remoteId );
   i.setPayload( evptr );
-  mPendingItems << i; // TODO check if we have that item already
+  mPendingItems[ remoteId ] = i;
   synchronize();
 }
 
@@ -183,9 +183,9 @@
 {
   Item i( "application/x-vnd.akonadi.calendar.event" );
   i.setRemoteId( QString::fromLatin1( "b%1" ).arg( item.id() ) );
-  mDeletedItems << i;
+  mDeletedItems[ i.remoteId() ] = i;
   i.setRemoteId( QString::fromLatin1( "a%1" ).arg( item.id() ) );
-  mDeletedItems << i;
+  mDeletedItems[ i.remoteId() ] = i;
   synchronize();
 }
 
--- branches/KDE/4.4/kdepim/runtime/resources/birthdays/birthdaysresource.h #1202449:1202450
@@ -27,6 +27,8 @@
 class Event;
 }
 
+#include <QHash>
+
 class QDate;
 
 class BirthdaysResource : public Akonadi::ResourceBase, public Akonadi::AgentBase::Observer
@@ -62,8 +64,8 @@
 
     void contactRetrieved( KJob *job );
   private:
-    Akonadi::Item::List mPendingItems;
-    Akonadi::Item::List mDeletedItems;
+    QHash<QString, Akonadi::Item> mPendingItems;
+    QHash<QString, Akonadi::Item> mDeletedItems;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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