author | zecke <zecke> | 2005-06-27 18:08:35 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-06-27 18:08:35 (UTC) |
commit | cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c (patch) (unidiff) | |
tree | f1507ae7e0ba8d3c41e0381b84827c97823edeca | |
parent | 058e3b6b0bc8f29314ee794bf7e993ebf3bfe072 (diff) | |
download | opie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.zip opie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.tar.gz opie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.tar.bz2 |
-Fix compile warning (signed vs unsigned)
-Somehow the split up patches missed the query string... (I knew I would mess up)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index 6aaa14c..f684f8c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -619,65 +619,65 @@ UIDArray OPimContactAccessBackend_SQL::queryByExample ( const UIDArray& uidlist, | |||
619 | .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) ); | 619 | .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) ); |
620 | } | 620 | } |
621 | 621 | ||
622 | if ( settings & OPimContactAccess::DateDay ){ | 622 | if ( settings & OPimContactAccess::DateDay ){ |
623 | if ( ( settings & OPimContactAccess::DateYear ) | 623 | if ( ( settings & OPimContactAccess::DateYear ) |
624 | || ( settings & OPimContactAccess::DateMonth ) ) | 624 | || ( settings & OPimContactAccess::DateMonth ) ) |
625 | searchQuery += " AND"; | 625 | searchQuery += " AND"; |
626 | 626 | ||
627 | searchQuery += QString( " (\"%1\" LIKE '%-%-%2')" ) | 627 | searchQuery += QString( " (\"%1\" LIKE '%-%-%2')" ) |
628 | .arg( *it ) | 628 | .arg( *it ) |
629 | .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) ); | 629 | .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) ); |
630 | } | 630 | } |
631 | 631 | ||
632 | break; | 632 | break; |
633 | default: | 633 | default: |
634 | // Switching between case sensitive and insensitive... | 634 | // Switching between case sensitive and insensitive... |
635 | // LIKE is not case sensitive, GLOB is case sensitive | 635 | // LIKE is not case sensitive, GLOB is case sensitive |
636 | // Do exist a better solution to switch this ? | 636 | // Do exist a better solution to switch this ? |
637 | if ( settings & OPimContactAccess::IgnoreCase ) | 637 | if ( settings & OPimContactAccess::IgnoreCase ) |
638 | searchQuery += " (\"" + *it + "\"" + " LIKE " + "'" | 638 | searchQuery += " (\"" + *it + "\"" + " LIKE " + "'" |
639 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")"; | 639 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")"; |
640 | else | 640 | else |
641 | searchQuery += " (\"" + *it + "\"" + " GLOB " + "'" | 641 | searchQuery += " (\"" + *it + "\"" + " GLOB " + "'" |
642 | + queryStr + "'" + ")"; | 642 | + queryStr + "'" + ")"; |
643 | 643 | ||
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | delete endDate; | 647 | delete endDate; |
648 | 648 | ||
649 | // The following if line is a replacement for | 649 | // The following if line is a replacement for |
650 | // if ( searchQuery.endsWith( "AND" ) ) | 650 | // if ( searchQuery.endsWith( "AND" ) ) |
651 | if ( searchQuery.findRev( "AND" ) == ( searchQuery.length() - 3 ) ){ | 651 | if ( searchQuery.findRev( "AND" ) == static_cast<int>( searchQuery.length() - 3 ) ){ |
652 | odebug << "remove AND" << oendl; | 652 | odebug << "remove AND" << oendl; |
653 | searchQuery.remove( searchQuery.length()-3, 3 ); // Hmmmm.. | 653 | searchQuery.remove( searchQuery.length()-3, 3 ); // Hmmmm.. |
654 | } | 654 | } |
655 | 655 | ||
656 | } | 656 | } |
657 | 657 | ||
658 | // Now compose the complete query | 658 | // Now compose the complete query |
659 | QString qu = "SELECT uid FROM addressbook WHERE " + uid_query; | 659 | QString qu = "SELECT uid FROM addressbook WHERE " + uid_query; |
660 | 660 | ||
661 | if ( !datediff_query.isEmpty() && !searchQuery.isEmpty() ){ | 661 | if ( !datediff_query.isEmpty() && !searchQuery.isEmpty() ){ |
662 | // If we use DateDiff, we have to intersect two queries. | 662 | // If we use DateDiff, we have to intersect two queries. |
663 | qu = datediff_query + QString( " INTERSECT " ) + qu + searchQuery; | 663 | qu = datediff_query + QString( " INTERSECT " ) + qu + searchQuery; |
664 | } else if ( datediff_query.isEmpty() && !searchQuery.isEmpty() ){ | 664 | } else if ( datediff_query.isEmpty() && !searchQuery.isEmpty() ){ |
665 | qu += searchQuery; | 665 | qu += searchQuery; |
666 | } else if ( !datediff_query.isEmpty() && searchQuery.isEmpty() ){ | 666 | } else if ( !datediff_query.isEmpty() && searchQuery.isEmpty() ){ |
667 | qu = datediff_query; | 667 | qu = datediff_query; |
668 | } else if ( datediff_query.isEmpty() && searchQuery.isEmpty() ){ | 668 | } else if ( datediff_query.isEmpty() && searchQuery.isEmpty() ){ |
669 | UIDArray empty; | 669 | UIDArray empty; |
670 | return empty; | 670 | return empty; |
671 | } | 671 | } |
672 | 672 | ||
673 | odebug << "queryByExample query: " << qu << "" << oendl; | 673 | odebug << "queryByExample query: " << qu << "" << oendl; |
674 | 674 | ||
675 | // Execute query and return the received uid's | 675 | // Execute query and return the received uid's |
676 | OSQLRawQuery raw( qu ); | 676 | OSQLRawQuery raw( qu ); |
677 | OSQLResult res = m_driver->query( &raw ); | 677 | OSQLResult res = m_driver->query( &raw ); |
678 | if ( res.state() != OSQLResult::Success ){ | 678 | if ( res.state() != OSQLResult::Success ){ |
679 | UIDArray empty; | 679 | UIDArray empty; |
680 | return empty; | 680 | return empty; |
681 | } | 681 | } |
682 | 682 | ||
683 | UIDArray list = extractUids( res ); | 683 | UIDArray list = extractUids( res ); |
@@ -844,64 +844,70 @@ UIDArray OPimContactAccessBackend_SQL::sorted( const UIDArray& ar, bool asc, int | |||
844 | query += " \"Name Title\""; | 844 | query += " \"Name Title\""; |
845 | break; | 845 | break; |
846 | case OPimContactAccess::SortFirstName: | 846 | case OPimContactAccess::SortFirstName: |
847 | query += " \"First Name\""; | 847 | query += " \"First Name\""; |
848 | break; | 848 | break; |
849 | case OPimContactAccess::SortMiddleName: | 849 | case OPimContactAccess::SortMiddleName: |
850 | query += " \"Middle Name\""; | 850 | query += " \"Middle Name\""; |
851 | break; | 851 | break; |
852 | case OPimContactAccess::SortLastName: | 852 | case OPimContactAccess::SortLastName: |
853 | query += " \"Last Name\""; | 853 | query += " \"Last Name\""; |
854 | break; | 854 | break; |
855 | case OPimContactAccess::SortFileAsName: | 855 | case OPimContactAccess::SortFileAsName: |
856 | query += " \"File As\""; | 856 | query += " \"File As\""; |
857 | break; | 857 | break; |
858 | case OPimContactAccess::SortSuffix: | 858 | case OPimContactAccess::SortSuffix: |
859 | query += " \"Suffix\""; | 859 | query += " \"Suffix\""; |
860 | break; | 860 | break; |
861 | case OPimContactAccess::SortEmail: | 861 | case OPimContactAccess::SortEmail: |
862 | query += " \"Default Email\""; | 862 | query += " \"Default Email\""; |
863 | break; | 863 | break; |
864 | case OPimContactAccess::SortNickname: | 864 | case OPimContactAccess::SortNickname: |
865 | query += " \"Nickname\""; | 865 | query += " \"Nickname\""; |
866 | break; | 866 | break; |
867 | case OPimContactAccess::SortAnniversary: | 867 | case OPimContactAccess::SortAnniversary: |
868 | query += " \"Anniversary\""; | 868 | query += " \"Anniversary\""; |
869 | break; | 869 | break; |
870 | case OPimContactAccess::SortBirthday: | 870 | case OPimContactAccess::SortBirthday: |
871 | query += " \"Birthday\""; | 871 | query += " \"Birthday\""; |
872 | break; | 872 | break; |
873 | case OPimContactAccess::SortGender: | 873 | case OPimContactAccess::SortGender: |
874 | query += " \"Gender\""; | 874 | query += " \"Gender\""; |
875 | break; | 875 | break; |
876 | case OPimContactAccess::SortBirthdayWithoutYear: | ||
877 | query += " substr(\"Birthday\", 6, 10)"; | ||
878 | break; | ||
879 | case OPimContactAccess::SortAnniversaryWithoutYear: | ||
880 | query += " substr(\"Anniversary\", 6, 10)"; | ||
881 | break; | ||
876 | default: | 882 | default: |
877 | query += " \"Last Name\""; | 883 | query += " \"Last Name\""; |
878 | } | 884 | } |
879 | 885 | ||
880 | if ( !asc ) | 886 | if ( !asc ) |
881 | query += " DESC"; | 887 | query += " DESC"; |
882 | 888 | ||
883 | 889 | ||
884 | odebug << "sorted query is: " << query << "" << oendl; | 890 | odebug << "sorted query is: " << query << "" << oendl; |
885 | 891 | ||
886 | OSQLRawQuery raw( query ); | 892 | OSQLRawQuery raw( query ); |
887 | OSQLResult res = m_driver->query( &raw ); | 893 | OSQLResult res = m_driver->query( &raw ); |
888 | if ( res.state() != OSQLResult::Success ){ | 894 | if ( res.state() != OSQLResult::Success ){ |
889 | UIDArray empty; | 895 | UIDArray empty; |
890 | return empty; | 896 | return empty; |
891 | } | 897 | } |
892 | 898 | ||
893 | UIDArray list = extractUids( res ); | 899 | UIDArray list = extractUids( res ); |
894 | 900 | ||
895 | odebug << "sorted needed " << t.elapsed() << " ms!" << oendl; | 901 | odebug << "sorted needed " << t.elapsed() << " ms!" << oendl; |
896 | return list; | 902 | return list; |
897 | } | 903 | } |
898 | 904 | ||
899 | 905 | ||
900 | void OPimContactAccessBackend_SQL::update() | 906 | void OPimContactAccessBackend_SQL::update() |
901 | { | 907 | { |
902 | odebug << "Update starts" << oendl; | 908 | odebug << "Update starts" << oendl; |
903 | QTime t; | 909 | QTime t; |
904 | t.start(); | 910 | t.start(); |
905 | 911 | ||
906 | // Now load the database set and extract the uid's | 912 | // Now load the database set and extract the uid's |
907 | // which will be held locally | 913 | // which will be held locally |