summaryrefslogtreecommitdiff
path: root/libopie2
authoreilers <eilers>2004-09-05 15:46:47 (UTC)
committer eilers <eilers>2004-09-05 15:46:47 (UTC)
commit97a40bb7f35a8323dd99712bf014387add283177 (patch) (unidiff)
treeec50fbb430f00c86af6ca5bd7c6b94fa29cfe3b1 /libopie2
parentf8b02e2ae752ce98b8840735260c4e9b0ff25cb8 (diff)
downloadopie-97a40bb7f35a8323dd99712bf014387add283177.zip
opie-97a40bb7f35a8323dd99712bf014387add283177.tar.gz
opie-97a40bb7f35a8323dd99712bf014387add283177.tar.bz2
Fixing really stupid caching bug.. Thanks to zecke who found it..
Removed cachefind in backend which isn't needed anymore and not a goot idea...
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h4
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h22
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp20
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h2
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h4
6 files changed, 25 insertions, 32 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index abfd944..221e977 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -829,65 +829,68 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co
829 829
830 // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; 830 // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl;
831 odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed 831 odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed
832 << " ms, mapping: " << t3needed << " ms" << oendl; 832 << " ms, mapping: " << t3needed << " ms" << oendl;
833 833
834 return nonCustomMap; 834 return nonCustomMap;
835} 835}
836 836
837/* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ 837/* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */
838OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const 838OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const
839{ 839{
840 // We want to get all contacts with one query. 840 // We want to get all contacts with one query.
841 // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h). 841 // We don't have to add the given uid to the uidlist, it is expected to be there already (see opimrecordlist.h).
842 // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned 842 // All contacts will be stored in the cache, afterwards the contact with the user id "uid" will be returned
843 // by using the cache.. 843 // by using the cache..
844 QArray<int> cachelist = uidlist; 844 QArray<int> cachelist = uidlist;
845 OPimContact retContact;
845 846
846 odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl; 847 odebug << "Reqest and cache" << cachelist.size() << "elements !" << oendl;
847 848
848 QTime t; 849 QTime t;
849 t.start(); 850 t.start();
850 851
851 int t2needed = 0; 852 int t2needed = 0;
852 int t3needed = 0; 853 int t3needed = 0;
853 QTime t2; 854 QTime t2;
854 t2.start(); 855 t2.start();
855 FindQuery query( cachelist ); 856 FindQuery query( cachelist );
856 OSQLResult res_noncustom = m_driver->query( &query ); 857 OSQLResult res_noncustom = m_driver->query( &query );
857 t2needed = t2.elapsed(); 858 t2needed = t2.elapsed();
858 859
859 QMap<int, QString> nonCustomMap; 860 QMap<int, QString> nonCustomMap;
860 QTime t3; 861 QTime t3;
861 t3.start(); 862 t3.start();
862 OSQLResultItem resItem = res_noncustom.first(); 863 OSQLResultItem resItem = res_noncustom.first();
863 do { 864 do {
864 OPimContact contact( fillNonCustomMap( resItem ) ); 865 OPimContact contact( fillNonCustomMap( resItem ) );
865 contact.setExtraMap( requestCustom( contact.uid() ) ); 866 contact.setExtraMap( requestCustom( contact.uid() ) );
866 odebug << "Caching uid: " << contact.uid() << oendl; 867 odebug << "Caching uid: " << contact.uid() << oendl;
867 cache( contact ); 868 cache( contact );
869 if ( contact.uid() == uid )
870 retContact = contact;
868 resItem = res_noncustom.next(); 871 resItem = res_noncustom.next();
869 } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !! 872 } while ( ! res_noncustom.atEnd() ); //atEnd() is true if we are past(!) the list !!
870 t3needed = t3.elapsed(); 873 t3needed = t3.elapsed();
871 874
872 875
873 // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl; 876 // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl;
874 odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed 877 odebug << "RequestContactsAndCache needed: insg.:" << t.elapsed() << " ms, query: " << t2needed
875 << " ms, mapping: " << t3needed << " ms" << oendl; 878 << " ms, mapping: " << t3needed << " ms" << oendl;
876 879
877 return cacheFind( uid ); 880 return retContact;
878} 881}
879 882
880QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const 883QMap<int, QString> OPimContactAccessBackend_SQL::fillNonCustomMap( const OSQLResultItem& resultItem ) const
881{ 884{
882 QMap<int, QString> nonCustomMap; 885 QMap<int, QString> nonCustomMap;
883 886
884 // Now loop through all columns 887 // Now loop through all columns
885 QStringList fieldList = OPimContactFields::untrfields( false ); 888 QStringList fieldList = OPimContactFields::untrfields( false );
886 QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); 889 QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
887 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 890 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
888 // Get data for the selected column and store it with the 891 // Get data for the selected column and store it with the
889 // corresponding id into the map.. 892 // corresponding id into the map..
890 893
891 int id = translate[*it]; 894 int id = translate[*it];
892 QString value = resultItem.data( (*it) ); 895 QString value = resultItem.data( (*it) );
893 896
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index 4f81735..28d9746 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -59,34 +59,34 @@ namespace Opie {
59class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { 59class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
60 public: 60 public:
61 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 61 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
62 62
63 ~OPimContactAccessBackend_SQL (); 63 ~OPimContactAccessBackend_SQL ();
64 64
65 bool save(); 65 bool save();
66 66
67 bool load (); 67 bool load ();
68 68
69 void clear (); 69 void clear ();
70 70
71 bool wasChangedExternally(); 71 bool wasChangedExternally();
72 72
73 QArray<int> allRecords() const; 73 QArray<int> allRecords() const;
74 74
75 OPimContact find ( int uid ) const; 75 OPimContact find( int uid ) const;
76 OPimContact find( int uid, const QArray<int>&, uint cur, Frontend::CacheDirection ) const; 76 OPimContact find( int uid, const QArray<int>& items, uint cur, Frontend::CacheDirection ) const;
77 77
78 QArray<int> queryByExample ( const OPimContact &query, int settings, 78 QArray<int> queryByExample ( const OPimContact &query, int settings,
79 const QDateTime& d ); 79 const QDateTime& d );
80 80
81 QArray<int> matchRegexp( const QRegExp &r ) const; 81 QArray<int> matchRegexp( const QRegExp &r ) const;
82 82
83 const uint querySettings(); 83 const uint querySettings();
84 84
85 bool hasQuerySettings (uint querySettings) const; 85 bool hasQuerySettings (uint querySettings) const;
86 86
87 // Currently only asc implemented.. 87 // Currently only asc implemented..
88 QArray<int> sorted( bool asc, int , int , int ); 88 QArray<int> sorted( bool asc, int , int , int );
89 bool add ( const OPimContact &newcontact ); 89 bool add ( const OPimContact &newcontact );
90 90
91 bool replace ( const OPimContact &contact ); 91 bool replace ( const OPimContact &contact );
92 92
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 15a7b7f..26af762 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -80,35 +80,35 @@ public:
80 /** 80 /**
81 * return a List of records 81 * return a List of records
82 * that match the regex 82 * that match the regex
83 */ 83 */
84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
85 85
86 /** 86 /**
87 * queryByExample for T with the given Settings 87 * queryByExample for T with the given Settings
88 * 88 *
89 */ 89 */
90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
91 91
92 /** 92 /**
93 * find the OPimRecord with uid @param uid 93 * find the OPimRecord with uid @param uid
94 * returns T and T.isEmpty() if nothing was found 94 * returns T and T.isEmpty() if nothing was found
95 */ 95 */
96 virtual T find(int uid )const = 0; 96 virtual T find( int uid )const = 0;
97 97
98 virtual T find(int uid, const QArray<int>& items, 98 virtual T find( int uid, const QArray<int>& items,
99 uint current, typename Frontend::CacheDirection ) const; 99 uint current, typename Frontend::CacheDirection ) const;
100 /** 100 /**
101 * clear the back end 101 * clear the back end
102 */ 102 */
103 virtual void clear() = 0; 103 virtual void clear() = 0;
104 104
105 /** 105 /**
106 * add T 106 * add T
107 */ 107 */
108 virtual bool add( const T& t ) = 0; 108 virtual bool add( const T& t ) = 0;
109 109
110 /** 110 /**
111 * remove 111 * remove
112 */ 112 */
113 virtual bool remove( int uid ) = 0; 113 virtual bool remove( int uid ) = 0;
114 114
@@ -118,39 +118,32 @@ public:
118 virtual bool replace( const T& t ) = 0; 118 virtual bool replace( const T& t ) = 0;
119 119
120 /* 120 /*
121 * setTheFrontEnd!!! 121 * setTheFrontEnd!!!
122 */ 122 */
123 void setFrontend( Frontend* front ); 123 void setFrontend( Frontend* front );
124 124
125 /** 125 /**
126 * set the read ahead count 126 * set the read ahead count
127 */ 127 */
128 void setReadAhead( uint count ); 128 void setReadAhead( uint count );
129protected: 129protected:
130 int access()const; 130 int access()const;
131 131
132 void cache( const T& t )const; 132 void cache( const T& t )const;
133 133
134 /**
135 * Returns the element with given uid out of the cache.
136 * Returns empty element if nothing was found.
137 * <b>Attention:</b> This just works if we have a frontend which contains the cache !
138 */
139 T cacheFind( int uid ) const;
140
141 /** 134 /**
142 * use a prime number here! 135 * use a prime number here!
143 */ 136 */
144 void setSaneCacheSize( int ); 137 void setSaneCacheSize( int );
145 138
146 uint readAhead()const; 139 uint readAhead()const;
147 140
148private: 141private:
149 OPimAccessBackendPrivate *d; 142 OPimAccessBackendPrivate *d;
150 Frontend* m_front; 143 Frontend* m_front;
151 uint m_read; 144 uint m_read;
152 int m_acc; 145 int m_acc;
153 146
154}; 147};
155 148
156template <class T> 149template <class T>
@@ -160,51 +153,42 @@ OPimAccessBackend<T>::OPimAccessBackend(int acc)
160 m_front = 0l; 153 m_front = 0l;
161} 154}
162template <class T> 155template <class T>
163OPimAccessBackend<T>::~OPimAccessBackend() { 156OPimAccessBackend<T>::~OPimAccessBackend() {
164 157
165} 158}
166template <class T> 159template <class T>
167void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 160void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
168 m_front = fr; 161 m_front = fr;
169} 162}
170template <class T> 163template <class T>
171void OPimAccessBackend<T>::cache( const T& t )const { 164void OPimAccessBackend<T>::cache( const T& t )const {
172 if ( m_front ) 165 if ( m_front )
173 m_front->cache( t ); 166 m_front->cache( t );
174} 167}
175 168
176template <class T>
177T OPimAccessBackend<T>::cacheFind( int uid )const {
178 if ( ! m_front ){
179 qWarning ( "No frontend assigned ! Therefore we cannot access the cache to return the right element!" );
180 return T();
181 }
182
183 return m_front->cacheFind( uid );
184}
185 169
186template <class T> 170template <class T>
187void OPimAccessBackend<T>::setSaneCacheSize( int size) { 171void OPimAccessBackend<T>::setSaneCacheSize( int size) {
188 if ( m_front ) 172 if ( m_front )
189 m_front->setSaneCacheSize( size ); 173 m_front->setSaneCacheSize( size );
190} 174}
191template <class T> 175template <class T>
192T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 176T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
193 uint, typename Frontend::CacheDirection ) const{ 177 uint, typename Frontend::CacheDirection ) const{
194 qDebug( "*** Lookahead feature not supported. Fallback to default find!" ); 178 qDebug( "*** Lookahead feature not supported. Fallback to default find!!" );
195 return find( uid ); 179 return find( uid );
196} 180}
197template <class T> 181template <class T>
198void OPimAccessBackend<T>::setReadAhead( uint count ) { 182void OPimAccessBackend<T>::setReadAhead( uint count ) {
199 m_read = count; 183 m_read = count;
200} 184}
201template <class T> 185template <class T>
202uint OPimAccessBackend<T>::readAhead()const { 186uint OPimAccessBackend<T>::readAhead()const {
203 return m_read; 187 return m_read;
204} 188}
205template <class T> 189template <class T>
206int OPimAccessBackend<T>::access()const { 190int OPimAccessBackend<T>::access()const {
207 return m_acc; 191 return m_acc;
208} 192}
209 193
210} 194}
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
@@ -441,33 +441,33 @@ bool OPimTodoAccessBackendSQL::reload(){
441 441
442bool OPimTodoAccessBackendSQL::save(){ 442bool OPimTodoAccessBackendSQL::save(){
443 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 443 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
444} 444}
445QArray<int> OPimTodoAccessBackendSQL::allRecords()const { 445QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
446 if (m_dirty ) 446 if (m_dirty )
447 update(); 447 update();
448 448
449 return m_uids; 449 return m_uids;
450} 450}
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{
464 uint CACHE = readAhead(); 464 uint CACHE = readAhead();
465 odebug << "searching for " << uid << "" << oendl; 465 odebug << "searching for " << uid << "" << oendl;
466 QArray<int> search( CACHE ); 466 QArray<int> search( CACHE );
467 uint size =0; 467 uint size =0;
468 OPimTodo to; 468 OPimTodo to;
469 469
470 // we try to cache CACHE items 470 // we try to cache CACHE items
471 switch( dir ) { 471 switch( dir ) {
472 /* forward */ 472 /* forward */
473 case Frontend::Forward: 473 case Frontend::Forward:
@@ -479,34 +479,33 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
479 break; 479 break;
480 /* reverse */ 480 /* reverse */
481 case Frontend::Reverse: 481 case Frontend::Reverse:
482 for (uint i = cur; i != 0 && size < CACHE; i-- ) { 482 for (uint i = cur; i != 0 && size < CACHE; i-- ) {
483 search[size] = ints[i]; 483 search[size] = ints[i];
484 size++; 484 size++;
485 } 485 }
486 break; 486 break;
487 } 487 }
488 488
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;
503 res = m_driver->query(&qu); 502 res = m_driver->query(&qu);
504} 503}
505bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) { 504bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) {
506 InsertQuery ins( t ); 505 InsertQuery ins( t );
507 OSQLResult res = m_driver->query( &ins ); 506 OSQLResult res = m_driver->query( &ins );
508 507
509 if ( res.state() == OSQLResult::Failure ) 508 if ( res.state() == OSQLResult::Failure )
510 return false; 509 return false;
511 int c = m_uids.count(); 510 int c = m_uids.count();
512 m_uids.resize( c+1 ); 511 m_uids.resize( c+1 );
@@ -617,50 +616,55 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
617 OSQLRawQuery raw(query ); 616 OSQLRawQuery raw(query );
618 return uids( m_driver->query(&raw) ); 617 return uids( m_driver->query(&raw) );
619} 618}
620bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 619bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
621 if ( str == "0-0-0" ) 620 if ( str == "0-0-0" )
622 return false; 621 return false;
623 else{ 622 else{
624 int day, year, month; 623 int day, year, month;
625 QStringList list = QStringList::split("-", str ); 624 QStringList list = QStringList::split("-", str );
626 year = list[0].toInt(); 625 year = list[0].toInt();
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
657 bool hasDueDate = false; QDate dueDate = QDate::currentDate(); 661 bool hasDueDate = false; QDate dueDate = QDate::currentDate();
658 hasDueDate = date( dueDate, item.data("DueDate") ); 662 hasDueDate = date( dueDate, item.data("DueDate") );
659 QStringList cats = QStringList::split(";", item.data("categories") ); 663 QStringList cats = QStringList::split(";", item.data("categories") );
660 664
661 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl; 665 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
662 666
663 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 667 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
664 cats, item.data("summary"), item.data("description"), 668 cats, item.data("summary"), item.data("description"),
665 item.data("progress").toUShort(), hasDueDate, dueDate, 669 item.data("progress").toUShort(), hasDueDate, dueDate,
666 item.data("uid").toInt() ); 670 item.data("uid").toInt() );
@@ -694,35 +698,37 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
694 recMap.insert( OPimRecurrence::RPosition , item.data("RPosition") ); 698 recMap.insert( OPimRecurrence::RPosition , item.data("RPosition") );
695 recMap.insert( OPimRecurrence::RFreq , item.data("RFreq") ); 699 recMap.insert( OPimRecurrence::RFreq , item.data("RFreq") );
696 recMap.insert( OPimRecurrence::RHasEndDate, item.data("RHasEndDate") ); 700 recMap.insert( OPimRecurrence::RHasEndDate, item.data("RHasEndDate") );
697 recMap.insert( OPimRecurrence::EndDate , item.data("EndDate") ); 701 recMap.insert( OPimRecurrence::EndDate , item.data("EndDate") );
698 recMap.insert( OPimRecurrence::Created , item.data("Created") ); 702 recMap.insert( OPimRecurrence::Created , item.data("Created") );
699 recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") ); 703 recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") );
700 704
701 OPimRecurrence recur; 705 OPimRecurrence recur;
702 recur.fromMap( recMap ); 706 recur.fromMap( recMap );
703 to.setRecurrence( recur ); 707 to.setRecurrence( recur );
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
719#if 0 725#if 0
720 /* initialize dict */ 726 /* initialize dict */
721 /* 727 /*
722 * UPDATE dict if you change anything!!! 728 * UPDATE dict if you change anything!!!
723 * FIXME: Isn't this dict obsolete ? (eilers) 729 * FIXME: Isn't this dict obsolete ? (eilers)
724 */ 730 */
725 m_dict.setAutoDelete( TRUE ); 731 m_dict.setAutoDelete( TRUE );
726 m_dict.insert("Categories" , new int(OPimTodo::Category) ); 732 m_dict.insert("Categories" , new int(OPimTodo::Category) );
727 m_dict.insert("Uid" , new int(OPimTodo::Uid) ); 733 m_dict.insert("Uid" , new int(OPimTodo::Uid) );
728 m_dict.insert("HasDate" , new int(OPimTodo::HasDate) ); 734 m_dict.insert("HasDate" , new int(OPimTodo::HasDate) );
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 0cc7722..415f791 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -62,32 +62,32 @@ public:
62 bool replace( const OPimTodo& t ); 62 bool replace( const OPimTodo& t );
63 63
64 QArray<int> overDue(); 64 QArray<int> overDue();
65 QArray<int> effectiveToDos( const QDate& start, 65 QArray<int> effectiveToDos( const QDate& start,
66 const QDate& end, bool includeNoDates ); 66 const QDate& end, bool includeNoDates );
67 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 67 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
68 68
69 QBitArray supports()const; 69 QBitArray supports()const;
70 QArray<int> matchRegexp( const QRegExp &r ) const; 70 QArray<int> matchRegexp( const QRegExp &r ) const;
71 void removeAllCompleted(); 71 void removeAllCompleted();
72 72
73 73
74private: 74private:
75 void update()const; 75 void update()const;
76 void fillDict(); 76 void fillDict();
77 inline bool date( QDate& date, const QString& )const; 77 inline bool date( QDate& date, const QString& )const;
78 inline OPimTodo todo( const Opie::DB::OSQLResult& )const; 78 inline OPimTodo parseResultAndCache( int uid, const Opie::DB::OSQLResult& )const;
79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const; 79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const;
80 inline QArray<int> uids( const Opie::DB::OSQLResult& )const; 80 inline QArray<int> uids( const Opie::DB::OSQLResult& )const;
81 OPimTodo todo( int uid )const; 81 OPimTodo todo( int uid )const;
82 QBitArray sup() const; 82 QBitArray sup() const;
83 QMap<QString, QString> requestCustom( int uid ) const; 83 QMap<QString, QString> requestCustom( int uid ) const;
84 84
85 // QAsciiDict<int> m_dict; 85 // QAsciiDict<int> m_dict;
86 Opie::DB::OSQLDriver* m_driver; 86 Opie::DB::OSQLDriver* m_driver;
87 QArray<int> m_uids; 87 QArray<int> m_uids;
88 bool m_dirty : 1; 88 bool m_dirty : 1;
89}; 89};
90 90
91} 91}
92 92
93#endif 93#endif
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6f01b46..7ab1ea5 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -106,38 +106,38 @@ public:
106 106
107 /** 107 /**
108 * return a List of records 108 * return a List of records
109 * that match the regex 109 * that match the regex
110 */ 110 */
111 virtual List matchRegexp( const QRegExp &r ) const; 111 virtual List matchRegexp( const QRegExp &r ) const;
112 112
113 /** 113 /**
114 * queryByExample. 114 * queryByExample.
115 * @see otodoaccess, ocontactaccess 115 * @see otodoaccess, ocontactaccess
116 */ 116 */
117 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 117 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
118 118
119 /** 119 /**
120 * find the OPimRecord uid 120 * find the OPimRecord uid
121 */ 121 */
122 virtual T find( int uid )const; 122 T find( int uid )const;
123 123
124 /** 124 /**
125 * read ahead cache find method ;) 125 * read ahead cache find method ;)
126 */ 126 */
127 virtual T find( int uid, const QArray<int>&, 127 T find( int uid, const QArray<int>&,
128 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 128 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
129 129
130 130
131 /* invalidate cache here */ 131 /* invalidate cache here */
132 /** 132 /**
133 * clears the backend and invalidates the backend 133 * clears the backend and invalidates the backend
134 */ 134 */
135 void clear() ; 135 void clear() ;
136 136
137 /** 137 /**
138 * add T to the backend 138 * add T to the backend
139 * @param t The item to add. 139 * @param t The item to add.
140 * @return <i>true</i> if added successfully. 140 * @return <i>true</i> if added successfully.
141 */ 141 */
142 virtual bool add( const T& t ) ; 142 virtual bool add( const T& t ) ;
143 143