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.cpp73
1 files changed, 63 insertions, 10 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index ec9c14c..23e0c3e 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -1,21 +1,21 @@
#include <qdatetime.h>
#include <qpe/global.h>
-#include <opie/osqldriver.h>
-#include <opie/osqlresult.h>
-#include <opie/osqlmanager.h>
-#include <opie/osqlquery.h>
+#include <opie2/osqldriver.h>
+#include <opie2/osqlresult.h>
+#include <opie2/osqlmanager.h>
+#include <opie2/osqlquery.h>
#include "otodoaccesssql.h"
/*
* first some query
* CREATE query
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
namespace {
@@ -240,25 +240,25 @@ namespace {
}
};
OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file )
: OTodoAccessBackend(), m_dict(15), 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();
+ // fillDict();
}
OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){
}
bool OTodoAccessBackendSQL::load(){
if (!m_driver->open() )
return false;
CreateQuery creat;
OSQLResult res = m_driver->query(&creat );
m_dirty = true;
@@ -288,33 +288,33 @@ OTodo OTodoAccessBackendSQL::find(int uid ) const{
}
OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
uint cur, Frontend::CacheDirection dir ) const{
int CACHE = readAhead();
qWarning("searching for %d", uid );
QArray<int> search( CACHE );
uint size =0;
OTodo to;
// we try to cache CACHE items
switch( dir ) {
/* forward */
- case 0:
+ case 0: // FIXME: Not a good style to use magic numbers here (eilers)
for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
qWarning("size %d %d", size, ints[i] );
search[size] = ints[i];
size++;
}
break;
/* reverse */
- case 1:
+ case 1: // FIXME: Not a good style to use magic numbers here (eilers)
for (uint i = cur; i != 0 && size < CACHE; i-- ) {
search[size] = ints[i];
size++;
}
break;
}
search.resize( size );
FindQuery query( search );
OSQLResult res = m_driver->query( &query );
if ( res.state() != OSQLResult::Success )
return to;
@@ -372,24 +372,25 @@ QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s,
/*
*
*/
QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
qWarning("sorted %d, %d", asc, sortOrder );
QString query;
query = "select uid from todolist WHERE ";
/*
* Sort Filter stuff
* not that straight forward
+ * FIXME: Replace magic numbers
*
*/
/* Category */
if ( sortFilter & 1 ) {
QString str;
if (cat != 0 ) str = QString::number( cat );
query += " categories like '%" +str+"%' AND";
}
/* Show only overdue */
if ( sortFilter & 2 ) {
QDate date = QDate::currentDate();
QString due;
@@ -483,41 +484,42 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
}
OTodo OTodoAccessBackendSQL::todo( int uid )const {
FindQuery find( uid );
return todo( m_driver->query(&find) );
}
/*
* update the dict
*/
void OTodoAccessBackendSQL::fillDict() {
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
+ * FIXME: Isn't this dict obsolete ? (eilers)
*/
m_dict.setAutoDelete( TRUE );
m_dict.insert("Categories" , new int(OTodo::Category) );
m_dict.insert("Uid" , new int(OTodo::Uid) );
m_dict.insert("HasDate" , new int(OTodo::HasDate) );
m_dict.insert("Completed" , new int(OTodo::Completed) );
m_dict.insert("Description" , new int(OTodo::Description) );
m_dict.insert("Summary" , new int(OTodo::Summary) );
m_dict.insert("Priority" , new int(OTodo::Priority) );
m_dict.insert("DateDay" , new int(OTodo::DateDay) );
m_dict.insert("DateMonth" , new int(OTodo::DateMonth) );
m_dict.insert("DateYear" , new int(OTodo::DateYear) );
m_dict.insert("Progress" , new int(OTodo::Progress) );
- m_dict.insert("Completed", new int(OTodo::Completed) );
+ m_dict.insert("Completed", new int(OTodo::Completed) ); // Why twice ? (eilers)
m_dict.insert("CrossReference", new int(OTodo::CrossReference) );
- m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
- m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
+// m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); // old stuff (eilers)
+// m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); // old stuff (eilers)
}
/*
* need to be const so let's fool the
* compiler :(
*/
void OTodoAccessBackendSQL::update()const {
((OTodoAccessBackendSQL*)this)->m_dirty = false;
LoadQuery lo;
OSQLResult res = m_driver->query(&lo);
if ( res.state() != OSQLResult::Success )
return;
@@ -529,12 +531,63 @@ QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{
OSQLResultItem::ValueList::Iterator it;
QArray<int> ints(list.count() );
qWarning(" count = %d", list.count() );
int i = 0;
for (it = list.begin(); it != list.end(); ++it ) {
ints[i] = (*it).data("uid").toInt();
i++;
}
return ints;
}
+QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
+{
+
+#warning OTodoAccessBackendSQL::matchRegexp() not implemented !!
+
+#if 0
+
+ Copied from xml-backend by not adapted to sql (eilers)
+
+ QArray<int> m_currentQuery( m_events.count() );
+ uint arraycounter = 0;
+
+
+
+ QMap<int, OTodo>::ConstIterator it;
+ for (it = m_events.begin(); it != m_events.end(); ++it ) {
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+
+ }
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
+#endif
+ QArray<int> empty;
+ return empty;
+}
+QBitArray OTodoAccessBackendSQL::supports()const {
+
+ static QBitArray ar = sup();
+ return ar;
+}
+
+QBitArray OTodoAccessBackendSQL::sup() {
+
+ 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;
+}
+
+void OTodoAccessBackendSQL::removeAllCompleted(){
+#warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !!
+
+}