summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 12a8bea..4e3e47b 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -451,13 +451,13 @@ QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
451QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){ 451QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){
452 QArray<int> ints(0); 452 QArray<int> ints(0);
453 return ints; 453 return ints;
454} 454}
455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ 455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
456 FindQuery query( uid ); 456 FindQuery query( uid );
457 return todo( m_driver->query(&query) ); 457 return parseResultAndCache( uid, m_driver->query(&query) );
458 458
459} 459}
460 460
461// Remember: uid is already in the list of uids, called ints ! 461// Remember: uid is already in the list of uids, called ints !
462OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 462OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
463 uint cur, Frontend::CacheDirection dir ) const{ 463 uint cur, Frontend::CacheDirection dir ) const{
@@ -489,14 +489,13 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
489 search.resize( size ); 489 search.resize( size );
490 FindQuery query( search ); 490 FindQuery query( search );
491 OSQLResult res = m_driver->query( &query ); 491 OSQLResult res = m_driver->query( &query );
492 if ( res.state() != OSQLResult::Success ) 492 if ( res.state() != OSQLResult::Success )
493 return to; 493 return to;
494 494
495 todo( res ); //FIXME: Don't like polymorphism here. It makes the code hard to read here..(eilers) 495 return parseResultAndCache( uid, res );
496 return cacheFind( uid );
497} 496}
498 497
499void OPimTodoAccessBackendSQL::clear() { 498void OPimTodoAccessBackendSQL::clear() {
500 ClearQuery cle; 499 ClearQuery cle;
501 OSQLResult res = m_driver->query( &cle ); 500 OSQLResult res = m_driver->query( &cle );
502 CreateQuery qu; 501 CreateQuery qu;
@@ -627,30 +626,35 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
627 month = list[1].toInt(); 626 month = list[1].toInt();
628 day = list[2].toInt(); 627 day = list[2].toInt();
629 da.setYMD( year, month, day ); 628 da.setYMD( year, month, day );
630 return true; 629 return true;
631 } 630 }
632} 631}
633OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ 632OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
634 if ( res.state() == OSQLResult::Failure ) { 633 if ( res.state() == OSQLResult::Failure ) {
635 OPimTodo to; 634 OPimTodo to;
636 return to; 635 return to;
637 } 636 }
638 637
638 OPimTodo retTodo;
639
639 OSQLResultItem::ValueList list = res.results(); 640 OSQLResultItem::ValueList list = res.results();
640 OSQLResultItem::ValueList::Iterator it = list.begin(); 641 OSQLResultItem::ValueList::Iterator it = list.begin();
641 odebug << "todo1" << oendl; 642 odebug << "todo1" << oendl;
642 OPimTodo to = todo( (*it) ); 643 OPimTodo to = todo( (*it) );
643 cache( to ); 644 cache( to );
644 ++it; 645 ++it;
645 646
646 for ( ; it != list.end(); ++it ) { 647 for ( ; it != list.end(); ++it ) {
647 odebug << "caching" << oendl; 648 odebug << "caching" << oendl;
648 cache( todo( (*it) ) ); 649 OPimTodo newTodo = todo( (*it) );
650 cache( newTodo );
651 if ( newTodo.uid() == uid )
652 retTodo = newTodo;
649 } 653 }
650 return to; 654 return retTodo;
651} 655}
652OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 656OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
653 odebug << "todo(ResultItem)" << oendl; 657 odebug << "todo(ResultItem)" << oendl;
654 658
655 // Request information from addressbook table and create the OPimTodo-object. 659 // Request information from addressbook table and create the OPimTodo-object.
656 660
@@ -704,15 +708,17 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
704 708
705 // Finally load the custom-entries for this UID and put it into the created object 709 // Finally load the custom-entries for this UID and put it into the created object
706 to.setExtraMap( requestCustom( to.uid() ) ); 710 to.setExtraMap( requestCustom( to.uid() ) );
707 711
708 return to; 712 return to;
709} 713}
714
715// FIXME: Where is the difference to "find" ? (eilers)
710OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const { 716OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
711 FindQuery find( uid ); 717 FindQuery find( uid );
712 return todo( m_driver->query(&find) ); 718 return parseResultAndCache( uid, m_driver->query(&find) );
713} 719}
714/* 720/*
715 * update the dict 721 * update the dict
716 */ 722 */
717void OPimTodoAccessBackendSQL::fillDict() { 723void OPimTodoAccessBackendSQL::fillDict() {
718 724