Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[libcontacts] Force models to reload data upon receiving dataChanged.…
… Contributes to JB#44742

The qtcontacts-sqlite backend will emit dataChanged() when the
group property changes and it updates its internal data structures
accordingly.

This commit ensures that when this signal is received by libcontacts,
it will force all models to update all source data, to ensure that
the group labels are updated appropriately.
  • Loading branch information
Chris Adams committed Apr 17, 2019
1 parent 4284c8e commit 50d794c2ac488ec1f6d79ade67a3c39c2d3d8a35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
@@ -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,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:

0 comments on commit 50d794c

Please sign in to comment.