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 'jb44742-fixes' into 'master'
[libcontacts] Force models to reload data upon receiving dataChanged. Contributes to JB#44742

See merge request mer-core/libcontacts!10
  • Loading branch information
blam committed Apr 18, 2019
2 parents 4284c8e + 50d794c commit 3833cce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
41 changes: 17 additions & 24 deletions src/seasidecache.cpp
Expand Up @@ -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()) {
Expand All @@ -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>)),
Expand Down Expand Up @@ -2025,7 +2024,7 @@ void SeasideCache::contactsRemoved(const QList<QContactId> &ids)
requestUpdate();
}

void SeasideCache::updateContacts()
void SeasideCache::dataChanged()
{
QList<QContactId> contactIds;

Expand All @@ -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()
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/seasidecache.h
Expand Up @@ -345,15 +345,14 @@ 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);
void contactsRemoved(const QList<QContactId> &contactIds);
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:
Expand Down

0 comments on commit 3833cce

Please sign in to comment.