Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 5 |
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 | |||
@@ -821,81 +821,84 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
821 | OSQLResultItem resItem = res_noncustom.first(); | 821 | OSQLResultItem resItem = res_noncustom.first(); |
822 | 822 | ||
823 | QMap<int, QString> nonCustomMap; | 823 | QMap<int, QString> nonCustomMap; |
824 | QTime t3; | 824 | QTime t3; |
825 | t3.start(); | 825 | t3.start(); |
826 | nonCustomMap = fillNonCustomMap( resItem ); | 826 | nonCustomMap = fillNonCustomMap( resItem ); |
827 | t3needed = t3.elapsed(); | 827 | t3needed = t3.elapsed(); |
828 | 828 | ||
829 | 829 | ||
830 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; | 830 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; |
831 | odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed | 831 | odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed |
832 | << " ms, mapping: " << t3needed << " ms" << oendl; | 832 | << " ms, mapping: " << t3needed << " ms" << oendl; |
833 | 833 | ||
834 | return nonCustomMap; | 834 | return nonCustomMap; |
835 | } | 835 | } |
836 | 836 | ||
837 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ | 837 | /* 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 | 838 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const |
839 | { | 839 | { |
840 | // We want to get all contacts with one query. | 840 | // 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). | 841 | // 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 | 842 | // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned |
843 | // by using the cache.. | 843 | // by using the cache.. |
844 | QArray<int> cachelist = uidlist; | 844 | QArray<int> cachelist = uidlist; |
845 | OPimContact retContact; | ||
845 | 846 | ||
846 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; | 847 | odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; |
847 | 848 | ||
848 | QTime t; | 849 | QTime t; |
849 | t.start(); | 850 | t.start(); |
850 | 851 | ||
851 | int t2needed = 0; | 852 | int t2needed = 0; |
852 | int t3needed = 0; | 853 | int t3needed = 0; |
853 | QTime t2; | 854 | QTime t2; |
854 | t2.start(); | 855 | t2.start(); |
855 | FindQuery query( cachelist ); | 856 | FindQuery query( cachelist ); |
856 | OSQLResult res_noncustom = m_driver->query( &query ); | 857 | OSQLResult res_noncustom = m_driver->query( &query ); |
857 | t2needed = t2.elapsed(); | 858 | t2needed = t2.elapsed(); |
858 | 859 | ||
859 | QMap<int, QString> nonCustomMap; | 860 | QMap<int, QString> nonCustomMap; |
860 | QTime t3; | 861 | QTime t3; |
861 | t3.start(); | 862 | t3.start(); |
862 | OSQLResultItem resItem = res_noncustom.first(); | 863 | OSQLResultItem resItem = res_noncustom.first(); |
863 | do { | 864 | do { |
864 | OPimContact contact( fillNonCustomMap( resItem ) ); | 865 | OPimContact contact( fillNonCustomMap( resItem ) ); |
865 | contact.setExtraMap( requestCustom( contact.uid() ) ); | 866 | contact.setExtraMap( requestCustom( contact.uid() ) ); |
866 | odebug << "Caching uid: " << contact.uid() << oendl; | 867 | odebug << "Caching uid: " << contact.uid() << oendl; |
867 | cache( contact ); | 868 | cache( contact ); |
869 | if ( contact.uid() == uid ) | ||
870 | retContact = contact; | ||
868 | resItem = res_noncustom.next(); | 871 | resItem = res_noncustom.next(); |
869 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! | 872 | } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! |
870 | t3needed = t3.elapsed(); | 873 | t3needed = t3.elapsed(); |
871 | 874 | ||
872 | 875 | ||
873 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; | 876 | // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; |
874 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed | 877 | odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed |
875 | << " ms, mapping: " << t3needed << " ms" << oendl; | 878 | << " ms, mapping: " << t3needed << " ms" << oendl; |
876 | 879 | ||
877 | return cacheFind( uid ); | 880 | return retContact; |
878 | } | 881 | } |
879 | 882 | ||
880 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const | 883 | QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const |
881 | { | 884 | { |
882 | QMap<int, QString> nonCustomMap; | 885 | QMap<int, QString> nonCustomMap; |
883 | 886 | ||
884 | // Now loop through all columns | 887 | // Now loop through all columns |
885 | QStringList fieldList = OPimContactFields::untrfields( false ); | 888 | QStringList fieldList = OPimContactFields::untrfields( false ); |
886 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); | 889 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
887 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 890 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
888 | // Get data for the selected column and store it with the | 891 | // Get data for the selected column and store it with the |
889 | // corresponding id into the map.. | 892 | // corresponding id into the map.. |
890 | 893 | ||
891 | int id = translate[*it]; | 894 | int id = translate[*it]; |
892 | QString value = resultItem.data( (*it) ); | 895 | QString value = resultItem.data( (*it) ); |
893 | 896 | ||
894 | // odebug << "Reading " << (*it) << "... found: " << value << "" << oendl; | 897 | // odebug << "Reading " << (*it) << "... found: " << value << "" << oendl; |
895 | 898 | ||
896 | switch( id ){ | 899 | switch( id ){ |
897 | case Qtopia::Birthday: | 900 | case Qtopia::Birthday: |
898 | case Qtopia::Anniversary:{ | 901 | case Qtopia::Anniversary:{ |
899 | // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) | 902 | // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) |
900 | QStringList list = QStringList::split( '-', value ); | 903 | QStringList list = QStringList::split( '-', value ); |
901 | QStringList::Iterator lit = list.begin(); | 904 | QStringList::Iterator lit = list.begin(); |