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

Commit

Permalink
[libcontacts] Do not emit change notifications during initial contact…
Browse files Browse the repository at this point in the history
… insert

When a contact is first loaded into the cache, no listener can yet be
interested in changes to that contact.
  • Loading branch information
matthewvogt committed Dec 9, 2013
1 parent a73f147 commit a6fef0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/seasidecache.cpp
Expand Up @@ -1712,7 +1712,7 @@ void SeasideCache::updateContacts(const QList<ContactIdType> &contactIds)
}
}

void SeasideCache::updateCache(CacheItem *item, const QContact &contact, bool partialFetch)
void SeasideCache::updateCache(CacheItem *item, const QContact &contact, bool partialFetch, bool initialInsert)
{
if (item->contactState < ContactRequested) {
item->contactState = partialFetch ? ContactPartial : ContactComplete;
Expand All @@ -1732,7 +1732,9 @@ void SeasideCache::updateCache(CacheItem *item, const QContact &contact, bool pa
item->displayLabel = generateDisplayLabel(item->contact, m_displayLabelOrder);
item->nameGroup = determineNameGroup(item);

reportItemUpdated(item);
if (!initialInsert) {
reportItemUpdated(item);
}
}

void SeasideCache::reportItemUpdated(CacheItem *item)
Expand Down Expand Up @@ -2049,7 +2051,7 @@ void SeasideCache::applyContactUpdates(const QList<QContact> &contacts, bool par

roleDataChanged |= updateContactIndexing(item->contact, contact, iid, queryDetailTypes, item);

updateCache(item, contact, partialFetch);
updateCache(item, contact, partialFetch, false);
roleDataChanged |= (item->displayLabel != oldDisplayLabel);

// do this even if !roleDataChanged as name groups are affected by other display label changes
Expand Down Expand Up @@ -2223,7 +2225,7 @@ void SeasideCache::appendContacts(const QList<QContact> &contacts, FilterType fi
}

updateContactIndexing(item->contact, contact, iid, queryDetailTypes, item);
updateCache(item, contact, partialFetch);
updateCache(item, contact, partialFetch, true);

if (filterType == FilterAll) {
addToContactNameGroup(iid, nameGroup(item), &modifiedGroups);
Expand Down
2 changes: 1 addition & 1 deletion src/seasidecache.h
Expand Up @@ -400,7 +400,7 @@ private slots:

void resolveUnknownAddresses(const QString &first, const QString &second, CacheItem *item);
bool updateContactIndexing(const QContact &oldContact, const QContact &contact, quint32 iid, const QSet<DetailTypeId> &queryDetailTypes, CacheItem *item);
void updateCache(CacheItem *item, const QContact &contact, bool partialFetch);
void updateCache(CacheItem *item, const QContact &contact, bool partialFetch, bool initialInsert);
void reportItemUpdated(CacheItem *item);

void removeRange(FilterType filter, int index, int count);
Expand Down

0 comments on commit a6fef0b

Please sign in to comment.