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 @@ -455,5 +455,5 @@ QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, con OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ FindQuery query( uid ); - return todo( m_driver->query(&query) ); + return parseResultAndCache( uid, m_driver->query(&query) ); } @@ -493,6 +493,5 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, return to; - todo( res ); //FIXME: Don't like polymorphism here. It makes the code hard to read here..(eilers) - return cacheFind( uid ); + return parseResultAndCache( uid, res ); } @@ -631,5 +630,5 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ } } -OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ +OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{ if ( res.state() == OSQLResult::Failure ) { OPimTodo to; @@ -637,4 +636,6 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ } + OPimTodo retTodo; + OSQLResultItem::ValueList list = res.results(); OSQLResultItem::ValueList::Iterator it = list.begin(); @@ -646,7 +647,10 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ for ( ; it != list.end(); ++it ) { odebug << "caching" << oendl; - cache( todo( (*it) ) ); + OPimTodo newTodo = todo( (*it) ); + cache( newTodo ); + if ( newTodo.uid() == uid ) + retTodo = newTodo; } - return to; + return retTodo; } OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { @@ -708,7 +712,9 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { return to; } + +// FIXME: Where is the difference to "find" ? (eilers) OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const { FindQuery find( uid ); - return todo( m_driver->query(&find) ); + return parseResultAndCache( uid, m_driver->query(&find) ); } /* |