00001 #ifndef OPIE_PIM_ACCESS_SQL_H
00002 #define OPIE_PIM_ACCESS_SQL_H
00003
00004 #include <qasciidict.h>
00005
00006 #include "otodoaccessbackend.h"
00007
00008 namespace Opie{
00009 namespace DB {
00010 class OSQLDriver;
00011 class OSQLResult;
00012 class OSQLResultItem;
00013 }
00014 }
00015
00016 class OTodoAccessBackendSQL : public OTodoAccessBackend {
00017 public:
00018 OTodoAccessBackendSQL( const QString& file );
00019 ~OTodoAccessBackendSQL();
00020
00021 bool load();
00022 bool reload();
00023 bool save();
00024 QArray<int> allRecords()const;
00025
00026 QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() );
00027 OTodo find(int uid)const;
00028 OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
00029 void clear();
00030 bool add( const OTodo& t );
00031 bool remove( int uid );
00032 bool replace( const OTodo& t );
00033
00034 QArray<int> overDue();
00035 QArray<int> effectiveToDos( const QDate& start,
00036 const QDate& end, bool includeNoDates );
00037 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
00038
00039 QBitArray supports()const;
00040 QArray<int> matchRegexp( const QRegExp &r ) const;
00041 void removeAllCompleted();
00042
00043
00044 private:
00045 void update()const;
00046 void fillDict();
00047 inline bool date( QDate& date, const QString& )const;
00048 inline OTodo todo( const Opie::DB::OSQLResult& )const;
00049 inline OTodo todo( Opie::DB::OSQLResultItem& )const;
00050 inline QArray<int> uids( const Opie::DB::OSQLResult& )const;
00051 OTodo todo( int uid )const;
00052 QBitArray sup() const;
00053
00054 QAsciiDict<int> m_dict;
00055 Opie::DB::OSQLDriver* m_driver;
00056 QArray<int> m_uids;
00057 bool m_dirty : 1;
00058 };
00059
00060
00061 #endif