author | ar <ar> | 2004-06-01 21:38:07 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-01 21:38:07 (UTC) |
commit | baed1d5ab8589aef14440009bc4e7380bcc5a741 (patch) (side-by-side diff) | |
tree | c636e892c5eec0df2b36d16cb601a7da41a2ef0f /libopie2/opiepim/backend/otodoaccesssql.cpp | |
parent | 4438393d8eef624565e840b798429071829adea8 (diff) | |
download | opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.zip opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.gz opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.bz2 |
- convert to odebug framework
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 444 |
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 @@ -25,27 +25,31 @@ -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <qdatetime.h> -#include <qmap.h> -#include <qstring.h> - -#include <qpe/global.h> - +/* OPIE */ #include <opie2/osqldriver.h> #include <opie2/osqlresult.h> #include <opie2/osqlmanager.h> #include <opie2/osqlquery.h> #include <opie2/otodoaccesssql.h> #include <opie2/opimstate.h> #include <opie2/opimnotifymanager.h> #include <opie2/opimrecurrence.h> +#include <opie2/odebug.h> + +#include <qpe/global.h> + +/* QT */ +#include <qdatetime.h> +#include <qmap.h> +#include <qstring.h> + using namespace Opie::DB; using namespace Opie; /* * first some query @@ -148,48 +152,48 @@ namespace { QDate m_start; QDate m_end; bool m_inc :1; }; - /** - * a find query for custom elements - */ - class FindCustomQuery : public OSQLQuery { - public: - FindCustomQuery(int uid); - FindCustomQuery(const QArray<int>& ); - ~FindCustomQuery(); - QString query()const; - private: - QString single()const; - QString multi()const; - QArray<int> m_uids; - int m_uid; - }; + /** + * a find query for custom elements + */ + class FindCustomQuery : public OSQLQuery { + public: + FindCustomQuery(int uid); + FindCustomQuery(const QArray<int>& ); + ~FindCustomQuery(); + QString query()const; + private: + QString single()const; + QString multi()const; + QArray<int> m_uids; + int m_uid; + }; CreateQuery::CreateQuery() : OSQLQuery() {} CreateQuery::~CreateQuery() {} QString CreateQuery::query()const { QString qu; qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; qu += "description, summary, priority, DueDate, progress , state, "; - // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers) - qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; - qu += "reminders, alarms, maintainer, startdate, completeddate);"; - qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; + // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers) + qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; + qu += "reminders, alarms, maintainer, startdate, completeddate);"; + qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; return qu; } LoadQuery::LoadQuery() : OSQLQuery() {} LoadQuery::~LoadQuery() {} QString LoadQuery::query()const { QString qu; - // We do not need "distinct" here. The primary key is always unique.. + // We do not need "distinct" here. The primary key is always unique.. //qu += "select distinct uid from todolist"; qu += "select uid from todolist"; return qu; } @@ -210,100 +214,100 @@ namespace { year = month = day = 0; if (m_todo.hasDueDate() ) { QDate date = m_todo.dueDate(); year = date.year(); month = date.month(); day = date.day(); - } - int sYear = 0, sMonth = 0, sDay = 0; - if( m_todo.hasStartDate() ){ - QDate sDate = m_todo.startDate(); - sYear = sDate.year(); - sMonth= sDate.month(); - sDay = sDate.day(); - } - - int eYear = 0, eMonth = 0, eDay = 0; - if( m_todo.hasCompletedDate() ){ - QDate eDate = m_todo.completedDate(); - eYear = eDate.year(); - eMonth= eDate.month(); - eDay = eDate.day(); - } + } + int sYear = 0, sMonth = 0, sDay = 0; + if( m_todo.hasStartDate() ){ + QDate sDate = m_todo.startDate(); + sYear = sDate.year(); + sMonth= sDate.month(); + sDay = sDate.day(); + } + + int eYear = 0, eMonth = 0, eDay = 0; + if( m_todo.hasCompletedDate() ){ + QDate eDate = m_todo.completedDate(); + eYear = eDate.year(); + eMonth= eDate.month(); + eDay = eDate.day(); + } QString qu; - QMap<int, QString> recMap = m_todo.recurrence().toMap(); + QMap<int, QString> recMap = m_todo.recurrence().toMap(); qu = "insert into todolist VALUES(" - + QString::number( m_todo.uid() ) + "," - + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," - + QString::number( m_todo.isCompleted() ) + "," - + "'" + m_todo.description() + "'" + "," - + "'" + m_todo.summary() + "'" + "," - + QString::number(m_todo.priority() ) + "," - + "'" + QString::number(year).rightJustify( 4, '0' ) + "-" - + QString::number(month).rightJustify( 2, '0' ) - + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + "," - + QString::number( m_todo.progress() ) + "," - + QString::number( m_todo.state().state() ) + "," - + "'" + recMap[ OPimRecurrence::RType ] + "'" + "," - + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + "," - + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + "," - + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + "," - + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + "," - + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + "," - + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," - + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; - - if ( m_todo.hasNotifiers() ) { - OPimNotifyManager manager = m_todo.notifiers(); - qu += "'" + manager.remindersToString() + "'" + "," - + "'" + manager.alarmsToString() + "'" + ","; - } - else{ - qu += QString( "''" ) + "," - + "''" + ","; - } - - qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) - + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-" - + QString::number(sMonth).rightJustify( 2, '0' ) - + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + "," - + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-" - + QString::number(eMonth).rightJustify( 2, '0' ) - + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'" - + "); "; - - // Save custom Entries: - int id = 0; - id = 0; - QMap<QString, QString> customMap = m_todo.toExtraMap(); - for( QMap<QString, QString>::Iterator it = customMap.begin(); - it != customMap.end(); ++it ){ - qu += "insert into custom_data VALUES(" - + QString::number( m_todo.uid() ) - + "," - + QString::number( id++ ) - + ",'" - + it.key() - + "'," - + "0" // Priority for future enhancements - + ",'" - + it.data() - + "');"; - } - - - qDebug("add %s", qu.latin1() ); + + QString::number( m_todo.uid() ) + "," + + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," + + QString::number( m_todo.isCompleted() ) + "," + + "'" + m_todo.description() + "'" + "," + + "'" + m_todo.summary() + "'" + "," + + QString::number(m_todo.priority() ) + "," + + "'" + QString::number(year).rightJustify( 4, '0' ) + "-" + + QString::number(month).rightJustify( 2, '0' ) + + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + "," + + QString::number( m_todo.progress() ) + "," + + QString::number( m_todo.state().state() ) + "," + + "'" + recMap[ OPimRecurrence::RType ] + "'" + "," + + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + "," + + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + "," + + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + "," + + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + "," + + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + "," + + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," + + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; + + if ( m_todo.hasNotifiers() ) { + OPimNotifyManager manager = m_todo.notifiers(); + qu += "'" + manager.remindersToString() + "'" + "," + + "'" + manager.alarmsToString() + "'" + ","; + } + else{ + qu += QString( "''" ) + "," + + "''" + ","; + } + + qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) + + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-" + + QString::number(sMonth).rightJustify( 2, '0' ) + + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + "," + + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-" + + QString::number(eMonth).rightJustify( 2, '0' ) + + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'" + + "); "; + + // Save custom Entries: + int id = 0; + id = 0; + QMap<QString, QString> customMap = m_todo.toExtraMap(); + for( QMap<QString, QString>::Iterator it = customMap.begin(); + it != customMap.end(); ++it ){ + qu += "insert into custom_data VALUES(" + + QString::number( m_todo.uid() ) + + "," + + QString::number( id++ ) + + ",'" + + it.key() + + "'," + + "0" // Priority for future enhancements + + ",'" + + it.data() + + "');"; + } + + + odebug << "add " << qu << "" << oendl; return qu; } RemoveQuery::RemoveQuery(int uid ) : OSQLQuery(), m_uid( uid ) {} RemoveQuery::~RemoveQuery() {} QString RemoveQuery::query()const { QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; - qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); + qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); return qu; } ClearQuery::ClearQuery() : OSQLQuery() {} @@ -342,15 +346,15 @@ namespace { OverDueQuery::OverDueQuery(): OSQLQuery() {} OverDueQuery::~OverDueQuery() {} QString OverDueQuery::query()const { QDate date = QDate::currentDate(); QString str; str = QString("select uid from todolist where DueDate ='%1-%2-%3'") - .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) ); + .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) ); return str; } EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) @@ -359,69 +363,69 @@ namespace { QString EffQuery::query()const { return m_inc ? with() : out(); } QString EffQuery::with()const { QString str; str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") - .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); + .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); return str; } QString EffQuery::out()const { QString str; str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") - .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); + .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) ); return str; } - FindCustomQuery::FindCustomQuery(int uid) - : OSQLQuery(), m_uid( uid ) { - } - FindCustomQuery::FindCustomQuery(const QArray<int>& ints) - : OSQLQuery(), m_uids( ints ){ - } - FindCustomQuery::~FindCustomQuery() { - } - QString FindCustomQuery::query()const{ - return single(); // Multiple requests not supported ! - } - QString FindCustomQuery::single()const{ - QString qu = "select uid, type, value from custom_data where uid = "; - qu += QString::number(m_uid); - return qu; - } + FindCustomQuery::FindCustomQuery(int uid) + : OSQLQuery(), m_uid( uid ) { + } + FindCustomQuery::FindCustomQuery(const QArray<int>& ints) + : OSQLQuery(), m_uids( ints ){ + } + FindCustomQuery::~FindCustomQuery() { + } + QString FindCustomQuery::query()const{ + return single(); // Multiple requests not supported ! + } + QString FindCustomQuery::single()const{ + QString qu = "select uid, type, value from custom_data where uid = "; + qu += QString::number(m_uid); + return qu; + } }; namespace Opie { OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file ) - : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true) + : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true) { QString fi = file; if ( fi.isEmpty() ) fi = Global::applicationFileName( "todolist", "todolist.db" ); OSQLManager man; m_driver = man.standard(); m_driver->setUrl(fi); // fillDict(); } OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){ - if( m_driver ) - delete m_driver; + if( m_driver ) + delete m_driver; } bool OPimTodoAccessBackendSQL::load(){ if (!m_driver->open() ) return false; @@ -453,23 +457,23 @@ OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ return todo( m_driver->query(&query) ); } OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, uint cur, Frontend::CacheDirection dir ) const{ uint CACHE = readAhead(); - qDebug("searching for %d", uid ); + odebug << "searching for " << uid << "" << oendl; QArray<int> search( CACHE ); uint size =0; OPimTodo to; // we try to cache CACHE items switch( dir ) { /* forward */ case 0: // FIXME: Not a good style to use magic numbers here (eilers) for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { - qDebug("size %d %d", size, ints[i] ); + odebug << "size " << size << " " << ints[i] << "" << oendl; search[size] = ints[i]; size++; } break; /* reverse */ case 1: // FIXME: Not a good style to use magic numbers here (eilers) @@ -538,13 +542,13 @@ QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s, } /* * */ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, int sortFilter, int cat ) { - qDebug("sorted %d, %d", asc, sortOrder ); + odebug << "sorted " << asc << ", " << sortOrder << "" << oendl; QString query; query = "select uid from todolist WHERE "; /* * Sort Filter stuff * not that straight forward @@ -560,15 +564,15 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, /* Show only overdue */ if ( sortFilter & 2 ) { QDate date = QDate::currentDate(); QString due; QString base; base = QString("DueDate <= '%1-%2-%3' AND completed = 0") - .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) - .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) - .arg( QString::number( date.day() ).rightJustify( 2, '0' ) ); + .arg( QString::number( date.year() ).rightJustify( 4, '0' ) ) + .arg( QString::number( date.month() ).rightJustify( 2, '0' ) ) + .arg( QString::number( date.day() ).rightJustify( 2, '0' ) ); query += " " + base + " AND"; } /* not show completed */ if ( sortFilter & 4 ) { query += " completed = 0 AND"; }else{ @@ -597,17 +601,17 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, case 3: query += "DueDate"; break; } if ( !asc ) { - qDebug("not ascending!"); + odebug << "not ascending!" << oendl; query += " DESC"; } - qDebug( query ); + odebug << query << oendl; OSQLRawQuery raw(query ); return uids( m_driver->query(&raw) ); } bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ if ( str == "0-0-0" ) return false; @@ -626,53 +630,53 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ OPimTodo to; return to; } OSQLResultItem::ValueList list = res.results(); OSQLResultItem::ValueList::Iterator it = list.begin(); - qDebug("todo1"); + odebug << "todo1" << oendl; OPimTodo to = todo( (*it) ); cache( to ); ++it; for ( ; it != list.end(); ++it ) { - qDebug("caching"); + odebug << "caching" << oendl; cache( todo( (*it) ) ); } return to; } OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { - qDebug("todo(ResultItem)"); + odebug << "todo(ResultItem)" << oendl; // Request information from addressbook table and create the OPimTodo-object. bool hasDueDate = false; QDate dueDate = QDate::currentDate(); hasDueDate = date( dueDate, item.data("DueDate") ); QStringList cats = QStringList::split(";", item.data("categories") ); - qDebug("Item is completed: %d", item.data("completed").toInt() ); + odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl; OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), cats, item.data("summary"), item.data("description"), item.data("progress").toUShort(), hasDueDate, dueDate, item.data("uid").toInt() ); bool isOk; int prioInt = QString( item.data("priority") ).toInt( &isOk ); if ( isOk ) - to.setPriority( prioInt ); + to.setPriority( prioInt ); bool hasStartDate = false; QDate startDate = QDate::currentDate(); hasStartDate = date( startDate, item.data("startdate") ); bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); hasCompletedDate = date( completedDate, item.data("completeddate") ); if ( hasStartDate ) - to.setStartDate( startDate ); + to.setStartDate( startDate ); if ( hasCompletedDate ) - to.setCompletedDate( completedDate ); + to.setCompletedDate( completedDate ); OPimNotifyManager& manager = to.notifiers(); manager.alarmsFromString( item.data("alarms") ); manager.remindersFromString( item.data("reminders") ); OPimState pimState; @@ -747,13 +751,13 @@ void OPimTodoAccessBackendSQL::update()const { } QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{ OSQLResultItem::ValueList list = res.results(); OSQLResultItem::ValueList::Iterator it; QArray<int> ints(list.count() ); - qDebug(" count = %d", list.count() ); + odebug << " count = " << list.count() << "" << oendl; int i = 0; for (it = list.begin(); it != list.end(); ++it ) { ints[i] = (*it).data("uid").toInt(); i++; } @@ -761,120 +765,120 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{ } QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const { #if 0 - QArray<int> empty; - return empty; + QArray<int> empty; + return empty; #else - QString qu = "SELECT uid FROM todolist WHERE ("; + QString qu = "SELECT uid FROM todolist WHERE ("; - // Do it make sense to search other fields, too ? - qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; - qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; + // Do it make sense to search other fields, too ? + qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; + qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; - qu += ")"; + qu += ")"; - qDebug( "query: %s", qu.latin1() ); + odebug << "query: " << qu << "" << oendl; - OSQLRawQuery raw( qu ); - OSQLResult res = m_driver->query( &raw ); + OSQLRawQuery raw( qu ); + OSQLResult res = m_driver->query( &raw ); - return uids( res ); + return uids( res ); #endif } QBitArray OPimTodoAccessBackendSQL::supports()const { - return sup(); + return sup(); } QBitArray OPimTodoAccessBackendSQL::sup() const{ - QBitArray ar( OPimTodo::CompletedDate + 1 ); - ar.fill( true ); - ar[OPimTodo::CrossReference] = false; - ar[OPimTodo::State ] = false; - ar[OPimTodo::Reminders] = false; - ar[OPimTodo::Notifiers] = false; - ar[OPimTodo::Maintainer] = false; + QBitArray ar( OPimTodo::CompletedDate + 1 ); + ar.fill( true ); + ar[OPimTodo::CrossReference] = false; + ar[OPimTodo::State ] = false; + ar[OPimTodo::Reminders] = false; + ar[OPimTodo::Notifiers] = false; + ar[OPimTodo::Maintainer] = false; - return ar; + return ar; } void OPimTodoAccessBackendSQL::removeAllCompleted(){ - // First we need the uids from all entries which are - // completed. Then, we just have to remove them... + // First we need the uids from all entries which are + // completed. Then, we just have to remove them... - QString qu = "SELECT uid FROM todolist WHERE completed = 1"; + QString qu = "SELECT uid FROM todolist WHERE completed = 1"; - OSQLRawQuery raw( qu ); - OSQLResult res = m_driver->query( &raw ); + OSQLRawQuery raw( qu ); + OSQLResult res = m_driver->query( &raw ); - QArray<int> completed_uids = uids( res ); + QArray<int> completed_uids = uids( res ); - qDebug( "Number of completed: %d", completed_uids.size() ); + odebug << "Number of completed: " << completed_uids.size() << "" << oendl; - if ( completed_uids.size() == 0 ) - return; + if ( completed_uids.size() == 0 ) + return; - qu = "DELETE FROM todolist WHERE ("; - QString query; + qu = "DELETE FROM todolist WHERE ("; + QString query; - for ( int i = 0; i < completed_uids.size(); i++ ){ - if ( !query.isEmpty() ) - query += " OR "; - query += QString( "uid = %1" ).arg( completed_uids[i] ); - } - qu += query + " );"; + for ( int i = 0; i < completed_uids.size(); i++ ){ + if ( !query.isEmpty() ) + query += " OR "; + query += QString( "uid = %1" ).arg( completed_uids[i] ); + } + qu += query + " );"; - // Put remove of custom entries in this query to speed up.. - qu += "DELETE FORM custom_data WHERE ("; - query = ""; + // Put remove of custom entries in this query to speed up.. + qu += "DELETE FORM custom_data WHERE ("; + query = ""; - for ( int i = 0; i < completed_uids.size(); i++ ){ - if ( !query.isEmpty() ) - query += " OR "; - query += QString( "uid = %1" ).arg( completed_uids[i] ); - } - qu += query + " );"; + for ( int i = 0; i < completed_uids.size(); i++ ){ + if ( !query.isEmpty() ) + query += " OR "; + query += QString( "uid = %1" ).arg( completed_uids[i] ); + } + qu += query + " );"; - qDebug( "query: %s", qu.latin1() ); + odebug << "query: " << qu << "" << oendl; - OSQLRawQuery raw2( qu ); - res = m_driver->query( &raw2 ); - if ( res.state() == OSQLResult::Failure ) { - qWarning("OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: %s", qu.latin1() ); - } + OSQLRawQuery raw2( qu ); + res = m_driver->query( &raw2 ); + if ( res.state() == OSQLResult::Failure ) { + owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl; + } } QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const { - QMap<QString, QString> customMap; + QMap<QString, QString> customMap; - FindCustomQuery query( uid ); - OSQLResult res_custom = m_driver->query( &query ); + FindCustomQuery query( uid ); + OSQLResult res_custom = m_driver->query( &query ); - if ( res_custom.state() == OSQLResult::Failure ) { - qWarning("OSQLResult::Failure in find query !!"); - QMap<QString, QString> empty; - return empty; - } + if ( res_custom.state() == OSQLResult::Failure ) { + owarn << "OSQLResult::Failure in find query !!" << oendl; + QMap<QString, QString> empty; + return empty; + } - OSQLResultItem::ValueList list = res_custom.results(); - OSQLResultItem::ValueList::Iterator it = list.begin(); - for ( ; it != list.end(); ++it ) { - customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); - } + OSQLResultItem::ValueList list = res_custom.results(); + OSQLResultItem::ValueList::Iterator it = list.begin(); + for ( ; it != list.end(); ++it ) { + customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); + } - return customMap; + return customMap; } } |