summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp52
1 files changed, 34 insertions, 18 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index d255c66..ebd03bb 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -6,12 +6,15 @@
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
#include "otodoaccesssql.h"
+#include "opimstate.h"
+#include "opimnotifymanager.h"
+#include "orecur.h"
/*
* first some query
* CREATE query
* LOAD query
* INSERT
@@ -117,13 +120,14 @@ namespace {
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, ";
- qu += "Recurrence, notifiers, maintainer, startdate, completeddate)";
+ qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);";
+ qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
return qu;
}
LoadQuery::LoadQuery() : OSQLQuery() {}
LoadQuery::~LoadQuery() {}
QString LoadQuery::query()const {
@@ -178,20 +182,29 @@ namespace {
+ "'" + m_todo.summary() + "'" + ","
+ QString::number(m_todo.priority() ) + ","
+ "'" + QString::number(year) + "-"
+ QString::number(month)
+ "-" + QString::number( day ) + "'" + ","
+ QString::number( m_todo.progress() ) + ","
- + "''" + "," // state (conversion needed)
-// + QString::number( m_todo.state() ) + ","
- + "''" + "," // Recurrence (conversion needed)
- + "''" + "," // Notifiers (conversion needed)
- + "''" + "," // Maintainers (conversion needed)
+ + QString::number( m_todo.state().state() ) + ","
+ + "'" + m_todo.recurrence().toString() + "'"+ ",";
+
+ 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) + "-"
- + QString::number(sMonth)
- + "-" + QString::number(sDay) + "'" + ","
+ + QString::number(sMonth)
+ + "-" + QString::number(sDay) + "'" + ","
+ "'" + QString::number(eYear) + "-"
+ QString::number(eMonth)
+ "-"+QString::number(eDay) + "'"
+ ")";
qWarning("add %s", qu.latin1() );
@@ -527,12 +540,23 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
hasCompletedDate = date( completedDate, item.data("completeddate") );
if ( hasStartDate )
to.setStartDate( startDate );
if ( hasCompletedDate )
to.setCompletedDate( completedDate );
+
+ OPimNotifyManager& manager = to.notifiers();
+ manager.alarmsFromString( item.data("alarms") );
+ manager.remindersFromString( item.data("reminders") );
+
+ OPimState pimState;
+ pimState.setState( QString( item.data("state") ).toInt() );
+ to.setState( pimState );
+
+ // Recurrence not supported yet
+ // to.setRecurrence(
return to;
}
OTodo OTodoAccessBackendSQL::todo( int uid )const {
FindQuery find( uid );
return todo( m_driver->query(&find) );
@@ -618,24 +642,16 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
#endif
QArray<int> empty;
return empty;
}
QBitArray OTodoAccessBackendSQL::supports()const {
- QBitArray ar( OTodo::CompletedDate + 1 );
- ar.fill( true );
- ar[OTodo::CrossReference] = false;
- ar[OTodo::State ] = false;
- ar[OTodo::Reminders] = false;
- ar[OTodo::Notifiers] = false;
- ar[OTodo::Maintainer] = false;
-
- return ar;
+ return sup();
}
-QBitArray OTodoAccessBackendSQL::sup() {
+QBitArray OTodoAccessBackendSQL::sup() const{
QBitArray ar( OTodo::CompletedDate + 1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;