ocontactaccessbackend_sql.h
Go to the documentation of this file.00001 /* 00002 * SQL Backend for the OPIE-Contact Database. 00003 * 00004 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 00005 * 00006 * ===================================================================== 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * ===================================================================== 00012 * 00013 * 00014 * ===================================================================== 00015 * Version: $Id: ocontactaccessbackend_sql.h,v 1.2 2003/12/08 15:18:11 eilers Exp $ 00016 * ===================================================================== 00017 * History: 00018 * $Log: ocontactaccessbackend_sql.h,v $ 00019 * Revision 1.2 2003/12/08 15:18:11 eilers 00020 * Committing unfinished sql implementation before merging to libopie2 starts.. 00021 * 00022 * Revision 1.1 2003/09/22 14:31:16 eilers 00023 * Added first experimental incarnation of sql-backend for addressbook. 00024 * Some modifications to be able to compile the todo sql-backend. 00025 * A lot of changes fill follow... 00026 * 00027 * 00028 */ 00029 00030 #ifndef _OContactAccessBackend_SQL_ 00031 #define _OContactAccessBackend_SQL_ 00032 00033 #include "ocontactaccessbackend.h" 00034 #include "ocontactaccess.h" 00035 00036 #include <qlist.h> 00037 #include <qdict.h> 00038 00039 class OSQLDriver; 00040 class OSQLResult; 00041 class OSQLResultItem; 00042 00043 /* the default xml implementation */ 00049 class OContactAccessBackend_SQL : public OContactAccessBackend { 00050 public: 00051 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 00052 00053 ~OContactAccessBackend_SQL (); 00054 00055 bool save(); 00056 00057 bool load (); 00058 00059 void clear (); 00060 00061 bool wasChangedExternally(); 00062 00063 QArray<int> allRecords() const; 00064 00065 OContact find ( int uid ) const; 00066 // FIXME: Add lookahead-cache support ! 00067 //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 00068 00069 QArray<int> queryByExample ( const OContact &query, int settings, 00070 const QDateTime& d ); 00071 00072 QArray<int> matchRegexp( const QRegExp &r ) const; 00073 00074 const uint querySettings(); 00075 00076 bool hasQuerySettings (uint querySettings) const; 00077 00078 // Currently only asc implemented.. 00079 QArray<int> sorted( bool asc, int , int , int ); 00080 bool add ( const OContact &newcontact ); 00081 00082 bool replace ( const OContact &contact ); 00083 00084 bool remove ( int uid ); 00085 bool reload(); 00086 00087 private: 00088 QArray<int> extractUids( OSQLResult& res ) const; 00089 QMap<int, QString> requestNonCustom( int uid ) const; 00090 QMap<QString, QString> requestCustom( int uid ) const; 00091 void update(); 00092 00093 protected: 00094 bool m_changed; 00095 QString m_fileName; 00096 QArray<int> m_uids; 00097 00098 OSQLDriver* m_driver; 00099 }; 00100 00101 #endif
