# HG changeset patch # User John Kern # Date 1282858474 25200 # Node ID edc0144719a1e7a957a1156ec92dde36133332a6 # Parent 3ed811ba9e2e8617a41107b6f676764be49ecced removed invariant from data() and rowCount(). Performance should be ok now. diff -r 3ed811ba9e2e -r edc0144719a1 contactengine/contactsengine.cpp --- a/contactengine/contactsengine.cpp Thu Aug 26 10:26:51 2010 -0700 +++ b/contactengine/contactsengine.cpp Thu Aug 26 14:34:34 2010 -0700 @@ -121,6 +121,11 @@ m_manager = new QContactManager(); } + if(this->m_manager && (this->m_manager->error() == QContactManager::NoError )) + { + this->m_allContacts = this->m_manager->contacts(); + } + // Show message to the user QString msg = QString("Manager %1 created, that has %2 contacts") .arg(m_manager->managerName()).arg(contactIds.count()); @@ -352,7 +357,7 @@ int ContactsEngine::rowCount(const QModelIndex &parent) const { - return this->m_manager->contacts().count(); + return this->m_allContacts.count(); } void ContactsEngine::enumerateMgrs() @@ -394,17 +399,16 @@ QVariant ContactsEngine::data(const QModelIndex &index, int role) const { QVariant rc; - QList allContacts; QContact c; - allContacts = this->m_manager->contacts(); + - if (!index.isValid() || index.row() >= allContacts.size()) { + if (!index.isValid() || index.row() >= this->m_allContacts.size()) { return rc; } if (role == Qt::DisplayRole) { //rc = QVariant(allContacts.at(index.row()).displayLabel()); - c = allContacts.at(index.row()); + c = this->m_allContacts.at(index.row()); // organizations do not have first and last names. So the displayLabel() is empty. QContactDetail cd = c.detail(QContactName::DefinitionName); if (cd.isEmpty()) { @@ -414,4 +418,4 @@ } } return rc; - } +} diff -r 3ed811ba9e2e -r edc0144719a1 contactengine/contactsengine.h --- a/contactengine/contactsengine.h Thu Aug 26 10:26:51 2010 -0700 +++ b/contactengine/contactsengine.h Thu Aug 26 14:34:34 2010 -0700 @@ -46,6 +46,8 @@ QPointer m_manager; // this one is simply in memory. Put the Symbian Foundation contacts here. QPointer m_manager_sf; + // cache list of all contacts. + QList m_allContacts; }; #endif // CONTACTSENGINE_H