All pastes #32109 Raw Edit

libopie2 Todo sorted

public text v1 · immutable
#32109 ·published 2005-12-02 16:01 UTC
rendered paste body
Index: backend/otodoaccesssql.cpp
===================================================================
RCS file: /cvs/opie/libopie2/opiepim/backend/otodoaccesssql.cpp,v
retrieving revision 1.26
diff -u -u -r1.26 otodoaccesssql.cpp
--- libopie2/opiepim/backend/otodoaccesssql.cpp	28 Dec 2004 14:19:26 -0000	1.26
+++ libopie2/opiepim/backend/otodoaccesssql.cpp	2 Dec 2005 15:35:44 -0000
@@ -34,6 +34,7 @@
 #include <opie2/osqlmanager.h>
 #include <opie2/osqlquery.h>
 
+#include <opie2/otodoaccess.h>
 #include <opie2/otodoaccesssql.h>
 #include <opie2/opimstate.h>
 #include <opie2/opimnotifymanager.h>
@@ -553,12 +554,12 @@
     return uids (m_driver->query(&ef) );
 }
 
-#if 0
+#if 1
 /*
  *
  */
-QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
-                                           int sortFilter, int cat ) {
+UIDArray OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
+                                           int sortFilter, const QArray<int>& categories ) const{
     odebug << "sorted " << asc << ", " << sortOrder << "" << oendl;
     QString query;
     query = "select uid from todolist WHERE ";
@@ -570,17 +571,17 @@
      *
      */
     /* Category */
-    if ( sortFilter & OPimTodoAccess::FilterCategory ) {
-        QString str;
-        if (cat != 0 ) str = QString::number( cat );
-        query += " categories like '%" +str+"%' AND";
-    }
+//    if ( sortFilter & OPimTodoAccess::FilterCategory ) {
+//        QString str;
+//        if (cat != 0 ) str = QString::number( cat );
+//        query += " categories like '%" +str+"%' AND";
+//    }
     /* Show only overdue */
     if ( sortFilter & OPimTodoAccess::OnlyOverDue ) {
         QDate date = QDate::currentDate();
         QString due;
         QString base;
-        base = QString("DueDate <= '%1-%2-%3' AND completed = 0")
+        base = QString("DueDate != NULL AND 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' ) );
@@ -589,9 +590,10 @@
     /* not show completed */
     if ( sortFilter & OPimTodoAccess::DoNotShowCompleted ) {
         query += " completed = 0 AND";
-    }else{
-       query += " ( completed = 1 OR  completed = 0) AND";
-    }
+	}
+//    else{
+//       query += " ( completed = 1 OR  completed = 0) AND";
+//    }
     /* strip the end */
     query = query.remove( query.length()-3, 3 );
 
@@ -603,15 +605,16 @@
     query += "ORDER BY ";
     switch( sortOrder ) {
         /* completed */
+	default:
     case OPimTodoAccess::Completed:
         query += "completed";
         break;
     case OPimTodoAccess::Priority:
         query += "priority";
         break;
-    case OPimTodoAccess::SortSummary:
-        query += "summary";
-        break;
+//    case OPimTodoAccess::SortSummary:
+//        query += "summary";
+//        break;
     case OPimTodoAccess::Deadline:
         query += "DueDate";
         break;
Index: backend/otodoaccesssql.h
===================================================================
RCS file: /cvs/opie/libopie2/opiepim/backend/otodoaccesssql.h,v
retrieving revision 1.14
diff -u -u -r1.14 otodoaccesssql.h
--- libopie2/opiepim/backend/otodoaccesssql.h	28 Dec 2004 14:19:26 -0000	1.14
+++ libopie2/opiepim/backend/otodoaccesssql.h	2 Dec 2005 15:35:44 -0000
@@ -67,6 +67,7 @@
     QArray<UID> matchRegexp(  const QRegExp &r ) const;
     void removeAllCompleted();
 
+    UIDArray sorted( bool, int, int, const QArray<int>& )const;
 
 private:
     void update()const;