Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 20 |
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 | |||
@@ -454,7 +454,7 @@ QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, con | |||
454 | } | 454 | } |
455 | OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ | 455 | OPimTodo 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 | ||
@@ -492,8 +492,7 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | |||
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 | ||
499 | void OPimTodoAccessBackendSQL::clear() { | 498 | void OPimTodoAccessBackendSQL::clear() { |
@@ -630,12 +629,14 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ | |||
630 | return true; | 629 | return true; |
631 | } | 630 | } |
632 | } | 631 | } |
633 | OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ | 632 | OPimTodo 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; |
@@ -645,9 +646,12 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ | |||
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 | } |
652 | OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | 656 | OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { |
653 | odebug << "todo(ResultItem)" << oendl; | 657 | odebug << "todo(ResultItem)" << oendl; |
@@ -707,9 +711,11 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
707 | 711 | ||
708 | return to; | 712 | return to; |
709 | } | 713 | } |
714 | |||
715 | // FIXME: Where is the difference to "find" ? (eilers) | ||
710 | OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const { | 716 | OPimTodo 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 |