From kde-commits Tue Nov 30 22:41:39 2010 From: Thomas McGuire Date: Tue, 30 Nov 2010 22:41:39 +0000 To: kde-commits Subject: branches/KDE/4.4/kdepim/runtime/resources/birthdays Message-Id: <20101130224139.D36B7AC8A3 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129115694702486 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 + 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 mPendingItems; + QHash mDeletedItems; }; #endif