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

Commit

Permalink
[libcontacts] Only aggregate contacts should affect name groups
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Sep 2, 2013
1 parent f93fb41 commit cdb951e
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions 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,9 +1693,11 @@ void SeasideCache::contactsAvailable()

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

Expand Down Expand Up @@ -2134,12 +2152,14 @@ 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 (!it->nameGroup.isNull()) {
removeFromContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
if (!ignoreContactForNameGroups(it->contact)) {
if (!it->nameGroup.isNull()) {
removeFromContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}

it->nameGroup = group;
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
it->nameGroup = group;
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
}
}

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

it->nameGroup = group;
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
it->nameGroup = group;
addToContactNameGroup(it->iid, it->nameGroup, &modifiedGroups);
}
}
}

Expand Down

0 comments on commit cdb951e

Please sign in to comment.