Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index 2bcab29..70e40e4 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -292,47 +292,57 @@ namespace { | |||
292 | + ",'" | 292 | + ",'" |
293 | + it.data() | 293 | + it.data() |
294 | + "');"; | 294 | + "');"; |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | odebug << "add " << qu << "" << oendl; | 298 | odebug << "add " << qu << "" << oendl; |
299 | return qu; | 299 | return qu; |
300 | } | 300 | } |
301 | 301 | ||
302 | RemoveQuery::RemoveQuery(int uid ) | 302 | RemoveQuery::RemoveQuery(int uid ) |
303 | : OSQLQuery(), m_uid( uid ) {} | 303 | : OSQLQuery(), m_uid( uid ) {} |
304 | |||
304 | RemoveQuery::~RemoveQuery() {} | 305 | RemoveQuery::~RemoveQuery() {} |
306 | |||
305 | QString RemoveQuery::query()const { | 307 | QString RemoveQuery::query()const { |
306 | QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; | 308 | QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; |
307 | qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); | 309 | qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); |
308 | return qu; | 310 | return qu; |
309 | } | 311 | } |
310 | 312 | ||
311 | 313 | ||
312 | ClearQuery::ClearQuery() | 314 | ClearQuery::ClearQuery() |
313 | : OSQLQuery() {} | 315 | : OSQLQuery() {} |
314 | ClearQuery::~ClearQuery() {} | 316 | ClearQuery::~ClearQuery() {} |
315 | QString ClearQuery::query()const { | 317 | QString ClearQuery::query()const |
316 | QString qu = "drop table todolist"; | 318 | { |
317 | return qu; | 319 | QString qu = "drop table todolist"; |
320 | return qu; | ||
318 | } | 321 | } |
322 | |||
319 | FindQuery::FindQuery(int uid) | 323 | FindQuery::FindQuery(int uid) |
320 | : OSQLQuery(), m_uid(uid ) { | 324 | : OSQLQuery(), m_uid(uid ) |
325 | { | ||
321 | } | 326 | } |
327 | |||
322 | FindQuery::FindQuery(const QArray<int>& ints) | 328 | FindQuery::FindQuery(const QArray<int>& ints) |
323 | : OSQLQuery(), m_uids(ints){ | 329 | : OSQLQuery(), m_uids(ints) |
330 | { | ||
324 | } | 331 | } |
325 | FindQuery::~FindQuery() { | 332 | |
333 | FindQuery::~FindQuery() | ||
334 | { | ||
326 | } | 335 | } |
336 | |||
327 | QString FindQuery::query()const{ | 337 | QString FindQuery::query()const{ |
328 | if (m_uids.count() == 0 ) | 338 | if (m_uids.count() == 0 ) |
329 | return single(); | 339 | return single(); |
330 | else | 340 | else |
331 | return multi(); | 341 | return multi(); |
332 | } | 342 | } |
333 | QString FindQuery::single()const{ | 343 | QString FindQuery::single()const{ |
334 | QString qu = "select * from todolist where uid = " + QString::number(m_uid); | 344 | QString qu = "select * from todolist where uid = " + QString::number(m_uid); |
335 | return qu; | 345 | return qu; |
336 | } | 346 | } |
337 | QString FindQuery::multi()const { | 347 | QString FindQuery::multi()const { |
338 | QString qu = "select * from todolist where "; | 348 | QString qu = "select * from todolist where "; |
@@ -439,28 +449,28 @@ bool OPimTodoAccessBackendSQL::reload(){ | |||
439 | return load(); | 449 | return load(); |
440 | } | 450 | } |
441 | 451 | ||
442 | bool OPimTodoAccessBackendSQL::save(){ | 452 | bool OPimTodoAccessBackendSQL::save(){ |
443 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 453 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
444 | } | 454 | } |
445 | QArray<int> OPimTodoAccessBackendSQL::allRecords()const { | 455 | QArray<int> OPimTodoAccessBackendSQL::allRecords()const { |
446 | if (m_dirty ) | 456 | if (m_dirty ) |
447 | update(); | 457 | update(); |
448 | 458 | ||
449 | return m_uids; | 459 | return m_uids; |
450 | } | 460 | } |
451 | QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){ | 461 | // QArray<int> OPimTodoAccessBackendSQL::queryByExample( const UIDArray& uidlist, const OPimTodo& , int, const QDateTime& ){ |
452 | QArray<int> ints(0); | 462 | // QArray<int> ints(0); |
453 | return ints; | 463 | // return ints; |
454 | } | 464 | // } |
455 | OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ | 465 | OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ |
456 | FindQuery query( uid ); | 466 | FindQuery query( uid ); |
457 | return parseResultAndCache( uid, m_driver->query(&query) ); | 467 | return parseResultAndCache( uid, m_driver->query(&query) ); |
458 | } | 468 | } |
459 | 469 | ||
460 | // Remember: uid is already in the list of uids, called ints ! | 470 | // Remember: uid is already in the list of uids, called ints ! |
461 | OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | 471 | OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, |
462 | uint cur, Frontend::CacheDirection dir ) const{ | 472 | uint cur, Frontend::CacheDirection dir ) const{ |
463 | uint CACHE = readAhead(); | 473 | uint CACHE = readAhead(); |
464 | odebug << "searching for " << uid << "" << oendl; | 474 | odebug << "searching for " << uid << "" << oendl; |
465 | QArray<int> search( CACHE ); | 475 | QArray<int> search( CACHE ); |
466 | uint size =0; | 476 | uint size =0; |
@@ -610,25 +620,25 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, | |||
610 | if ( !asc ) | 620 | if ( !asc ) |
611 | query += " DESC"; | 621 | query += " DESC"; |
612 | 622 | ||
613 | 623 | ||
614 | odebug << query << oendl; | 624 | odebug << query << oendl; |
615 | OSQLRawQuery raw(query ); | 625 | OSQLRawQuery raw(query ); |
616 | return uids( m_driver->query(&raw) ); | 626 | return uids( m_driver->query(&raw) ); |
617 | } | 627 | } |
618 | #endif | 628 | #endif |
619 | 629 | ||
620 | 630 | ||
621 | bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ | 631 | bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ |
622 | if ( str == "0-0-0" ) | 632 | if ( str == "0000-00-00" ) |
623 | return false; | 633 | return false; |
624 | else{ | 634 | else{ |
625 | int day, year, month; | 635 | int day, year, month; |
626 | QStringList list = QStringList::split("-", str ); | 636 | QStringList list = QStringList::split("-", str ); |
627 | year = list[0].toInt(); | 637 | year = list[0].toInt(); |
628 | month = list[1].toInt(); | 638 | month = list[1].toInt(); |
629 | day = list[2].toInt(); | 639 | day = list[2].toInt(); |
630 | da.setYMD( year, month, day ); | 640 | da.setYMD( year, month, day ); |
631 | return true; | 641 | return true; |
632 | } | 642 | } |
633 | } | 643 | } |
634 | 644 | ||