summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index abfd944..221e977 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -833,57 +833,60 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co
return nonCustomMap;
}
/* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */
OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const
{
// We want to get all contacts with one query.
// We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h).
// All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned
// by using the cache..
QArray<int> cachelist = uidlist;
+ OPimContact retContact;
odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl;
QTime t;
t.start();
int t2needed = 0;
int t3needed = 0;
QTime t2;
t2.start();
FindQuery query( cachelist );
OSQLResult res_noncustom = m_driver->query( &query );
t2needed = t2.elapsed();
QMap<int, QString> nonCustomMap;
QTime t3;
t3.start();
OSQLResultItem resItem = res_noncustom.first();
do {
OPimContact contact( fillNonCustomMap( resItem ) );
contact.setExtraMap( requestCustom( contact.uid() ) );
odebug << "Caching uid: " << contact.uid() << oendl;
cache( contact );
+ if ( contact.uid() == uid )
+ retContact = contact;
resItem = res_noncustom.next();
} while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !!
t3needed = t3.elapsed();
// odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl;
odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed
<< " ms, mapping: " << t3needed << " ms" << oendl;
- return cacheFind( uid );
+ return retContact;
}
QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const
{
QMap<int, QString> nonCustomMap;
// Now loop through all columns
QStringList fieldList = OPimContactFields::untrfields( false );
QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
// Get data for the selected column and store it with the
// corresponding id into the map..