Commit 3833cce3 authored by blam's avatar blam

Merge branch 'jb44742-fixes' into 'master'

[libcontacts] Force models to reload data upon receiving dataChanged. Contributes to JB#44742

See merge request mer-core/libcontacts!10
parents 4284c8ef 50d794c2
......@@ -564,7 +564,6 @@ SeasideCache::SeasideCache()
connect(config, SIGNAL(displayLabelOrderChanged(CacheConfiguration::DisplayLabelOrder)),
this, SLOT(displayLabelOrderChanged(CacheConfiguration::DisplayLabelOrder)));
connect(config, SIGNAL(sortPropertyChanged(QString)), this, SLOT(sortPropertyChanged(QString)));
connect(config, SIGNAL(groupPropertyChanged(QString)), this, SLOT(groupPropertyChanged(QString)));
// Is this a GUI application? If so, we want to defer some processing when the display is off
if (qApp && qApp->property("applicationDisplayName").isValid()) {
......@@ -585,7 +584,7 @@ SeasideCache::SeasideCache()
this, SLOT(displayLabelGroupsChanged(QStringList)));
displayLabelGroupsChanged(cme->displayLabelGroups());
connect(mgr, SIGNAL(dataChanged()), this, SLOT(updateContacts()));
connect(mgr, SIGNAL(dataChanged()), this, SLOT(dataChanged()));
connect(mgr, SIGNAL(contactsAdded(QList<QContactId>)),
this, SLOT(contactsAdded(QList<QContactId>)));
connect(mgr, SIGNAL(contactsChanged(QList<QContactId>)),
......@@ -2025,7 +2024,7 @@ void SeasideCache::contactsRemoved(const QList<QContactId> &ids)
requestUpdate();
}
void SeasideCache::updateContacts()
void SeasideCache::dataChanged()
{
QList<QContactId> contactIds;
......@@ -2036,6 +2035,21 @@ void SeasideCache::updateContacts()
}
updateContacts(contactIds, &m_changedContacts);
// The backend will automatically update, but notify the models of the change.
for (int i = 0; i < FilterTypesCount; ++i) {
const QList<ListModel *> &models = m_models[i];
for (int j = 0; j < models.count(); ++j) {
ListModel *model = models.at(j);
model->updateGroupProperty();
model->sourceItemsChanged();
model->sourceDataChanged(0, m_contacts[i].size());
}
}
// Update the sorted list order
m_refreshRequired = true;
requestUpdate();
}
void SeasideCache::fetchContacts()
......@@ -2935,27 +2949,6 @@ void SeasideCache::sortPropertyChanged(const QString &sortProperty)
requestUpdate();
}
void SeasideCache::groupPropertyChanged(const QString &)
{
// It is unfortunate that this is required at all!
// Maybe handling for this could be added to dataChanged()
// instead? TODO: investigate that possibility.
// The backend will automatically update, but notify the models of the change.
for (int i = 0; i < FilterTypesCount; ++i) {
const QList<ListModel *> &models = m_models[i];
for (int j = 0; j < models.count(); ++j) {
ListModel *model = models.at(j);
model->updateGroupProperty();
model->sourceItemsChanged();
}
}
// Update the sorted list order
m_refreshRequired = true;
requestUpdate();
}
void SeasideCache::displayStatusChanged(const QString &status)
{
const bool off = (status == QLatin1String(MCE_DISPLAY_OFF_STRING));
......
......@@ -345,7 +345,7 @@ private slots:
void relationshipsAvailable();
void requestStateChanged(QContactAbstractRequest::State state);
void addressRequestStateChanged(QContactAbstractRequest::State state);
void updateContacts();
void dataChanged();
void contactsAdded(const QList<QContactId> &contactIds);
void contactsChanged(const QList<QContactId> &contactIds);
void contactsPresenceChanged(const QList<QContactId> &contactIds);
......@@ -353,7 +353,6 @@ private slots:
void displayLabelGroupsChanged(const QStringList &groups);
void displayLabelOrderChanged(CacheConfiguration::DisplayLabelOrder order);
void sortPropertyChanged(const QString &sortProperty);
void groupPropertyChanged(const QString &groupProperty);
void displayStatusChanged(const QString &);
private:
......
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