summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 6f65c48..12a8bea 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -457,6 +457,8 @@ OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
457 return todo( m_driver->query(&query) ); 457 return todo( m_driver->query(&query) );
458 458
459} 459}
460
461// Remember: uid is already in the list of uids, called ints !
460OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 462OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
461 uint cur, Frontend::CacheDirection dir ) const{ 463 uint cur, Frontend::CacheDirection dir ) const{
462 uint CACHE = readAhead(); 464 uint CACHE = readAhead();
@@ -468,7 +470,7 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
468 // we try to cache CACHE items 470 // we try to cache CACHE items
469 switch( dir ) { 471 switch( dir ) {
470 /* forward */ 472 /* forward */
471 case 0: // FIXME: Not a good style to use magic numbers here (eilers) 473 case Frontend::Forward:
472 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 474 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
473 odebug << "size " << size << " " << ints[i] << "" << oendl; 475 odebug << "size " << size << " " << ints[i] << "" << oendl;
474 search[size] = ints[i]; 476 search[size] = ints[i];
@@ -476,21 +478,24 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
476 } 478 }
477 break; 479 break;
478 /* reverse */ 480 /* reverse */
479 case 1: // FIXME: Not a good style to use magic numbers here (eilers) 481 case Frontend::Reverse:
480 for (uint i = cur; i != 0 && size < CACHE; i-- ) { 482 for (uint i = cur; i != 0 && size < CACHE; i-- ) {
481 search[size] = ints[i]; 483 search[size] = ints[i];
482 size++; 484 size++;
483 } 485 }
484 break; 486 break;
485 } 487 }
488
486 search.resize( size ); 489 search.resize( size );
487 FindQuery query( search ); 490 FindQuery query( search );
488 OSQLResult res = m_driver->query( &query ); 491 OSQLResult res = m_driver->query( &query );
489 if ( res.state() != OSQLResult::Success ) 492 if ( res.state() != OSQLResult::Success )
490 return to; 493 return to;
491 494
492 return todo( res ); 495 todo( res ); //FIXME: Don't like polymorphism here. It makes the code hard to read here..(eilers)
496 return cacheFind( uid );
493} 497}
498
494void OPimTodoAccessBackendSQL::clear() { 499void OPimTodoAccessBackendSQL::clear() {
495 ClearQuery cle; 500 ClearQuery cle;
496 OSQLResult res = m_driver->query( &cle ); 501 OSQLResult res = m_driver->query( &cle );