author | zecke <zecke> | 2004-09-12 23:48:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-12 23:48:59 (UTC) |
commit | df292cd5dbd8f3c11efa06db1a2ed565a6efa9b8 (patch) (unidiff) | |
tree | 749fce3927b9dad57bb4e836771860a8607963ba | |
parent | 03d8f31d45fa569d944ff635428ad9a946f077b9 (diff) | |
download | opie-df292cd5dbd8f3c11efa06db1a2ed565a6efa9b8.zip opie-df292cd5dbd8f3c11efa06db1a2ed565a6efa9b8.tar.gz opie-df292cd5dbd8f3c11efa06db1a2ed565a6efa9b8.tar.bz2 |
-Sorry for the whitespaces
-Delete endDate which is used by queryByExample
Eilers can you look if a QDate::isValid makes more sense?
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index 221e977..3d284f7 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -300,32 +300,32 @@ namespace { | |||
300 | FindQuery::~FindQuery() { | 300 | FindQuery::~FindQuery() { |
301 | } | 301 | } |
302 | QString FindQuery::query()const{ | 302 | QString FindQuery::query()const{ |
303 | if ( m_uids.count() == 0 ) | 303 | if ( m_uids.count() == 0 ) |
304 | return single(); | 304 | return single(); |
305 | else | 305 | else |
306 | return multi(); | 306 | return multi(); |
307 | } | 307 | } |
308 | 308 | ||
309 | QString FindQuery::multi()const { | 309 | QString FindQuery::multi()const { |
310 | QString qu = "select * from addressbook where"; | 310 | QString qu = "select * from addressbook where"; |
311 | for (uint i = 0; i < m_uids.count(); i++ ) { | 311 | for (uint i = 0; i < m_uids.count(); i++ ) { |
312 | qu += " uid = " + QString::number( m_uids[i] ) + " OR"; | 312 | qu += " uid = " + QString::number( m_uids[i] ) + " OR"; |
313 | } | 313 | } |
314 | qu.remove( qu.length()-2, 2 ); // Hmmmm.. | 314 | qu.remove( qu.length()-2, 2 ); // Hmmmm.. |
315 | 315 | ||
316 | odebug << "find query: " << qu << "" << oendl; | 316 | odebug << "find query: " << qu << "" << oendl; |
317 | return qu; | 317 | return qu; |
318 | } | 318 | } |
319 | 319 | ||
320 | QString FindQuery::single()const{ | 320 | QString FindQuery::single()const{ |
321 | QString qu = "select *"; | 321 | QString qu = "select *"; |
322 | qu += " from addressbook where uid = " + QString::number(m_uid); | 322 | qu += " from addressbook where uid = " + QString::number(m_uid); |
323 | 323 | ||
324 | // owarn << "find query: " << qu << "" << oendl; | 324 | // owarn << "find query: " << qu << "" << oendl; |
325 | return qu; | 325 | return qu; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | FindCustomQuery::FindCustomQuery(int uid) | 329 | FindCustomQuery::FindCustomQuery(int uid) |
330 | : OSQLQuery(), m_uid( uid ) { | 330 | : OSQLQuery(), m_uid( uid ) { |
331 | } | 331 | } |
@@ -487,20 +487,20 @@ OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const | |||
487 | 487 | ||
488 | OPimContact OPimContactAccessBackend_SQL::find( int uid, const QArray<int>& queryUids, uint current, Frontend::CacheDirection direction ) const | 488 | OPimContact OPimContactAccessBackend_SQL::find( int uid, const QArray<int>& queryUids, uint current, Frontend::CacheDirection direction ) const |
489 | { | 489 | { |
490 | odebug << "OPimContactAccessBackend_SQL::find( ..multi.. )" << oendl; | 490 | odebug << "OPimContactAccessBackend_SQL::find( ..multi.. )" << oendl; |
491 | odebug << "searching for " << uid << "" << oendl; | 491 | odebug << "searching for " << uid << "" << oendl; |
492 | 492 | ||
493 | QTime t; | 493 | QTime t; |
494 | t.start(); | 494 | t.start(); |
495 | 495 | ||
496 | uint numReadAhead = readAhead(); | 496 | uint numReadAhead = readAhead(); |
497 | QArray<int> searchList( numReadAhead ); | 497 | QArray<int> searchList( numReadAhead ); |
498 | 498 | ||
499 | uint size =0; | 499 | uint size =0; |
500 | 500 | ||
501 | // Build an array with all elements which should be requested and cached | 501 | // Build an array with all elements which should be requested and cached |
502 | // We will just request "numReadAhead" elements, starting from "current" position in | 502 | // We will just request "numReadAhead" elements, starting from "current" position in |
503 | // the list of many uids ! | 503 | // the list of many uids ! |
504 | switch( direction ) { | 504 | switch( direction ) { |
505 | /* forward */ | 505 | /* forward */ |
506 | case Frontend::Forward: | 506 | case Frontend::Forward: |
@@ -619,16 +619,18 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu | |||
619 | searchQuery += "(\"" + *it + "\"" + " LIKE " + "'" | 619 | searchQuery += "(\"" + *it + "\"" + " LIKE " + "'" |
620 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")"; | 620 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")"; |
621 | else | 621 | else |
622 | searchQuery += "(\"" + *it + "\"" + " GLOB " + "'" | 622 | searchQuery += "(\"" + *it + "\"" + " GLOB " + "'" |
623 | + queryStr + "'" + ")"; | 623 | + queryStr + "'" + ")"; |
624 | 624 | ||
625 | } | 625 | } |
626 | } | 626 | } |
627 | |||
628 | delete endDate; | ||
627 | } | 629 | } |
628 | // Skip trailing "AND" | 630 | // Skip trailing "AND" |
629 | // if ( isAnyFieldSelected ) | 631 | // if ( isAnyFieldSelected ) |
630 | // qu = qu.left( qu.length() - 4 ); | 632 | // qu = qu.left( qu.length() - 4 ); |
631 | 633 | ||
632 | qu += searchQuery; | 634 | qu += searchQuery; |
633 | 635 | ||
634 | odebug << "queryByExample query: " << qu << "" << oendl; | 636 | odebug << "queryByExample query: " << qu << "" << oendl; |
@@ -820,32 +822,32 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
820 | 822 | ||
821 | OSQLResultItem resItem = res_noncustom.first(); | 823 | OSQLResultItem resItem = res_noncustom.first(); |
822 | 824 | ||
823 | QMap<int, QString> nonCustomMap; | 825 | QMap<int, QString> nonCustomMap; |
824 | QTime t3; | 826 | QTime t3; |
825 | t3.start(); | 827 | t3.start(); |
826 | nonCustomMap = fillNonCustomMap( resItem ); | 828 | nonCustomMap = fillNonCustomMap( resItem ); |
827 | t3needed = t3.elapsed(); | 829 | t3needed = t3.elapsed(); |
828 | 830 | ||
829 | 831 | ||
830 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; | 832 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; |
831 | odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed | 833 | odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed |
832 | << " ms, mapping: " << t3needed << " ms" << oendl; | 834 | << " ms, mapping: " << t3needed << " ms" << oendl; |
833 | 835 | ||
834 | return nonCustomMap; | 836 | return nonCustomMap; |
835 | } | 837 | } |
836 | 838 | ||
837 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ | 839 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ |
838 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const | 840 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const |
839 | { | 841 | { |
840 | // We want to get all contacts with one query. | 842 | // We want to get all contacts with one query. |
841 | // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h). | 843 | // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h). |
842 | // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned | 844 | // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned |
843 | // by using the cache.. | 845 | // by using the cache.. |
844 | QArray<int> cachelist = uidlist; | 846 | QArray<int> cachelist = uidlist; |
845 | OPimContact retContact; | 847 | OPimContact retContact; |
846 | 848 | ||
847 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; | 849 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; |
848 | 850 | ||
849 | QTime t; | 851 | QTime t; |
850 | t.start(); | 852 | t.start(); |
851 | 853 | ||
@@ -866,22 +868,22 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons | |||
866 | contact.setExtraMap( requestCustom( contact.uid() ) ); | 868 | contact.setExtraMap( requestCustom( contact.uid() ) ); |
867 | odebug << "Caching uid: " << contact.uid() << oendl; | 869 | odebug << "Caching uid: " << contact.uid() << oendl; |
868 | cache( contact ); | 870 | cache( contact ); |
869 | if ( contact.uid() == uid ) | 871 | if ( contact.uid() == uid ) |
870 | retContact = contact; | 872 | retContact = contact; |
871 | resItem = res_noncustom.next(); | 873 | resItem = res_noncustom.next(); |
872 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! | 874 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! |
873 | t3needed = t3.elapsed(); | 875 | t3needed = t3.elapsed(); |
874 | 876 | ||
875 | 877 | ||
876 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; | 878 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; |
877 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed | 879 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed |
878 | << " ms, mapping: " << t3needed << " ms" << oendl; | 880 | << " ms, mapping: " << t3needed << " ms" << oendl; |
879 | 881 | ||
880 | return retContact; | 882 | return retContact; |
881 | } | 883 | } |
882 | 884 | ||
883 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const | 885 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const |
884 | { | 886 | { |
885 | QMap<int, QString> nonCustomMap; | 887 | QMap<int, QString> nonCustomMap; |
886 | 888 | ||
887 | // Now loop through all columns | 889 | // Now loop through all columns |