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.cpp444
1 files changed, 224 insertions, 220 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 132b5a6..6f65c48 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -30,8 +30,3 @@
30 30
31#include <qdatetime.h> 31/* OPIE */
32#include <qmap.h>
33#include <qstring.h>
34
35#include <qpe/global.h>
36
37#include <opie2/osqldriver.h> 32#include <opie2/osqldriver.h>
@@ -45,2 +40,11 @@
45#include <opie2/opimrecurrence.h> 40#include <opie2/opimrecurrence.h>
41#include <opie2/odebug.h>
42
43#include <qpe/global.h>
44
45/* QT */
46#include <qdatetime.h>
47#include <qmap.h>
48#include <qstring.h>
49
46 50
@@ -153,17 +157,17 @@ namespace {
153 157
154 /** 158 /**
155 * a find query for custom elements 159 * a find query for custom elements
156 */ 160 */
157 class FindCustomQuery : public OSQLQuery { 161 class FindCustomQuery : public OSQLQuery {
158 public: 162 public:
159 FindCustomQuery(int uid); 163 FindCustomQuery(int uid);
160 FindCustomQuery(const QArray<int>& ); 164 FindCustomQuery(const QArray<int>& );
161 ~FindCustomQuery(); 165 ~FindCustomQuery();
162 QString query()const; 166 QString query()const;
163 private: 167 private:
164 QString single()const; 168 QString single()const;
165 QString multi()const; 169 QString multi()const;
166 QArray<int> m_uids; 170 QArray<int> m_uids;
167 int m_uid; 171 int m_uid;
168 }; 172 };
169 173
@@ -177,6 +181,6 @@ namespace {
177 qu += "description, summary, priority, DueDate, progress , state, "; 181 qu += "description, summary, priority, DueDate, progress , state, ";
178 // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers) 182 // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers)
179 qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; 183 qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, ";
180 qu += "reminders, alarms, maintainer, startdate, completeddate);"; 184 qu += "reminders, alarms, maintainer, startdate, completeddate);";
181 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; 185 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
182 return qu; 186 return qu;
@@ -188,3 +192,3 @@ namespace {
188 QString qu; 192 QString qu;
189 // We do not need "distinct" here. The primary key is always unique.. 193 // We do not need "distinct" here. The primary key is always unique..
190 //qu += "select distinct uid from todolist"; 194 //qu += "select distinct uid from todolist";
@@ -215,81 +219,81 @@ namespace {
215 day = date.day(); 219 day = date.day();
216 } 220 }
217 int sYear = 0, sMonth = 0, sDay = 0; 221 int sYear = 0, sMonth = 0, sDay = 0;
218 if( m_todo.hasStartDate() ){ 222 if( m_todo.hasStartDate() ){
219 QDate sDate = m_todo.startDate(); 223 QDate sDate = m_todo.startDate();
220 sYear = sDate.year(); 224 sYear = sDate.year();
221 sMonth= sDate.month(); 225 sMonth= sDate.month();
222 sDay = sDate.day(); 226 sDay = sDate.day();
223 } 227 }
224 228
225 int eYear = 0, eMonth = 0, eDay = 0; 229 int eYear = 0, eMonth = 0, eDay = 0;
226 if( m_todo.hasCompletedDate() ){ 230 if( m_todo.hasCompletedDate() ){
227 QDate eDate = m_todo.completedDate(); 231 QDate eDate = m_todo.completedDate();
228 eYear = eDate.year(); 232 eYear = eDate.year();
229 eMonth= eDate.month(); 233 eMonth= eDate.month();
230 eDay = eDate.day(); 234 eDay = eDate.day();
231 } 235 }
232 QString qu; 236 QString qu;
233 QMap<int, QString> recMap = m_todo.recurrence().toMap(); 237 QMap<int, QString> recMap = m_todo.recurrence().toMap();
234 qu = "insert into todolist VALUES(" 238 qu = "insert into todolist VALUES("
235 + QString::number( m_todo.uid() ) + "," 239 + QString::number( m_todo.uid() ) + ","
236 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," 240 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
237 + QString::number( m_todo.isCompleted() ) + "," 241 + QString::number( m_todo.isCompleted() ) + ","
238 + "'" + m_todo.description() + "'" + "," 242 + "'" + m_todo.description() + "'" + ","
239 + "'" + m_todo.summary() + "'" + "," 243 + "'" + m_todo.summary() + "'" + ","
240 + QString::number(m_todo.priority() ) + "," 244 + QString::number(m_todo.priority() ) + ","
241 + "'" + QString::number(year).rightJustify( 4, '0' ) + "-" 245 + "'" + QString::number(year).rightJustify( 4, '0' ) + "-"
242 + QString::number(month).rightJustify( 2, '0' ) 246 + QString::number(month).rightJustify( 2, '0' )
243 + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + "," 247 + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + ","
244 + QString::number( m_todo.progress() ) + "," 248 + QString::number( m_todo.progress() ) + ","
245 + QString::number( m_todo.state().state() ) + "," 249 + QString::number( m_todo.state().state() ) + ","
246 + "'" + recMap[ OPimRecurrence::RType ] + "'" + "," 250 + "'" + recMap[ OPimRecurrence::RType ] + "'" + ","
247 + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + "," 251 + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + ","
248 + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + "," 252 + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + ","
249 + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + "," 253 + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + ","
250 + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + "," 254 + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + ","
251 + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + "," 255 + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + ","
252 + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," 256 + "'" + recMap[ OPimRecurrence::Created ] + "'" + ","
253 + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; 257 + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ",";
254 258
255 if ( m_todo.hasNotifiers() ) { 259 if ( m_todo.hasNotifiers() ) {
256 OPimNotifyManager manager = m_todo.notifiers(); 260 OPimNotifyManager manager = m_todo.notifiers();
257 qu += "'" + manager.remindersToString() + "'" + "," 261 qu += "'" + manager.remindersToString() + "'" + ","
258 + "'" + manager.alarmsToString() + "'" + ","; 262 + "'" + manager.alarmsToString() + "'" + ",";
259 } 263 }
260 else{ 264 else{
261 qu += QString( "''" ) + "," 265 qu += QString( "''" ) + ","
262 + "''" + ","; 266 + "''" + ",";
263 } 267 }
264 268
265 qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) 269 qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
266 + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-" 270 + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-"
267 + QString::number(sMonth).rightJustify( 2, '0' ) 271 + QString::number(sMonth).rightJustify( 2, '0' )
268 + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + "," 272 + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + ","
269 + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-" 273 + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-"
270 + QString::number(eMonth).rightJustify( 2, '0' ) 274 + QString::number(eMonth).rightJustify( 2, '0' )
271 + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'" 275 + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'"
272 + "); "; 276 + "); ";
273 277
274 // Save custom Entries: 278 // Save custom Entries:
275 int id = 0; 279 int id = 0;
276 id = 0; 280 id = 0;
277 QMap<QString, QString> customMap = m_todo.toExtraMap(); 281 QMap<QString, QString> customMap = m_todo.toExtraMap();
278 for( QMap<QString, QString>::Iterator it = customMap.begin(); 282 for( QMap<QString, QString>::Iterator it = customMap.begin();
279 it != customMap.end(); ++it ){ 283 it != customMap.end(); ++it ){
280 qu += "insert into custom_data VALUES(" 284 qu += "insert into custom_data VALUES("
281 + QString::number( m_todo.uid() ) 285 + QString::number( m_todo.uid() )
282 + "," 286 + ","
283 + QString::number( id++ ) 287 + QString::number( id++ )
284 + ",'" 288 + ",'"
285 + it.key() 289 + it.key()
286 + "'," 290 + "',"
287 + "0" // Priority for future enhancements 291 + "0" // Priority for future enhancements
288 + ",'" 292 + ",'"
289 + it.data() 293 + it.data()
290 + "');"; 294 + "');";
291 } 295 }
292 296
293 297
294 qDebug("add %s", qu.latin1() ); 298 odebug << "add " << qu << "" << oendl;
295 return qu; 299 return qu;
@@ -302,3 +306,3 @@ namespace {
302 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; 306 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;";
303 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); 307 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
304 return qu; 308 return qu;
@@ -347,5 +351,5 @@ namespace {
347 str = QString("select uid from todolist where DueDate ='%1-%2-%3'") 351 str = QString("select uid from todolist where DueDate ='%1-%2-%3'")
348 .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) 352 .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
349 .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) 353 .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
350 .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) ); 354 .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) );
351 355
@@ -364,8 +368,8 @@ namespace {
364 str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") 368 str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ")
365 .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) 369 .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
366 .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) 370 .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
367 .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) 371 .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
368 .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) 372 .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
369 .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) 373 .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
370 .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); 374 .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
371 return str; 375 return str;
@@ -375,8 +379,8 @@ namespace {
375 str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") 379 str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'")
376 .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) 380 .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
377 .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) 381 .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
378 .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) 382 .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
379 .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) 383 .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
380 .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) 384 .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
381 .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); 385 .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
382 386
@@ -385,18 +389,18 @@ namespace {
385 389
386 FindCustomQuery::FindCustomQuery(int uid) 390 FindCustomQuery::FindCustomQuery(int uid)
387 : OSQLQuery(), m_uid( uid ) { 391 : OSQLQuery(), m_uid( uid ) {
388 } 392 }
389 FindCustomQuery::FindCustomQuery(const QArray<int>& ints) 393 FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
390 : OSQLQuery(), m_uids( ints ){ 394 : OSQLQuery(), m_uids( ints ){
391 } 395 }
392 FindCustomQuery::~FindCustomQuery() { 396 FindCustomQuery::~FindCustomQuery() {
393 } 397 }
394 QString FindCustomQuery::query()const{ 398 QString FindCustomQuery::query()const{
395 return single(); // Multiple requests not supported ! 399 return single(); // Multiple requests not supported !
396 } 400 }
397 QString FindCustomQuery::single()const{ 401 QString FindCustomQuery::single()const{
398 QString qu = "select uid, type, value from custom_data where uid = "; 402 QString qu = "select uid, type, value from custom_data where uid = ";
399 qu += QString::number(m_uid); 403 qu += QString::number(m_uid);
400 return qu; 404 return qu;
401 } 405 }
402 406
@@ -407,3 +411,3 @@ namespace Opie {
407OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file ) 411OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file )
408 : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true) 412 : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true)
409{ 413{
@@ -419,4 +423,4 @@ OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file )
419OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){ 423OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){
420 if( m_driver ) 424 if( m_driver )
421 delete m_driver; 425 delete m_driver;
422} 426}
@@ -458,3 +462,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
458 uint CACHE = readAhead(); 462 uint CACHE = readAhead();
459 qDebug("searching for %d", uid ); 463 odebug << "searching for " << uid << "" << oendl;
460 QArray<int> search( CACHE ); 464 QArray<int> search( CACHE );
@@ -468,3 +472,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
468 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 472 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
469 qDebug("size %d %d", size, ints[i] ); 473 odebug << "size " << size << " " << ints[i] << "" << oendl;
470 search[size] = ints[i]; 474 search[size] = ints[i];
@@ -543,3 +547,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
543 int sortFilter, int cat ) { 547 int sortFilter, int cat ) {
544 qDebug("sorted %d, %d", asc, sortOrder ); 548 odebug << "sorted " << asc << ", " << sortOrder << "" << oendl;
545 QString query; 549 QString query;
@@ -565,5 +569,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
565 base = QString("DueDate <= '%1-%2-%3' AND completed = 0") 569 base = QString("DueDate <= '%1-%2-%3' AND completed = 0")
566 .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) 570 .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
567 .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) 571 .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
568 .arg( QString::number( date.day() ).rightJustify( 2, '0' ) ); 572 .arg( QString::number( date.day() ).rightJustify( 2, '0' ) );
569 query += " " + base + " AND"; 573 query += " " + base + " AND";
@@ -602,3 +606,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
602 if ( !asc ) { 606 if ( !asc ) {
603 qDebug("not ascending!"); 607 odebug << "not ascending!" << oendl;
604 query += " DESC"; 608 query += " DESC";
@@ -606,3 +610,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
606 610
607 qDebug( query ); 611 odebug << query << oendl;
608 OSQLRawQuery raw(query ); 612 OSQLRawQuery raw(query );
@@ -631,3 +635,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
631 OSQLResultItem::ValueList::Iterator it = list.begin(); 635 OSQLResultItem::ValueList::Iterator it = list.begin();
632 qDebug("todo1"); 636 odebug << "todo1" << oendl;
633 OPimTodo to = todo( (*it) ); 637 OPimTodo to = todo( (*it) );
@@ -637,3 +641,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
637 for ( ; it != list.end(); ++it ) { 641 for ( ; it != list.end(); ++it ) {
638 qDebug("caching"); 642 odebug << "caching" << oendl;
639 cache( todo( (*it) ) ); 643 cache( todo( (*it) ) );
@@ -643,3 +647,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
643OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 647OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
644 qDebug("todo(ResultItem)"); 648 odebug << "todo(ResultItem)" << oendl;
645 649
@@ -651,3 +655,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
651 655
652 qDebug("Item is completed: %d", item.data("completed").toInt() ); 656 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
653 657
@@ -661,3 +665,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
661 if ( isOk ) 665 if ( isOk )
662 to.setPriority( prioInt ); 666 to.setPriority( prioInt );
663 667
@@ -669,5 +673,5 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
669 if ( hasStartDate ) 673 if ( hasStartDate )
670 to.setStartDate( startDate ); 674 to.setStartDate( startDate );
671 if ( hasCompletedDate ) 675 if ( hasCompletedDate )
672 to.setCompletedDate( completedDate ); 676 to.setCompletedDate( completedDate );
673 677
@@ -752,3 +756,3 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
752 QArray<int> ints(list.count() ); 756 QArray<int> ints(list.count() );
753 qDebug(" count = %d", list.count() ); 757 odebug << " count = " << list.count() << "" << oendl;
754 758
@@ -766,20 +770,20 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
766#if 0 770#if 0
767 QArray<int> empty; 771 QArray<int> empty;
768 return empty; 772 return empty;
769 773
770#else 774#else
771 QString qu = "SELECT uid FROM todolist WHERE ("; 775 QString qu = "SELECT uid FROM todolist WHERE (";
772 776
773 // Do it make sense to search other fields, too ? 777 // Do it make sense to search other fields, too ?
774 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; 778 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
775 qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; 779 qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
776 780
777 qu += ")"; 781 qu += ")";
778 782
779 qDebug( "query: %s", qu.latin1() ); 783 odebug << "query: " << qu << "" << oendl;
780 784
781 OSQLRawQuery raw( qu ); 785 OSQLRawQuery raw( qu );
782 OSQLResult res = m_driver->query( &raw ); 786 OSQLResult res = m_driver->query( &raw );
783 787
784 return uids( res ); 788 return uids( res );
785 789
@@ -791,3 +795,3 @@ QBitArray OPimTodoAccessBackendSQL::supports()const {
791 795
792 return sup(); 796 return sup();
793} 797}
@@ -796,11 +800,11 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{
796 800
797 QBitArray ar( OPimTodo::CompletedDate + 1 ); 801 QBitArray ar( OPimTodo::CompletedDate + 1 );
798 ar.fill( true ); 802 ar.fill( true );
799 ar[OPimTodo::CrossReference] = false; 803 ar[OPimTodo::CrossReference] = false;
800 ar[OPimTodo::State ] = false; 804 ar[OPimTodo::State ] = false;
801 ar[OPimTodo::Reminders] = false; 805 ar[OPimTodo::Reminders] = false;
802 ar[OPimTodo::Notifiers] = false; 806 ar[OPimTodo::Notifiers] = false;
803 ar[OPimTodo::Maintainer] = false; 807 ar[OPimTodo::Maintainer] = false;
804 808
805 return ar; 809 return ar;
806} 810}
@@ -808,45 +812,45 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{
808void OPimTodoAccessBackendSQL::removeAllCompleted(){ 812void OPimTodoAccessBackendSQL::removeAllCompleted(){
809 // First we need the uids from all entries which are 813 // First we need the uids from all entries which are
810 // completed. Then, we just have to remove them... 814 // completed. Then, we just have to remove them...
811 815
812 QString qu = "SELECT uid FROM todolist WHERE completed = 1"; 816 QString qu = "SELECT uid FROM todolist WHERE completed = 1";
813 817
814 OSQLRawQuery raw( qu ); 818 OSQLRawQuery raw( qu );
815 OSQLResult res = m_driver->query( &raw ); 819 OSQLResult res = m_driver->query( &raw );
816 820
817 QArray<int> completed_uids = uids( res ); 821 QArray<int> completed_uids = uids( res );
818 822
819 qDebug( "Number of completed: %d", completed_uids.size() ); 823 odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
820 824
821 if ( completed_uids.size() == 0 ) 825 if ( completed_uids.size() == 0 )
822 return; 826 return;
823 827
824 qu = "DELETE FROM todolist WHERE ("; 828 qu = "DELETE FROM todolist WHERE (";
825 QString query; 829 QString query;
826 830
827 for ( int i = 0; i < completed_uids.size(); i++ ){ 831 for ( int i = 0; i < completed_uids.size(); i++ ){
828 if ( !query.isEmpty() ) 832 if ( !query.isEmpty() )
829 query += " OR "; 833 query += " OR ";
830 query += QString( "uid = %1" ).arg( completed_uids[i] ); 834 query += QString( "uid = %1" ).arg( completed_uids[i] );
831 } 835 }
832 qu += query + " );"; 836 qu += query + " );";
833 837
834 // Put remove of custom entries in this query to speed up.. 838 // Put remove of custom entries in this query to speed up..
835 qu += "DELETE FORM custom_data WHERE ("; 839 qu += "DELETE FORM custom_data WHERE (";
836 query = ""; 840 query = "";
837 841
838 for ( int i = 0; i < completed_uids.size(); i++ ){ 842 for ( int i = 0; i < completed_uids.size(); i++ ){
839 if ( !query.isEmpty() ) 843 if ( !query.isEmpty() )
840 query += " OR "; 844 query += " OR ";
841 query += QString( "uid = %1" ).arg( completed_uids[i] ); 845 query += QString( "uid = %1" ).arg( completed_uids[i] );
842 } 846 }
843 qu += query + " );"; 847 qu += query + " );";
844 848
845 qDebug( "query: %s", qu.latin1() ); 849 odebug << "query: " << qu << "" << oendl;
846 850
847 OSQLRawQuery raw2( qu ); 851 OSQLRawQuery raw2( qu );
848 res = m_driver->query( &raw2 ); 852 res = m_driver->query( &raw2 );
849 if ( res.state() == OSQLResult::Failure ) { 853 if ( res.state() == OSQLResult::Failure ) {
850 qWarning("OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: %s", qu.latin1() ); 854 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
851 } 855 }
852} 856}
@@ -856,20 +860,20 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
856{ 860{
857 QMap<QString, QString> customMap; 861 QMap<QString, QString> customMap;
858 862
859 FindCustomQuery query( uid ); 863 FindCustomQuery query( uid );
860 OSQLResult res_custom = m_driver->query( &query ); 864 OSQLResult res_custom = m_driver->query( &query );
861 865
862 if ( res_custom.state() == OSQLResult::Failure ) { 866 if ( res_custom.state() == OSQLResult::Failure ) {
863 qWarning("OSQLResult::Failure in find query !!"); 867 owarn << "OSQLResult::Failure in find query !!" << oendl;
864 QMap<QString, QString> empty; 868 QMap<QString, QString> empty;
865 return empty; 869 return empty;
866 } 870 }
867 871
868 OSQLResultItem::ValueList list = res_custom.results(); 872 OSQLResultItem::ValueList list = res_custom.results();
869 OSQLResultItem::ValueList::Iterator it = list.begin(); 873 OSQLResultItem::ValueList::Iterator it = list.begin();
870 for ( ; it != list.end(); ++it ) { 874 for ( ; it != list.end(); ++it ) {
871 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 875 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
872 } 876 }
873 877
874 return customMap; 878 return customMap;
875} 879}