Commit 15b46be4 authored by mvogt's avatar mvogt

[libcontacts] Fetch extra details to faciliate search

When idle, fetch extra contact details used to populate the search model
data set.
parent f08f29e9
......@@ -232,6 +232,33 @@ QContactFetchHint favoriteFetchHint(quint32 fetchTypes = 0)
return fetchHint;
}
QContactFetchHint extendedMetadataFetchHint(quint32 fetchTypes)
{
QContactFetchHint fetchHint(basicFetchHint());
DetailList types;
// Only query for the specific types we need
if (fetchTypes & SeasideCache::FetchAccountUri) {
types << detailType<QContactOnlineAccount>();
}
if (fetchTypes & SeasideCache::FetchPhoneNumber) {
types << detailType<QContactPhoneNumber>();
}
if (fetchTypes & SeasideCache::FetchEmailAddress) {
types << detailType<QContactEmailAddress>();
}
if (fetchTypes & SeasideCache::FetchNickname) {
types << detailType<QContactNickname>();
}
if (fetchTypes & SeasideCache::FetchOrganization) {
types << detailType<QContactOrganization>();
}
setDetailTypesHint(fetchHint, types);
return fetchHint;
}
QContactFilter allFilter()
{
return QContactFilter();
......@@ -1703,6 +1730,45 @@ bool SeasideCache::event(QEvent *event)
}
if (!requestPending) {
// No remaining work is pending - do we have any background tasks?
if (m_keepPopulated) {
// Load extra data items that we want to be able to search on, if not already fetched
const quint32 fetchMask = (SeasideCache::FetchNickname |
SeasideCache::FetchOrganization |
SeasideCache::FetchPhoneNumber |
SeasideCache::FetchEmailAddress |
SeasideCache::FetchAccountUri);
if ((m_fetchTypes & fetchMask) != fetchMask) {
m_fetchRequest.setFilter(allFilter());
quint32 fetchType = 0;
if ((m_fetchTypes & SeasideCache::FetchNickname) == 0) {
fetchType = SeasideCache::FetchNickname;
} else if ((m_fetchTypes & SeasideCache::FetchOrganization) == 0) {
fetchType = SeasideCache::FetchOrganization;
} else if ((m_fetchTypes & SeasideCache::FetchPhoneNumber) == 0) {
fetchType = SeasideCache::FetchPhoneNumber;
m_fetchRequest.setFilter(QContactStatusFlags::matchFlag(QContactStatusFlags::HasPhoneNumber, QContactFilter::MatchContains));
} else if ((m_fetchTypes & SeasideCache::FetchEmailAddress) == 0) {
fetchType = SeasideCache::FetchEmailAddress;
m_fetchRequest.setFilter(QContactStatusFlags::matchFlag(QContactStatusFlags::HasEmailAddress, QContactFilter::MatchContains));
} else {
fetchType = SeasideCache::FetchAccountUri;
m_fetchRequest.setFilter(QContactStatusFlags::matchFlag(QContactStatusFlags::HasOnlineAccount, QContactFilter::MatchContains));
}
m_fetchRequest.setFetchHint(extendedMetadataFetchHint(fetchType));
m_fetchRequest.start();
m_fetchProcessedCount = 0;
m_fetchTypes |= fetchType;
return true;
}
}
m_updatesPending = false;
// Remove expired contacts when all other activity has been processed
......
......@@ -102,7 +102,9 @@ public:
FetchNone = 0,
FetchAccountUri = (1 << 0),
FetchPhoneNumber = (1 << 1),
FetchEmailAddress = (1 << 2)
FetchEmailAddress = (1 << 2),
FetchNickname = (1 << 3),
FetchOrganization = (1 << 4)
};
enum DisplayLabelOrder {
......
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