Commit cdb951e6 authored by mvogt's avatar mvogt

[libcontacts] Only aggregate contacts should affect name groups

parent f93fb419
......@@ -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;
}
......@@ -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;
......@@ -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);
}
}
}
......@@ -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);
}
}
}
......@@ -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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment