summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-07 10:56:58 (UTC)
committer zecke <zecke>2002-10-07 10:56:58 (UTC)
commit198ccce69447b515876e68cf7067e70da88cfb70 (patch) (side-by-side diff)
treea6ffa0df02450ca54a778864a2f90b81091ee9ff
parent399828740380aa59273cce8ddd9cc05588e2aeac (diff)
downloadopie-198ccce69447b515876e68cf7067e70da88cfb70.zip
opie-198ccce69447b515876e68cf7067e70da88cfb70.tar.gz
opie-198ccce69447b515876e68cf7067e70da88cfb70.tar.bz2
Sorted works enough in the SQL backend let's commit it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodoaccess.h6
-rw-r--r--libopie/pim/otodoaccesssql.cpp61
-rw-r--r--libopie/pim/otodoaccesssql.h6
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp61
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h6
-rw-r--r--libopie2/opiepim/core/otodoaccess.h6
6 files changed, 130 insertions, 16 deletions
diff --git a/libopie/pim/otodoaccess.h b/libopie/pim/otodoaccess.h
index 12997aa..390ab0e 100644
--- a/libopie/pim/otodoaccess.h
+++ b/libopie/pim/otodoaccess.h
@@ -21,9 +21,9 @@ public:
Priority,
Description,
Deadline };
- enum SortFilter{ ShowOverdue = 0,
- Category =1,
- OnlyOverDue= 2 };
+ enum SortFilter{ Category =1,
+ OnlyOverDue= 2,
+ DoNotShowCompleted =4 };
/**
* if you use 0l
* the default resource will be
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index 209e714..25536e0 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -308,10 +308,67 @@ QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s,
EffQuery ef(s, t, u );
return uids (m_driver->query(&ef) );
}
+/*
+ *
+ */
QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
- QArray<int> ints(0);
- return ints;
+ QString query;
+ query = "select uid from todolist WHERE ";
+
+ /*
+ * Sort Filter stuff
+ * not that straight forward
+ *
+ */
+ /* Category */
+ if ( sortFilter & 1 ) {
+ query += " categories like '%" +QString::number(cat)+"%' AND";
+ }
+ /* Show only overdue */
+ if ( sortFilter & 2 ) {
+ QDate date = QDate::currentDate();
+ QString due;
+ QString base;
+ base = QString("DueDate <= '%1-%2-%3' AND WHERE completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() );
+ query += " " + base + " AND";
+ }
+ /* not show completed */
+ if ( sortFilter & 4 ) {
+ query += " completed = 0 AND";
+ }else{
+ query += " ( completed = 1 OR completed = 0) AND";
+ }
+ /* srtip the end */
+ query = query.remove( query.length()-3, 3 );
+
+
+ /*
+ * sort order stuff
+ * quite straight forward
+ */
+ query += "ORDER BY ";
+ switch( sortOrder ) {
+ /* completed */
+ case 0:
+ query += "completed";
+ break;
+ case 1:
+ query += "priority";
+ break;
+ case 2:
+ query += "description";
+ break;
+ case 3:
+ query += "DueDate";
+ break;
+ }
+ if ( !asc )
+ query += " DESC";
+
+ qWarning( query );
+ OSQLRawQuery raw(query );
+ return uids( m_driver->query(&raw) );
}
bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
if ( str == "0-0-0" )
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h
index 966628d..6c5f50a 100644
--- a/libopie/pim/otodoaccesssql.h
+++ b/libopie/pim/otodoaccesssql.h
@@ -32,9 +32,9 @@ public:
private:
void update();
void fillDict();
- bool date( QDate& date, const QString& )const;
- OTodo todo( const OSQLResult& )const;
- QArray<int> uids( const OSQLResult& )const;
+ inline bool date( QDate& date, const QString& )const;
+ inline OTodo todo( const OSQLResult& )const;
+ inline QArray<int> uids( const OSQLResult& )const;
OTodo todo( int uid )const;
QAsciiDict<int> m_dict;
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 209e714..25536e0 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -308,10 +308,67 @@ QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s,
EffQuery ef(s, t, u );
return uids (m_driver->query(&ef) );
}
+/*
+ *
+ */
QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
- QArray<int> ints(0);
- return ints;
+ QString query;
+ query = "select uid from todolist WHERE ";
+
+ /*
+ * Sort Filter stuff
+ * not that straight forward
+ *
+ */
+ /* Category */
+ if ( sortFilter & 1 ) {
+ query += " categories like '%" +QString::number(cat)+"%' AND";
+ }
+ /* Show only overdue */
+ if ( sortFilter & 2 ) {
+ QDate date = QDate::currentDate();
+ QString due;
+ QString base;
+ base = QString("DueDate <= '%1-%2-%3' AND WHERE completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() );
+ query += " " + base + " AND";
+ }
+ /* not show completed */
+ if ( sortFilter & 4 ) {
+ query += " completed = 0 AND";
+ }else{
+ query += " ( completed = 1 OR completed = 0) AND";
+ }
+ /* srtip the end */
+ query = query.remove( query.length()-3, 3 );
+
+
+ /*
+ * sort order stuff
+ * quite straight forward
+ */
+ query += "ORDER BY ";
+ switch( sortOrder ) {
+ /* completed */
+ case 0:
+ query += "completed";
+ break;
+ case 1:
+ query += "priority";
+ break;
+ case 2:
+ query += "description";
+ break;
+ case 3:
+ query += "DueDate";
+ break;
+ }
+ if ( !asc )
+ query += " DESC";
+
+ qWarning( query );
+ OSQLRawQuery raw(query );
+ return uids( m_driver->query(&raw) );
}
bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
if ( str == "0-0-0" )
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 966628d..6c5f50a 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -32,9 +32,9 @@ public:
private:
void update();
void fillDict();
- bool date( QDate& date, const QString& )const;
- OTodo todo( const OSQLResult& )const;
- QArray<int> uids( const OSQLResult& )const;
+ inline bool date( QDate& date, const QString& )const;
+ inline OTodo todo( const OSQLResult& )const;
+ inline QArray<int> uids( const OSQLResult& )const;
OTodo todo( int uid )const;
QAsciiDict<int> m_dict;
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h
index 12997aa..390ab0e 100644
--- a/libopie2/opiepim/core/otodoaccess.h
+++ b/libopie2/opiepim/core/otodoaccess.h
@@ -21,9 +21,9 @@ public:
Priority,
Description,
Deadline };
- enum SortFilter{ ShowOverdue = 0,
- Category =1,
- OnlyOverDue= 2 };
+ enum SortFilter{ Category =1,
+ OnlyOverDue= 2,
+ DoNotShowCompleted =4 };
/**
* if you use 0l
* the default resource will be