summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp48
1 files changed, 26 insertions, 22 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
@@ -288,13 +292,13 @@ namespace {
+ ",'"
+ it.data()
+ "');";
}
- qDebug("add %s", qu.latin1() );
+ odebug << "add " << qu << "" << oendl;
return qu;
}
RemoveQuery::RemoveQuery(int uid )
: OSQLQuery(), m_uid( uid ) {}
RemoveQuery::~RemoveQuery() {}
@@ -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
@@ -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,33 +630,33 @@ 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() );
@@ -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++;
}
@@ -773,13 +777,13 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
// Do it make sense to search other fields, too ?
qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
qu += ")";
- qDebug( "query: %s", qu.latin1() );
+ odebug << "query: " << qu << "" << oendl;
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
return uids( res );
@@ -813,13 +817,13 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
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;
qu = "DELETE FROM todolist WHERE (";
QString query;
@@ -839,31 +843,31 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
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() );
+ owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
}
}
QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
{
QMap<QString, QString> customMap;
FindCustomQuery query( uid );
OSQLResult res_custom = m_driver->query( &query );
if ( res_custom.state() == OSQLResult::Failure ) {
- qWarning("OSQLResult::Failure in find query !!");
+ 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();