Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
[libcontacts] Fetch modified contacts after link/unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Oct 14, 2013
1 parent 8cce9b4 commit 7af8969
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/seasidecache.cpp
Expand Up @@ -2089,21 +2089,38 @@ void SeasideCache::requestStateChanged(QContactAbstractRequest::State state)
qWarning() << "ID fetch completed with no filter?";
}
} else if (request == &m_relationshipSaveRequest || request == &m_relationshipRemoveRequest) {
QSet<ContactIdType> contactIds;
foreach (const QContactRelationship &relationship, m_relationshipSaveRequest.relationships() +
m_relationshipRemoveRequest.relationships()) {
bool completed = false;
QList<QContactRelationship> relationships;
if (request == &m_relationshipSaveRequest) {
relationships = m_relationshipSaveRequest.relationships();
completed = !m_relationshipRemoveRequest.isActive();
} else {
relationships = m_relationshipRemoveRequest.relationships();
completed = !m_relationshipSaveRequest.isActive();
}

foreach (const QContactRelationship &relationship, relationships) {
#ifdef USING_QTPIM
contactIds.insert(SeasideCache::apiId(relationship.first()));
m_aggregatedContacts.insert(SeasideCache::apiId(relationship.first()));
#else
contactIds.insert(relationship.first().localId());
m_aggregatedContacts.insert(relationship.first().localId());
#endif
}

foreach (const ContactIdType &contactId, contactIds) {
if (completed) {
foreach (const ContactIdType &contactId, m_aggregatedContacts) {
CacheItem *cacheItem = itemById(contactId);
if (cacheItem && cacheItem->itemData)
cacheItem->itemData->aggregationOperationCompleted();
}

// We need to update these modified contacts immediately
foreach (const ContactIdType &id, m_aggregatedContacts)
m_changedContacts.append(id);
fetchContacts();

m_aggregatedContacts.clear();
}
} else if (request == &m_fetchRequest) {
if (m_populateProgress == Unpopulated && m_keepPopulated) {
// Start a query to fully populate the cache, starting with favorites
Expand Down
1 change: 1 addition & 0 deletions src/seasidecache.h
Expand Up @@ -433,6 +433,7 @@ private slots:
QList<QContact> m_contactsToCreate;
QList<ContactIdType> m_contactsToRemove;
QList<ContactIdType> m_changedContacts;
QSet<ContactIdType> m_aggregatedContacts;
QList<QContactId> m_contactsToFetchConstituents;
QList<QContactId> m_contactsToFetchCandidates;
QList<QContactId> m_contactsToLinkTo;
Expand Down

0 comments on commit 7af8969

Please sign in to comment.