Commit d988df41 authored by chriadam's avatar chriadam

Merge branch 'jb46496' into 'master'

[libcontacts] Update section bucket index cache after deletions. Contributes to JB#46496

See merge request mer-core/libcontacts!14
parents 346cbb28 c7112dae
......@@ -1024,19 +1024,35 @@ void SeasideCache::contactDataChanged(quint32 iid, FilterType filter)
bool SeasideCache::removeContact(const QContact &contact)
{
QContactId id = apiId(contact);
if (!validId(id))
return false;
return removeContacts(QList<QContact>() << contact);
}
bool SeasideCache::removeContacts(const QList<QContact> &contacts)
{
bool allSucceeded = true;
QSet<QString> modifiedDisplayLabelGroups;
for (const QContact &contact : contacts) {
const QContactId id = apiId(contact);
if (!validId(id)) {
allSucceeded = false;
continue;
}
instancePtr->m_contactsToRemove.append(id);
instancePtr->m_contactsToRemove.append(id);
quint32 iid = internalId(id);
instancePtr->removeContactData(iid, FilterFavorites);
instancePtr->removeContactData(iid, FilterOnline);
instancePtr->removeContactData(iid, FilterAll);
quint32 iid = internalId(id);
instancePtr->removeContactData(iid, FilterFavorites);
instancePtr->removeContactData(iid, FilterOnline);
instancePtr->removeContactData(iid, FilterAll);
const QString group(displayLabelGroup(existingItem(iid)));
instancePtr->removeFromContactDisplayLabelGroup(iid, group, &modifiedDisplayLabelGroups);
}
instancePtr->notifyDisplayLabelGroupsChanged(modifiedDisplayLabelGroups);
instancePtr->updateSectionBucketIndexCaches();
instancePtr->requestUpdate();
return true;
return allSucceeded;
}
void SeasideCache::removeContactData(quint32 iid, FilterType filter)
......@@ -1051,13 +1067,6 @@ void SeasideCache::removeContactData(quint32 iid, FilterType filter)
m_contacts[filter].removeAt(row);
if (filter == FilterAll) {
const QString group(displayLabelGroup(existingItem(iid)));
QSet<QString> modifiedDisplayLabelGroups;
removeFromContactDisplayLabelGroup(iid, group, &modifiedDisplayLabelGroups);
notifyDisplayLabelGroupsChanged(modifiedDisplayLabelGroups);
}
for (int i = 0; i < models.count(); ++i)
models.at(i)->sourceItemsRemoved();
}
......@@ -1913,6 +1922,8 @@ bool SeasideCache::event(QEvent *event)
m_people.erase(cacheItem);
}
}
updateSectionBucketIndexCaches();
}
}
return true;
......
......@@ -308,6 +308,7 @@ public:
static bool saveContact(const QContact &contact);
static bool removeContact(const QContact &contact);
static bool removeContacts(const QList<QContact> &contacts);
static void aggregateContacts(const QContact &contact1, const QContact &contact2);
static void disaggregateContacts(const QContact &contact1, const QContact &contact2);
......
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