00001 #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 00002 #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 00003 00004 #include <qmap.h> 00005 #include <opie2/osqlresult.h> 00006 00007 #include "odatebookaccessbackend.h" 00008 00009 namespace Opie { namespace DB { 00010 class OSQLDriver; 00011 00012 }} 00013 00020 class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { 00021 public: 00022 ODateBookAccessBackend_SQL( const QString& appName, 00023 const QString& fileName = QString::null); 00024 ~ODateBookAccessBackend_SQL(); 00025 00026 bool load(); 00027 bool reload(); 00028 bool save(); 00029 00030 QArray<int> allRecords()const; 00031 QArray<int> matchRegexp(const QRegExp &r) const; 00032 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 00033 OEvent find( int uid )const; 00034 void clear(); 00035 bool add( const OEvent& ev ); 00036 bool remove( int uid ); 00037 bool replace( const OEvent& ev ); 00038 00039 QArray<UID> rawEvents()const; 00040 QArray<UID> rawRepeats()const; 00041 QArray<UID> nonRepeats()const; 00042 00043 OEvent::ValueList directNonRepeats(); 00044 OEvent::ValueList directRawRepeats(); 00045 00046 private: 00047 bool loadFile(); 00048 QString m_fileName; 00049 QArray<int> m_uids; 00050 00051 QMap<int, QString> m_fieldMap; 00052 QMap<QString, int> m_reverseFieldMap; 00053 00054 Opie::DB::OSQLDriver* m_driver; 00055 00056 class Private; 00057 Private *d; 00058 00059 void initFields(); 00060 void update(); 00061 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; 00062 00063 }; 00064 00065 #endif
1.4.2