author | eilers <eilers> | 2003-09-22 14:31:15 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-09-22 14:31:15 (UTC) |
commit | 34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56 (patch) (side-by-side diff) | |
tree | cee19bfcf7c8d6a24cd4aaf578bd64b38b2d0ee4 /libopie/pim/otodoaccesssql.cpp | |
parent | fd500184450e37c239e573adf1c12a6ff62b65f6 (diff) | |
download | opie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.zip opie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.tar.gz opie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.tar.bz2 |
Added first experimental incarnation of sql-backend for addressbook.
Some modifications to be able to compile the todo sql-backend.
A lot of changes fill follow...
Diffstat (limited to 'libopie/pim/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 73 |
1 files changed, 63 insertions, 10 deletions
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index ec9c14c..23e0c3e 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp @@ -1,17 +1,17 @@ #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 @@ -244,17 +244,17 @@ 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; @@ -292,25 +292,25 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 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 ); @@ -376,16 +376,17 @@ 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"; } @@ -487,33 +488,34 @@ OTodo OTodoAccessBackendSQL::todo( int uid )const { } /* * 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; @@ -533,8 +535,59 @@ QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ 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 !! + +} |