Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h new file mode 100644 index 0000000..bb22551 --- a/dev/null +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * SQL Backend for the OPIE-Contact Database. | ||
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * | ||
13 | * | ||
14 | * ===================================================================== | ||
15 | * Version: $Id$ | ||
16 | * ===================================================================== | ||
17 | * History: | ||
18 | * $Log$ | ||
19 | * Revision 1.1 2003/09/22 14:31:16 eilers | ||
20 | * Added first experimental incarnation of sql-backend for addressbook. | ||
21 | * Some modifications to be able to compile the todo sql-backend. | ||
22 | * A lot of changes fill follow... | ||
23 | * | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef _OContactAccessBackend_SQL_ | ||
28 | #define _OContactAccessBackend_SQL_ | ||
29 | |||
30 | #include "ocontactaccessbackend.h" | ||
31 | #include "ocontactaccess.h" | ||
32 | |||
33 | #include <qlist.h> | ||
34 | #include <qdict.h> | ||
35 | |||
36 | class OSQLDriver; | ||
37 | class OSQLResult; | ||
38 | class OSQLResultItem; | ||
39 | |||
40 | /* the default xml implementation */ | ||
41 | /** | ||
42 | * This class is the SQL implementation of a Contact backend | ||
43 | * it does implement everything available for OContact. | ||
44 | * @see OPimAccessBackend for more information of available methods | ||
45 | */ | ||
46 | class OContactAccessBackend_SQL : public OContactAccessBackend { | ||
47 | public: | ||
48 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); | ||
49 | |||
50 | bool save(); | ||
51 | |||
52 | bool load (); | ||
53 | |||
54 | void clear (); | ||
55 | |||
56 | bool wasChangedExternally(); | ||
57 | |||
58 | QArray<int> allRecords() const; | ||
59 | |||
60 | OContact find ( int uid ) const; | ||
61 | // FIXME: Add lookahead-cache support ! | ||
62 | //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | ||
63 | |||
64 | QArray<int> queryByExample ( const OContact &query, int settings, | ||
65 | const QDateTime& d ); | ||
66 | |||
67 | QArray<int> matchRegexp( const QRegExp &r ) const; | ||
68 | |||
69 | const uint querySettings(); | ||
70 | |||
71 | bool hasQuerySettings (uint querySettings) const; | ||
72 | |||
73 | // Currently only asc implemented.. | ||
74 | QArray<int> sorted( bool asc, int , int , int ); | ||
75 | bool add ( const OContact &newcontact ); | ||
76 | |||
77 | bool replace ( const OContact &contact ); | ||
78 | |||
79 | bool remove ( int uid ); | ||
80 | bool reload(); | ||
81 | |||
82 | private: | ||
83 | QArray<int> extractUids( OSQLResult& res ) const; | ||
84 | QMap<int, QString> requestNonCustom( int uid ) const; | ||
85 | QMap<QString, QString> requestCustom( int uid ) const; | ||
86 | void update(); | ||
87 | |||
88 | protected: | ||
89 | bool m_changed; | ||
90 | QString m_fileName; | ||
91 | QArray<int> m_uids; | ||
92 | |||
93 | OSQLDriver* m_driver; | ||
94 | }; | ||
95 | |||
96 | #endif | ||