summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 3142f75..bb5c99b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -592,36 +592,61 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu
592 if ( res.state() != OSQLResult::Success ){ 592 if ( res.state() != OSQLResult::Success ){
593 QArray<int> empty; 593 QArray<int> empty;
594 return empty; 594 return empty;
595 } 595 }
596 596
597 QArray<int> list = extractUids( res ); 597 QArray<int> list = extractUids( res );
598 598
599 return list; 599 return list;
600} 600}
601 601
602QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 602QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
603{ 603{
604#if 1
604 QArray<int> nix(0); 605 QArray<int> nix(0);
605 return nix; 606 return nix;
607
608#else
609 QString qu = "SELECT uid FROM addressbook WHERE (";
610 QString searchlist;
611
612 QStringList fieldList = OPimContactFields::untrfields( false );
613 // QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
614 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
615 if ( !searchlist.isEmpty() )
616 searchlist += " OR ";
617 searchlist += "\"" + *it + "\" rlike(\"" + r.pattern() + "\") ";
618 }
619
620 qu = qu + searchlist + ")";
621
622 qDebug( "query: %s", qu.latin1() );
623
624 OSQLRawQuery raw( qu );
625 OSQLResult res = m_driver->query( &raw );
626
627 return extractUids( res );
628
629
630#endif
606} 631}
607 632
608const uint OPimContactAccessBackend_SQL::querySettings() 633const uint OPimContactAccessBackend_SQL::querySettings()
609{ 634{
610 return OPimContactAccess::IgnoreCase 635 return OPimContactAccess::IgnoreCase
611 || OPimContactAccess::WildCards 636 | OPimContactAccess::WildCards
612 || OPimContactAccess::DateDiff 637 | OPimContactAccess::DateDiff
613 || OPimContactAccess::DateYear 638 | OPimContactAccess::DateYear
614 || OPimContactAccess::DateMonth 639 | OPimContactAccess::DateMonth
615 || OPimContactAccess::DateDay 640 | OPimContactAccess::DateDay
616 ; 641 ;
617} 642}
618 643
619bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const 644bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
620{ 645{
621 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 646 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
622 * may be added with any of the other settings. IgnoreCase should never used alone. 647 * may be added with any of the other settings. IgnoreCase should never used alone.
623 * Wildcards, RegExp, ExactMatch should never used at the same time... 648 * Wildcards, RegExp, ExactMatch should never used at the same time...
624 */ 649 */
625 650
626 // Step 1: Check whether the given settings are supported by this backend 651 // Step 1: Check whether the given settings are supported by this backend
627 if ( ( querySettings & ( 652 if ( ( querySettings & (