00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _OPimContactAccessBackend_SQL_
00034 #define _OPimContactAccessBackend_SQL_
00035
00036 #include <opie2/ocontactaccessbackend.h>
00037 #include <opie2/ocontactaccess.h>
00038
00039 #include <qlist.h>
00040 #include <qdict.h>
00041
00042
00043 namespace Opie {
00044 namespace DB {
00045 class OSQLDriver;
00046 class OSQLResult;
00047 class OSQLResultItem;
00048 }
00049 }
00050
00051 namespace Opie {
00052
00053
00059 class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
00060 public:
00061 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
00062
00063 ~OPimContactAccessBackend_SQL ();
00064
00065 bool save();
00066
00067 bool load ();
00068
00069 void clear ();
00070
00071 bool wasChangedExternally();
00072
00073 UIDArray allRecords() const;
00074
00075 OPimContact find( int uid ) const;
00076 OPimContact find( int uid, const UIDArray& items, uint cur, Frontend::CacheDirection ) const;
00077
00078 UIDArray queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
00079 const QDateTime& d ) const;
00080
00081 UIDArray matchRegexp( const QRegExp &r ) const;
00082
00083 const uint querySettings() const;
00084
00085 bool hasQuerySettings (uint querySettings) const;
00086
00087 UIDArray sorted( const UIDArray& ar, bool asc, int sortOrder,
00088 int filter, const QArray<int>& categories)const;
00089
00090 bool add ( const OPimContact &newcontact );
00091
00092 bool replace ( const OPimContact &contact );
00093
00094 bool remove ( int uid );
00095 bool reload();
00096
00097 private:
00098 UIDArray extractUids( Opie::DB::OSQLResult& res ) const;
00099 QMap<int, QString> requestNonCustom( int uid ) const;
00100 QMap<QString, QString> requestCustom( int uid ) const;
00101 QMap<int, QString> fillNonCustomMap( const Opie::DB::OSQLResultItem& resultItem ) const;
00102 OPimContact requestContactsAndCache( int uid, const QArray<int>& cachelist ) const;
00103 void update();
00104
00105 protected:
00106 bool m_changed;
00107 QString m_fileName;
00108 UIDArray m_uids;
00109
00110 Opie::DB::OSQLDriver* m_driver;
00111 };
00112
00113 }
00114
00115 #endif