summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Side-by-side diff
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 {
QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){
QArray<int> ints(0);
return ints;
}
OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
FindQuery query( uid );
- return todo( m_driver->query(&query) );
+ return parseResultAndCache( uid, m_driver->query(&query) );
}
// Remember: uid is already in the list of uids, called ints !
OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
uint cur, Frontend::CacheDirection dir ) const{
@@ -489,14 +489,13 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
search.resize( size );
FindQuery query( search );
OSQLResult res = m_driver->query( &query );
if ( res.state() != OSQLResult::Success )
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 );
}
void OPimTodoAccessBackendSQL::clear() {
ClearQuery cle;
OSQLResult res = m_driver->query( &cle );
CreateQuery qu;
@@ -627,30 +626,35 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
month = list[1].toInt();
day = list[2].toInt();
da.setYMD( year, month, day );
return true;
}
}
-OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
+OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
if ( res.state() == OSQLResult::Failure ) {
OPimTodo to;
return to;
}
+ OPimTodo retTodo;
+
OSQLResultItem::ValueList list = res.results();
OSQLResultItem::ValueList::Iterator it = list.begin();
odebug << "todo1" << oendl;
OPimTodo to = todo( (*it) );
cache( to );
++it;
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 {
odebug << "todo(ResultItem)" << oendl;
// Request information from addressbook table and create the OPimTodo-object.
@@ -704,15 +708,17 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
// Finally load the custom-entries for this UID and put it into the created object
to.setExtraMap( requestCustom( to.uid() ) );
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) );
}
/*
* update the dict
*/
void OPimTodoAccessBackendSQL::fillDict() {