summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
authoreilers <eilers>2004-12-28 14:19:26 (UTC)
committer eilers <eilers>2004-12-28 14:19:26 (UTC)
commit47c87c92a46f56bc9190025e7a653fa48718431e (patch) (unidiff)
tree2c8d87f8a8132d6b59d56cdb35762a479515b1d1 /libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
parent521e3eed02205bca9baca9000ac7ff095a15abde (diff)
downloadopie-47c87c92a46f56bc9190025e7a653fa48718431e.zip
opie-47c87c92a46f56bc9190025e7a653fa48718431e.tar.gz
opie-47c87c92a46f56bc9190025e7a653fa48718431e.tar.bz2
Fixing bug #1501 and preparing for implementation of generic QueryByExample and
sorted for datebook and todo..
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 9375f43..2368865 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -279,7 +279,9 @@ namespace {
279 279
280 RemoveQuery::RemoveQuery(int uid ) 280 RemoveQuery::RemoveQuery(int uid )
281 : OSQLQuery(), m_uid( uid ) {} 281 : OSQLQuery(), m_uid( uid ) {}
282
282 RemoveQuery::~RemoveQuery() {} 283 RemoveQuery::~RemoveQuery() {}
284
283 QString RemoveQuery::query()const { 285 QString RemoveQuery::query()const {
284 QString qu = "DELETE from addressbook where uid = " 286 QString qu = "DELETE from addressbook where uid = "
285 + QString::number(m_uid) + ";"; 287 + QString::number(m_uid) + ";";
@@ -289,8 +291,6 @@ namespace {
289 } 291 }
290 292
291 293
292
293
294 FindQuery::FindQuery(int uid) 294 FindQuery::FindQuery(int uid)
295 : OSQLQuery(), m_uid( uid ) { 295 : OSQLQuery(), m_uid( uid ) {
296 } 296 }
@@ -300,12 +300,14 @@ 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
310
309 QString FindQuery::multi()const { 311 QString FindQuery::multi()const {
310 QString qu = "select * from addressbook where"; 312 QString qu = "select * from addressbook where";
311 for (uint i = 0; i < m_uids.count(); i++ ) { 313 for (uint i = 0; i < m_uids.count(); i++ ) {
@@ -528,10 +530,23 @@ OPimContact OPimContactAccessBackend_SQL::find( int uid, const UIDArray& queryUi
528} 530}
529 531
530 532
531UIDArray OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, 533UIDArray OPimContactAccessBackend_SQL::queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
532 const QDateTime& qd ) const 534 const QDateTime& qd ) const
533{ 535{
534 QString qu = "SELECT uid FROM addressbook WHERE"; 536 QString qu = "SELECT uid FROM addressbook WHERE";
537
538 // Just add uid's selection if we really try to search in a subset of all uids! Otherwise this would
539 // just take time and memory!
540 if ( uidlist.count() != m_uids.count() ) {
541 qu += " (";
542
543 for ( uint i = 0; i < uidlist.count(); i++ ) {
544 qu += " uid = " + QString::number( uidlist[i] ) + " OR";
545 }
546 qu.remove( qu.length()-2, 2 ); // Hmmmm..
547 qu += " ) AND ";
548 }
549
535 QString searchQuery =""; 550 QString searchQuery ="";
536 551
537 QDate startDate; 552 QDate startDate;