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

List:       kde-commits
Subject:    KDE/kdepim/runtime/resources/birthdays
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2010-11-30 22:33:15
Message-ID: 20101130223315.766EDAC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202449 by krake:

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  


--- trunk/KDE/kdepim/runtime/resources/birthdays/birthdaysresource.cpp #1202448:1202449
@@ -97,7 +97,7 @@
 void BirthdaysResource::retrieveItems(const Akonadi::Collection& collection)
 {
   Q_UNUSED( collection );
-  itemsRetrievedIncremental( mPendingItems, mDeletedItems );
+  itemsRetrievedIncremental( mPendingItems.values(), mDeletedItems.values() );
   mPendingItems.clear();
   mDeletedItems.clear();
 }
@@ -172,7 +172,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();
 }
 
@@ -181,9 +181,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();
 }
 
--- trunk/KDE/kdepim/runtime/resources/birthdays/birthdaysresource.h #1202448:1202449
@@ -25,6 +25,8 @@
 
 #include <akonadi/resourcebase.h>
 
+#include <QHash>
+
 class QDate;
 
 class BirthdaysResource : public Akonadi::ResourceBase, public Akonadi::AgentBase::Observer
@@ -60,8 +62,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