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

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontacts] Only aggregate contacts should affect name groups
  • Loading branch information
matthewvogt committed Sep 2, 2013
1 parent f93fb41 commit cdb951e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/seasidecache.cpp
Expand Up @@ -264,9 +264,11 @@ QContactFilter onlineFilter()

QContactFilter aggregateFilter()
{
static const QString aggregate(QString::fromLatin1("aggregate"));

QContactDetailFilter filter;
setDetailType<QContactSyncTarget>(filter, QContactSyncTarget::FieldSyncTarget);
filter.setValue("aggregate");
filter.setValue(aggregate);

return filter;
}
Expand All @@ -288,6 +290,20 @@ StringPair addressPair(const QContactOnlineAccount &account)
return qMakePair(account.value<QString>(QContactOnlineAccount__FieldAccountPath), account.accountUri().toLower());
}

bool ignoreContactForNameGroups(const QContact &contact)
{
static const QString aggregate(QString::fromLatin1("aggregate"));

// Don't include the self contact in name groups
if (SeasideCache::apiId(contact) == SeasideCache::selfContactId()) {
return true;
}

// Also ignore non-aggregate contacts
QContactSyncTarget syncTarget = contact.detail<QContactSyncTarget>();
return (syncTarget.syncTarget() != aggregate);
}

}

SeasideCache *SeasideCache::instancePtr = 0;
Expand Down Expand Up @@ -1677,11 +1693,13 @@ void SeasideCache::contactsAvailable()

// do this even if !roleDataChanged as name groups are affected by other display label changes
if (item->nameGroup != oldNameGroup) {
if (!ignoreContactForNameGroups(item->contact)) {
addToContactNameGroup(item->iid, item->nameGroup, &modifiedGroups);
if (!oldNameGroup.isNull()) {
removeFromContactNameGroup(item->iid, oldNameGroup, &modifiedGroups);
}
}
}

if (roleDataChanged) {
instancePtr->contactDataChanged(apiId);
Expand Down Expand Up @@ -2134,6 +2152,7 @@ void SeasideCache::displayLabelOrderChanged()
// If the contact's name group is derived from display label, it may have changed
const QChar group(determineNameGroup(&*it));
if (group != it->nameGroup) {
if (!ignoreContactForNameGroups(it->contact)) {
if (!it->nameGroup.isNull()) {
removeFromContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
Expand All @@ -2142,6 +2161,7 @@ void SeasideCache::displayLabelOrderChanged()
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
}
}

notifyNameGroupsChanged(modifiedGroups);

Expand Down Expand Up @@ -2209,6 +2229,7 @@ void SeasideCache::groupPropertyChanged()
// Update the nameGroup for this contact
const QChar group(determineNameGroup(&*it));
if (group != it->nameGroup) {
if (!ignoreContactForNameGroups(it->contact)) {
if (!it->nameGroup.isNull()) {
removeFromContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
Expand All @@ -2217,6 +2238,7 @@ void SeasideCache::groupPropertyChanged()
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
}
}

notifyNameGroupsChanged(modifiedGroups);

Expand Down

0 comments on commit cdb951e

Please sign in to comment.