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
Merge branch 'jb45504' into 'master'
[libcontacts] Explicitly tell models to update section bucket index caches. Contributes to JB#45504

See merge request mer-core/libcontacts!11
  • Loading branch information
chriadam committed Apr 30, 2019
2 parents f90aceb + 689011e commit 62876e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/seasidecache.cpp
Expand Up @@ -999,6 +999,7 @@ bool SeasideCache::saveContact(const QContact &contact)
}

instancePtr->requestUpdate();
instancePtr->updateSectionBucketIndexCaches();

return true;
}
Expand Down Expand Up @@ -2034,6 +2035,7 @@ void SeasideCache::dataChanged()
model->updateGroupProperty();
model->sourceItemsChanged();
model->sourceDataChanged(0, m_contacts[i].size());
model->updateSectionBucketIndexCache();
}
}

Expand Down Expand Up @@ -2342,6 +2344,7 @@ void SeasideCache::contactsAvailable()
if (contacts.count() == 1 || request == &m_fetchByIdRequest) {
// Process these results immediately
applyContactUpdates(contacts, queryDetailTypes);
updateSectionBucketIndexCaches(); // note: can cause out-of-order since this doesn't result in refresh request. TODO: remove this line?
} else {
// Add these contacts to the list to be progressively appended
QList<QPair<QSet<QContactDetail::DetailType>, QList<QContact> > >::iterator it = m_contactsToUpdate.begin(), end = m_contactsToUpdate.end();
Expand Down Expand Up @@ -2406,6 +2409,7 @@ void SeasideCache::applyPendingContactUpdates()
makePopulated(FilterOnline);
qDebug() << "Online queried in" << m_timer.elapsed() << "ms";
}
updateSectionBucketIndexCaches();
}
} else {
QList<QPair<QSet<QContactDetail::DetailType>, QList<QContact> > >::iterator it = m_contactsToUpdate.begin();
Expand All @@ -2419,6 +2423,17 @@ void SeasideCache::applyPendingContactUpdates()

if (updatedContacts.isEmpty()) {
m_contactsToUpdate.erase(it);
updateSectionBucketIndexCaches();
}
}
}

void SeasideCache::updateSectionBucketIndexCaches()
{
for (int i = 0; i < FilterTypesCount; ++i) {
const QList<ListModel *> &models = m_models[i];
for (ListModel *model : models) {
model->updateSectionBucketIndexCache();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/seasidecache.h
Expand Up @@ -232,6 +232,8 @@ class CONTACTCACHE_EXPORT SeasideCache : public QObject
virtual void updateDisplayLabelOrder() = 0;
virtual void updateSortProperty() = 0;
virtual void updateGroupProperty() = 0;

virtual void updateSectionBucketIndexCache() = 0;
};

struct ResolveListener
Expand Down Expand Up @@ -377,6 +379,7 @@ private slots:
void updateContacts(const QList<QContactId> &contactIds, QList<QContactId> *updateList);
void applyPendingContactUpdates();
void applyContactUpdates(const QList<QContact> &contacts, const QSet<QContactDetail::DetailType> &queryDetailTypes);
void updateSectionBucketIndexCaches();

void resolveUnknownAddresses(const QString &first, const QString &second, CacheItem *item);
bool updateContactIndexing(const QContact &oldContact, const QContact &contact, quint32 iid, const QSet<QContactDetail::DetailType> &queryDetailTypes, CacheItem *item);
Expand Down

0 comments on commit 62876e5

Please sign in to comment.