author | alwin <alwin> | 2004-03-14 13:50:35 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-14 13:50:35 (UTC) |
commit | 346288b5a95b72a84fabe9acb2e32aa8a8388c8c (patch) (unidiff) | |
tree | dd8a5e79020d05452d8568d626e77fed7d0f4e74 | |
parent | 0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44 (diff) | |
download | opie-346288b5a95b72a84fabe9acb2e32aa8a8388c8c.zip opie-346288b5a95b72a84fabe9acb2e32aa8a8388c8c.tar.gz opie-346288b5a95b72a84fabe9acb2e32aa8a8388c8c.tar.bz2 |
namespace correction
-rw-r--r-- | libopie/pim/ocontactaccessbackend_sql.cpp | 5 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_sql.h | 10 | ||||
-rw-r--r-- | libopie/pim/odatebookaccessbackend_sql.cpp | 4 | ||||
-rw-r--r-- | libopie/pim/odatebookaccessbackend_sql.h | 7 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 1 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.h | 13 |
6 files changed, 31 insertions, 9 deletions
diff --git a/libopie/pim/ocontactaccessbackend_sql.cpp b/libopie/pim/ocontactaccessbackend_sql.cpp index a5be4c8..d20df56 100644 --- a/libopie/pim/ocontactaccessbackend_sql.cpp +++ b/libopie/pim/ocontactaccessbackend_sql.cpp | |||
@@ -1,252 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | * SQL Backend for the OPIE-Contact Database. | 2 | * SQL Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * Version: $Id$ | 13 | * Version: $Id$ |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * History: | 15 | * History: |
16 | * $Log$ | 16 | * $Log$ |
17 | * Revision 1.5 2004/03/14 13:50:35 alwin | ||
18 | * namespace correction | ||
19 | * | ||
17 | * Revision 1.4 2003/12/22 10:19:26 eilers | 20 | * Revision 1.4 2003/12/22 10:19:26 eilers |
18 | * Finishing implementation of sql-backend for datebook. But I have to | 21 | * Finishing implementation of sql-backend for datebook. But I have to |
19 | * port the PIM datebook application to use it, before I could debug the | 22 | * port the PIM datebook application to use it, before I could debug the |
20 | * whole stuff. | 23 | * whole stuff. |
21 | * Thus, PIM-Database backend is finished, but highly experimental. And some | 24 | * Thus, PIM-Database backend is finished, but highly experimental. And some |
22 | * parts are still generic. For instance, the "queryByExample()" methods are | 25 | * parts are still generic. For instance, the "queryByExample()" methods are |
23 | * not (or not fully) implemented. Todo: custom-entries not stored. | 26 | * not (or not fully) implemented. Todo: custom-entries not stored. |
24 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | 27 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular |
25 | * expression search in the database, which is not supported by sqlite ! | 28 | * expression search in the database, which is not supported by sqlite ! |
26 | * Therefore we need either an extended sqlite or a workaround which would | 29 | * Therefore we need either an extended sqlite or a workaround which would |
27 | * be very slow and memory consuming.. | 30 | * be very slow and memory consuming.. |
28 | * | 31 | * |
29 | * Revision 1.3 2003/12/08 15:18:10 eilers | 32 | * Revision 1.3 2003/12/08 15:18:10 eilers |
30 | * Committing unfinished sql implementation before merging to libopie2 starts.. | 33 | * Committing unfinished sql implementation before merging to libopie2 starts.. |
31 | * | 34 | * |
32 | * Revision 1.2 2003/09/29 07:44:26 eilers | 35 | * Revision 1.2 2003/09/29 07:44:26 eilers |
33 | * Improvement of PIM-SQL Databases, but search queries are still limited. | 36 | * Improvement of PIM-SQL Databases, but search queries are still limited. |
34 | * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space. | 37 | * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space. |
35 | * Todo: Started to add new attributes. Some type conversions missing. | 38 | * Todo: Started to add new attributes. Some type conversions missing. |
36 | * | 39 | * |
37 | * Revision 1.1 2003/09/22 14:31:16 eilers | 40 | * Revision 1.1 2003/09/22 14:31:16 eilers |
38 | * Added first experimental incarnation of sql-backend for addressbook. | 41 | * Added first experimental incarnation of sql-backend for addressbook. |
39 | * Some modifications to be able to compile the todo sql-backend. | 42 | * Some modifications to be able to compile the todo sql-backend. |
40 | * A lot of changes fill follow... | 43 | * A lot of changes fill follow... |
41 | * | 44 | * |
42 | */ | 45 | */ |
43 | 46 | ||
44 | #include "ocontactaccessbackend_sql.h" | 47 | #include "ocontactaccessbackend_sql.h" |
45 | 48 | ||
46 | #include <qarray.h> | 49 | #include <qarray.h> |
47 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
48 | #include <qstringlist.h> | 51 | #include <qstringlist.h> |
49 | 52 | ||
50 | #include <qpe/global.h> | 53 | #include <qpe/global.h> |
51 | #include <qpe/recordfields.h> | 54 | #include <qpe/recordfields.h> |
52 | 55 | ||
53 | #include <opie/ocontactfields.h> | 56 | #include <opie/ocontactfields.h> |
54 | #include <opie/oconversion.h> | 57 | #include <opie/oconversion.h> |
55 | #include <opie2/osqldriver.h> | 58 | #include <opie2/osqldriver.h> |
56 | #include <opie2/osqlresult.h> | 59 | #include <opie2/osqlresult.h> |
57 | #include <opie2/osqlmanager.h> | 60 | #include <opie2/osqlmanager.h> |
58 | #include <opie2/osqlquery.h> | 61 | #include <opie2/osqlquery.h> |
59 | 62 | ||
60 | 63 | using namespace Opie::DB; | |
61 | 64 | ||
62 | 65 | ||
63 | // If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead | 66 | // If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead |
64 | // vertical like "uid, type, value". | 67 | // vertical like "uid, type, value". |
65 | // DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! | 68 | // DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! |
66 | #define __STORE_HORIZONTAL_ | 69 | #define __STORE_HORIZONTAL_ |
67 | 70 | ||
68 | // Distinct loading is not very fast. If I expect that every person has just | 71 | // Distinct loading is not very fast. If I expect that every person has just |
69 | // one (and always one) 'Last Name', I can request all uid's for existing lastnames, | 72 | // one (and always one) 'Last Name', I can request all uid's for existing lastnames, |
70 | // which is faster.. | 73 | // which is faster.. |
71 | // But this may not be true for all entries, like company contacts.. | 74 | // But this may not be true for all entries, like company contacts.. |
72 | // The current AddressBook application handles this problem, but other may not.. (eilers) | 75 | // The current AddressBook application handles this problem, but other may not.. (eilers) |
73 | #define __USE_SUPERFAST_LOADQUERY | 76 | #define __USE_SUPERFAST_LOADQUERY |
74 | 77 | ||
75 | 78 | ||
76 | /* | 79 | /* |
77 | * Implementation of used query types | 80 | * Implementation of used query types |
78 | * CREATE query | 81 | * CREATE query |
79 | * LOAD query | 82 | * LOAD query |
80 | * INSERT | 83 | * INSERT |
81 | * REMOVE | 84 | * REMOVE |
82 | * CLEAR | 85 | * CLEAR |
83 | */ | 86 | */ |
84 | namespace { | 87 | namespace { |
85 | /** | 88 | /** |
86 | * CreateQuery for the Todolist Table | 89 | * CreateQuery for the Todolist Table |
87 | */ | 90 | */ |
88 | class CreateQuery : public OSQLQuery { | 91 | class CreateQuery : public OSQLQuery { |
89 | public: | 92 | public: |
90 | CreateQuery(); | 93 | CreateQuery(); |
91 | ~CreateQuery(); | 94 | ~CreateQuery(); |
92 | QString query()const; | 95 | QString query()const; |
93 | }; | 96 | }; |
94 | 97 | ||
95 | /** | 98 | /** |
96 | * Clears (delete) a Table | 99 | * Clears (delete) a Table |
97 | */ | 100 | */ |
98 | class ClearQuery : public OSQLQuery { | 101 | class ClearQuery : public OSQLQuery { |
99 | public: | 102 | public: |
100 | ClearQuery(); | 103 | ClearQuery(); |
101 | ~ClearQuery(); | 104 | ~ClearQuery(); |
102 | QString query()const; | 105 | QString query()const; |
103 | 106 | ||
104 | }; | 107 | }; |
105 | 108 | ||
106 | 109 | ||
107 | /** | 110 | /** |
108 | * LoadQuery | 111 | * LoadQuery |
109 | * this one queries for all uids | 112 | * this one queries for all uids |
110 | */ | 113 | */ |
111 | class LoadQuery : public OSQLQuery { | 114 | class LoadQuery : public OSQLQuery { |
112 | public: | 115 | public: |
113 | LoadQuery(); | 116 | LoadQuery(); |
114 | ~LoadQuery(); | 117 | ~LoadQuery(); |
115 | QString query()const; | 118 | QString query()const; |
116 | }; | 119 | }; |
117 | 120 | ||
118 | /** | 121 | /** |
119 | * inserts/adds a OContact to the table | 122 | * inserts/adds a OContact to the table |
120 | */ | 123 | */ |
121 | class InsertQuery : public OSQLQuery { | 124 | class InsertQuery : public OSQLQuery { |
122 | public: | 125 | public: |
123 | InsertQuery(const OContact& ); | 126 | InsertQuery(const OContact& ); |
124 | ~InsertQuery(); | 127 | ~InsertQuery(); |
125 | QString query()const; | 128 | QString query()const; |
126 | private: | 129 | private: |
127 | OContact m_contact; | 130 | OContact m_contact; |
128 | }; | 131 | }; |
129 | 132 | ||
130 | 133 | ||
131 | /** | 134 | /** |
132 | * removes one from the table | 135 | * removes one from the table |
133 | */ | 136 | */ |
134 | class RemoveQuery : public OSQLQuery { | 137 | class RemoveQuery : public OSQLQuery { |
135 | public: | 138 | public: |
136 | RemoveQuery(int uid ); | 139 | RemoveQuery(int uid ); |
137 | ~RemoveQuery(); | 140 | ~RemoveQuery(); |
138 | QString query()const; | 141 | QString query()const; |
139 | private: | 142 | private: |
140 | int m_uid; | 143 | int m_uid; |
141 | }; | 144 | }; |
142 | 145 | ||
143 | /** | 146 | /** |
144 | * a find query for noncustom elements | 147 | * a find query for noncustom elements |
145 | */ | 148 | */ |
146 | class FindQuery : public OSQLQuery { | 149 | class FindQuery : public OSQLQuery { |
147 | public: | 150 | public: |
148 | FindQuery(int uid); | 151 | FindQuery(int uid); |
149 | FindQuery(const QArray<int>& ); | 152 | FindQuery(const QArray<int>& ); |
150 | ~FindQuery(); | 153 | ~FindQuery(); |
151 | QString query()const; | 154 | QString query()const; |
152 | private: | 155 | private: |
153 | QString single()const; | 156 | QString single()const; |
154 | QString multi()const; | 157 | QString multi()const; |
155 | QArray<int> m_uids; | 158 | QArray<int> m_uids; |
156 | int m_uid; | 159 | int m_uid; |
157 | }; | 160 | }; |
158 | 161 | ||
159 | /** | 162 | /** |
160 | * a find query for custom elements | 163 | * a find query for custom elements |
161 | */ | 164 | */ |
162 | class FindCustomQuery : public OSQLQuery { | 165 | class FindCustomQuery : public OSQLQuery { |
163 | public: | 166 | public: |
164 | FindCustomQuery(int uid); | 167 | FindCustomQuery(int uid); |
165 | FindCustomQuery(const QArray<int>& ); | 168 | FindCustomQuery(const QArray<int>& ); |
166 | ~FindCustomQuery(); | 169 | ~FindCustomQuery(); |
167 | QString query()const; | 170 | QString query()const; |
168 | private: | 171 | private: |
169 | QString single()const; | 172 | QString single()const; |
170 | QString multi()const; | 173 | QString multi()const; |
171 | QArray<int> m_uids; | 174 | QArray<int> m_uids; |
172 | int m_uid; | 175 | int m_uid; |
173 | }; | 176 | }; |
174 | 177 | ||
175 | 178 | ||
176 | 179 | ||
177 | // We using three tables to store the information: | 180 | // We using three tables to store the information: |
178 | // 1. addressbook : It contains General information about the contact (non custom) | 181 | // 1. addressbook : It contains General information about the contact (non custom) |
179 | // 2. custom_data : Not official supported entries | 182 | // 2. custom_data : Not official supported entries |
180 | // All tables are connected by the uid of the contact. | 183 | // All tables are connected by the uid of the contact. |
181 | // Maybe I should add a table for meta-information ? | 184 | // Maybe I should add a table for meta-information ? |
182 | CreateQuery::CreateQuery() : OSQLQuery() {} | 185 | CreateQuery::CreateQuery() : OSQLQuery() {} |
183 | CreateQuery::~CreateQuery() {} | 186 | CreateQuery::~CreateQuery() {} |
184 | QString CreateQuery::query()const { | 187 | QString CreateQuery::query()const { |
185 | QString qu; | 188 | QString qu; |
186 | #ifdef __STORE_HORIZONTAL_ | 189 | #ifdef __STORE_HORIZONTAL_ |
187 | 190 | ||
188 | qu += "create table addressbook( uid PRIMARY KEY "; | 191 | qu += "create table addressbook( uid PRIMARY KEY "; |
189 | 192 | ||
190 | QStringList fieldList = OContactFields::untrfields( false ); | 193 | QStringList fieldList = OContactFields::untrfields( false ); |
191 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 194 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
192 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); | 195 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); |
193 | } | 196 | } |
194 | qu += " );"; | 197 | qu += " );"; |
195 | 198 | ||
196 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | 199 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; |
197 | 200 | ||
198 | #else | 201 | #else |
199 | 202 | ||
200 | qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));"; | 203 | qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));"; |
201 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | 204 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; |
202 | // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );"; | 205 | // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );"; |
203 | 206 | ||
204 | #endif // __STORE_HORIZONTAL_ | 207 | #endif // __STORE_HORIZONTAL_ |
205 | return qu; | 208 | return qu; |
206 | } | 209 | } |
207 | 210 | ||
208 | ClearQuery::ClearQuery() | 211 | ClearQuery::ClearQuery() |
209 | : OSQLQuery() {} | 212 | : OSQLQuery() {} |
210 | ClearQuery::~ClearQuery() {} | 213 | ClearQuery::~ClearQuery() {} |
211 | QString ClearQuery::query()const { | 214 | QString ClearQuery::query()const { |
212 | QString qu = "drop table addressbook;"; | 215 | QString qu = "drop table addressbook;"; |
213 | qu += "drop table custom_data;"; | 216 | qu += "drop table custom_data;"; |
214 | // qu += "drop table dates;"; | 217 | // qu += "drop table dates;"; |
215 | return qu; | 218 | return qu; |
216 | } | 219 | } |
217 | 220 | ||
218 | 221 | ||
219 | LoadQuery::LoadQuery() : OSQLQuery() {} | 222 | LoadQuery::LoadQuery() : OSQLQuery() {} |
220 | LoadQuery::~LoadQuery() {} | 223 | LoadQuery::~LoadQuery() {} |
221 | QString LoadQuery::query()const { | 224 | QString LoadQuery::query()const { |
222 | QString qu; | 225 | QString qu; |
223 | #ifdef __STORE_HORIZONTAL_ | 226 | #ifdef __STORE_HORIZONTAL_ |
224 | qu += "select uid from addressbook"; | 227 | qu += "select uid from addressbook"; |
225 | #else | 228 | #else |
226 | # ifndef __USE_SUPERFAST_LOADQUERY | 229 | # ifndef __USE_SUPERFAST_LOADQUERY |
227 | qu += "select distinct uid from addressbook"; | 230 | qu += "select distinct uid from addressbook"; |
228 | # else | 231 | # else |
229 | qu += "select uid from addressbook where type = 'Last Name'"; | 232 | qu += "select uid from addressbook where type = 'Last Name'"; |
230 | # endif // __USE_SUPERFAST_LOADQUERY | 233 | # endif // __USE_SUPERFAST_LOADQUERY |
231 | #endif // __STORE_HORIZONTAL_ | 234 | #endif // __STORE_HORIZONTAL_ |
232 | 235 | ||
233 | return qu; | 236 | return qu; |
234 | } | 237 | } |
235 | 238 | ||
236 | 239 | ||
237 | InsertQuery::InsertQuery( const OContact& contact ) | 240 | InsertQuery::InsertQuery( const OContact& contact ) |
238 | : OSQLQuery(), m_contact( contact ) { | 241 | : OSQLQuery(), m_contact( contact ) { |
239 | } | 242 | } |
240 | 243 | ||
241 | InsertQuery::~InsertQuery() { | 244 | InsertQuery::~InsertQuery() { |
242 | } | 245 | } |
243 | 246 | ||
244 | /* | 247 | /* |
245 | * converts from a OContact to a query | 248 | * converts from a OContact to a query |
246 | */ | 249 | */ |
247 | QString InsertQuery::query()const{ | 250 | QString InsertQuery::query()const{ |
248 | 251 | ||
249 | #ifdef __STORE_HORIZONTAL_ | 252 | #ifdef __STORE_HORIZONTAL_ |
250 | QString qu; | 253 | QString qu; |
251 | qu += "insert into addressbook VALUES( " + | 254 | qu += "insert into addressbook VALUES( " + |
252 | QString::number( m_contact.uid() ); | 255 | QString::number( m_contact.uid() ); |
diff --git a/libopie/pim/ocontactaccessbackend_sql.h b/libopie/pim/ocontactaccessbackend_sql.h index b8f1d8d..f553760 100644 --- a/libopie/pim/ocontactaccessbackend_sql.h +++ b/libopie/pim/ocontactaccessbackend_sql.h | |||
@@ -1,101 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | * SQL Backend for the OPIE-Contact Database. | 2 | * SQL Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * | 12 | * |
13 | * | 13 | * |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.3 2004/03/14 13:50:35 alwin | ||
20 | * namespace correction | ||
21 | * | ||
19 | * Revision 1.2 2003/12/08 15:18:11 eilers | 22 | * Revision 1.2 2003/12/08 15:18:11 eilers |
20 | * Committing unfinished sql implementation before merging to libopie2 starts.. | 23 | * Committing unfinished sql implementation before merging to libopie2 starts.. |
21 | * | 24 | * |
22 | * Revision 1.1 2003/09/22 14:31:16 eilers | 25 | * Revision 1.1 2003/09/22 14:31:16 eilers |
23 | * Added first experimental incarnation of sql-backend for addressbook. | 26 | * Added first experimental incarnation of sql-backend for addressbook. |
24 | * Some modifications to be able to compile the todo sql-backend. | 27 | * Some modifications to be able to compile the todo sql-backend. |
25 | * A lot of changes fill follow... | 28 | * A lot of changes fill follow... |
26 | * | 29 | * |
27 | * | 30 | * |
28 | */ | 31 | */ |
29 | 32 | ||
30 | #ifndef _OContactAccessBackend_SQL_ | 33 | #ifndef _OContactAccessBackend_SQL_ |
31 | #define _OContactAccessBackend_SQL_ | 34 | #define _OContactAccessBackend_SQL_ |
32 | 35 | ||
33 | #include "ocontactaccessbackend.h" | 36 | #include "ocontactaccessbackend.h" |
34 | #include "ocontactaccess.h" | 37 | #include "ocontactaccess.h" |
35 | 38 | ||
36 | #include <qlist.h> | 39 | #include <qlist.h> |
37 | #include <qdict.h> | 40 | #include <qdict.h> |
38 | 41 | ||
42 | namespace Opie { namespace DB { | ||
39 | class OSQLDriver; | 43 | class OSQLDriver; |
40 | class OSQLResult; | 44 | class OSQLResult; |
41 | class OSQLResultItem; | 45 | class OSQLResultItem; |
42 | 46 | ||
47 | }} | ||
48 | |||
43 | /* the default xml implementation */ | 49 | /* the default xml implementation */ |
44 | /** | 50 | /** |
45 | * This class is the SQL implementation of a Contact backend | 51 | * This class is the SQL implementation of a Contact backend |
46 | * it does implement everything available for OContact. | 52 | * it does implement everything available for OContact. |
47 | * @see OPimAccessBackend for more information of available methods | 53 | * @see OPimAccessBackend for more information of available methods |
48 | */ | 54 | */ |
49 | class OContactAccessBackend_SQL : public OContactAccessBackend { | 55 | class OContactAccessBackend_SQL : public OContactAccessBackend { |
50 | public: | 56 | public: |
51 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); | 57 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); |
52 | 58 | ||
53 | ~OContactAccessBackend_SQL (); | 59 | ~OContactAccessBackend_SQL (); |
54 | 60 | ||
55 | bool save(); | 61 | bool save(); |
56 | 62 | ||
57 | bool load (); | 63 | bool load (); |
58 | 64 | ||
59 | void clear (); | 65 | void clear (); |
60 | 66 | ||
61 | bool wasChangedExternally(); | 67 | bool wasChangedExternally(); |
62 | 68 | ||
63 | QArray<int> allRecords() const; | 69 | QArray<int> allRecords() const; |
64 | 70 | ||
65 | OContact find ( int uid ) const; | 71 | OContact find ( int uid ) const; |
66 | // FIXME: Add lookahead-cache support ! | 72 | // FIXME: Add lookahead-cache support ! |
67 | //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | 73 | //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; |
68 | 74 | ||
69 | QArray<int> queryByExample ( const OContact &query, int settings, | 75 | QArray<int> queryByExample ( const OContact &query, int settings, |
70 | const QDateTime& d ); | 76 | const QDateTime& d ); |
71 | 77 | ||
72 | QArray<int> matchRegexp( const QRegExp &r ) const; | 78 | QArray<int> matchRegexp( const QRegExp &r ) const; |
73 | 79 | ||
74 | const uint querySettings(); | 80 | const uint querySettings(); |
75 | 81 | ||
76 | bool hasQuerySettings (uint querySettings) const; | 82 | bool hasQuerySettings (uint querySettings) const; |
77 | 83 | ||
78 | // Currently only asc implemented.. | 84 | // Currently only asc implemented.. |
79 | QArray<int> sorted( bool asc, int , int , int ); | 85 | QArray<int> sorted( bool asc, int , int , int ); |
80 | bool add ( const OContact &newcontact ); | 86 | bool add ( const OContact &newcontact ); |
81 | 87 | ||
82 | bool replace ( const OContact &contact ); | 88 | bool replace ( const OContact &contact ); |
83 | 89 | ||
84 | bool remove ( int uid ); | 90 | bool remove ( int uid ); |
85 | bool reload(); | 91 | bool reload(); |
86 | 92 | ||
87 | private: | 93 | private: |
88 | QArray<int> extractUids( OSQLResult& res ) const; | 94 | QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; |
89 | QMap<int, QString> requestNonCustom( int uid ) const; | 95 | QMap<int, QString> requestNonCustom( int uid ) const; |
90 | QMap<QString, QString> requestCustom( int uid ) const; | 96 | QMap<QString, QString> requestCustom( int uid ) const; |
91 | void update(); | 97 | void update(); |
92 | 98 | ||
93 | protected: | 99 | protected: |
94 | bool m_changed; | 100 | bool m_changed; |
95 | QString m_fileName; | 101 | QString m_fileName; |
96 | QArray<int> m_uids; | 102 | QArray<int> m_uids; |
97 | 103 | ||
98 | OSQLDriver* m_driver; | 104 | Opie::DB::OSQLDriver* m_driver; |
99 | }; | 105 | }; |
100 | 106 | ||
101 | #endif | 107 | #endif |
diff --git a/libopie/pim/odatebookaccessbackend_sql.cpp b/libopie/pim/odatebookaccessbackend_sql.cpp index 756f405..44dd2bc 100644 --- a/libopie/pim/odatebookaccessbackend_sql.cpp +++ b/libopie/pim/odatebookaccessbackend_sql.cpp | |||
@@ -1,244 +1,248 @@ | |||
1 | /* | 1 | /* |
2 | * SQL Backend for the OPIE-Calender Database. | 2 | * SQL Backend for the OPIE-Calender Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * Version: $Id$ | 13 | * Version: $Id$ |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * History: | 15 | * History: |
16 | * $Log$ | 16 | * $Log$ |
17 | * Revision 1.4 2004/03/14 13:50:35 alwin | ||
18 | * namespace correction | ||
19 | * | ||
17 | * Revision 1.3 2003/12/22 11:41:39 eilers | 20 | * Revision 1.3 2003/12/22 11:41:39 eilers |
18 | * Fixing stupid bug, found by sourcode review.. | 21 | * Fixing stupid bug, found by sourcode review.. |
19 | * | 22 | * |
20 | * Revision 1.2 2003/12/22 10:19:26 eilers | 23 | * Revision 1.2 2003/12/22 10:19:26 eilers |
21 | * Finishing implementation of sql-backend for datebook. But I have to | 24 | * Finishing implementation of sql-backend for datebook. But I have to |
22 | * port the PIM datebook application to use it, before I could debug the | 25 | * port the PIM datebook application to use it, before I could debug the |
23 | * whole stuff. | 26 | * whole stuff. |
24 | * Thus, PIM-Database backend is finished, but highly experimental. And some | 27 | * Thus, PIM-Database backend is finished, but highly experimental. And some |
25 | * parts are still generic. For instance, the "queryByExample()" methods are | 28 | * parts are still generic. For instance, the "queryByExample()" methods are |
26 | * not (or not fully) implemented. Todo: custom-entries not stored. | 29 | * not (or not fully) implemented. Todo: custom-entries not stored. |
27 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | 30 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular |
28 | * expression search in the database, which is not supported by sqlite ! | 31 | * expression search in the database, which is not supported by sqlite ! |
29 | * Therefore we need either an extended sqlite or a workaround which would | 32 | * Therefore we need either an extended sqlite or a workaround which would |
30 | * be very slow and memory consuming.. | 33 | * be very slow and memory consuming.. |
31 | * | 34 | * |
32 | * Revision 1.1 2003/12/08 15:18:12 eilers | 35 | * Revision 1.1 2003/12/08 15:18:12 eilers |
33 | * Committing unfinished sql implementation before merging to libopie2 starts.. | 36 | * Committing unfinished sql implementation before merging to libopie2 starts.. |
34 | * | 37 | * |
35 | * | 38 | * |
36 | */ | 39 | */ |
37 | 40 | ||
38 | #include <stdio.h> | 41 | #include <stdio.h> |
39 | #include <stdlib.h> | 42 | #include <stdlib.h> |
40 | 43 | ||
41 | #include <qarray.h> | 44 | #include <qarray.h> |
42 | #include <qstringlist.h> | 45 | #include <qstringlist.h> |
43 | 46 | ||
44 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
45 | 48 | ||
46 | #include <opie2/osqldriver.h> | 49 | #include <opie2/osqldriver.h> |
47 | #include <opie2/osqlmanager.h> | 50 | #include <opie2/osqlmanager.h> |
48 | #include <opie2/osqlquery.h> | 51 | #include <opie2/osqlquery.h> |
49 | 52 | ||
50 | #include "orecur.h" | 53 | #include "orecur.h" |
51 | #include "odatebookaccessbackend_sql.h" | 54 | #include "odatebookaccessbackend_sql.h" |
52 | 55 | ||
56 | using namespace Opie::DB; | ||
53 | 57 | ||
54 | 58 | ||
55 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , | 59 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , |
56 | const QString& fileName ) | 60 | const QString& fileName ) |
57 | : ODateBookAccessBackend(), m_driver( NULL ) | 61 | : ODateBookAccessBackend(), m_driver( NULL ) |
58 | { | 62 | { |
59 | m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; | 63 | m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; |
60 | 64 | ||
61 | // Get the standart sql-driver from the OSQLManager.. | 65 | // Get the standart sql-driver from the OSQLManager.. |
62 | OSQLManager man; | 66 | OSQLManager man; |
63 | m_driver = man.standard(); | 67 | m_driver = man.standard(); |
64 | m_driver->setUrl( m_fileName ); | 68 | m_driver->setUrl( m_fileName ); |
65 | 69 | ||
66 | initFields(); | 70 | initFields(); |
67 | 71 | ||
68 | load(); | 72 | load(); |
69 | } | 73 | } |
70 | 74 | ||
71 | ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { | 75 | ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { |
72 | if( m_driver ) | 76 | if( m_driver ) |
73 | delete m_driver; | 77 | delete m_driver; |
74 | } | 78 | } |
75 | 79 | ||
76 | void ODateBookAccessBackend_SQL::initFields() | 80 | void ODateBookAccessBackend_SQL::initFields() |
77 | { | 81 | { |
78 | 82 | ||
79 | // This map contains the translation of the fieldtype id's to | 83 | // This map contains the translation of the fieldtype id's to |
80 | // the names of the table columns | 84 | // the names of the table columns |
81 | m_fieldMap.insert( OEvent::FUid, "uid" ); | 85 | m_fieldMap.insert( OEvent::FUid, "uid" ); |
82 | m_fieldMap.insert( OEvent::FCategories, "Categories" ); | 86 | m_fieldMap.insert( OEvent::FCategories, "Categories" ); |
83 | m_fieldMap.insert( OEvent::FDescription, "Description" ); | 87 | m_fieldMap.insert( OEvent::FDescription, "Description" ); |
84 | m_fieldMap.insert( OEvent::FLocation, "Location" ); | 88 | m_fieldMap.insert( OEvent::FLocation, "Location" ); |
85 | m_fieldMap.insert( OEvent::FType, "Type" ); | 89 | m_fieldMap.insert( OEvent::FType, "Type" ); |
86 | m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); | 90 | m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); |
87 | m_fieldMap.insert( OEvent::FSound, "Sound" ); | 91 | m_fieldMap.insert( OEvent::FSound, "Sound" ); |
88 | m_fieldMap.insert( OEvent::FRType, "RType" ); | 92 | m_fieldMap.insert( OEvent::FRType, "RType" ); |
89 | m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); | 93 | m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); |
90 | m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); | 94 | m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); |
91 | m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); | 95 | m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); |
92 | m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); | 96 | m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); |
93 | m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); | 97 | m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); |
94 | m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); | 98 | m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); |
95 | m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); | 99 | m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); |
96 | m_fieldMap.insert( OEvent::FStart, "Start" ); | 100 | m_fieldMap.insert( OEvent::FStart, "Start" ); |
97 | m_fieldMap.insert( OEvent::FEnd, "End" ); | 101 | m_fieldMap.insert( OEvent::FEnd, "End" ); |
98 | m_fieldMap.insert( OEvent::FNote, "Note" ); | 102 | m_fieldMap.insert( OEvent::FNote, "Note" ); |
99 | m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); | 103 | m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); |
100 | m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); | 104 | m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); |
101 | m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); | 105 | m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); |
102 | 106 | ||
103 | // Create a map that maps the column name to the id | 107 | // Create a map that maps the column name to the id |
104 | QMapConstIterator<int, QString> it; | 108 | QMapConstIterator<int, QString> it; |
105 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 109 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
106 | m_reverseFieldMap.insert( it.data(), it.key() ); | 110 | m_reverseFieldMap.insert( it.data(), it.key() ); |
107 | } | 111 | } |
108 | 112 | ||
109 | } | 113 | } |
110 | 114 | ||
111 | bool ODateBookAccessBackend_SQL::load() | 115 | bool ODateBookAccessBackend_SQL::load() |
112 | { | 116 | { |
113 | if (!m_driver->open() ) | 117 | if (!m_driver->open() ) |
114 | return false; | 118 | return false; |
115 | 119 | ||
116 | // Don't expect that the database exists. | 120 | // Don't expect that the database exists. |
117 | // It is save here to create the table, even if it | 121 | // It is save here to create the table, even if it |
118 | // do exist. ( Is that correct for all databases ?? ) | 122 | // do exist. ( Is that correct for all databases ?? ) |
119 | QStringqu = "create table datebook( uid INTEGER PRIMARY KEY "; | 123 | QStringqu = "create table datebook( uid INTEGER PRIMARY KEY "; |
120 | 124 | ||
121 | QMap<int, QString>::Iterator it; | 125 | QMap<int, QString>::Iterator it; |
122 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 126 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
123 | qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); | 127 | qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); |
124 | } | 128 | } |
125 | qu += " );"; | 129 | qu += " );"; |
126 | 130 | ||
127 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | 131 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; |
128 | 132 | ||
129 | qWarning( "command: %s", qu.latin1() ); | 133 | qWarning( "command: %s", qu.latin1() ); |
130 | 134 | ||
131 | OSQLRawQuery raw( qu ); | 135 | OSQLRawQuery raw( qu ); |
132 | OSQLResult res = m_driver->query( &raw ); | 136 | OSQLResult res = m_driver->query( &raw ); |
133 | if ( res.state() != OSQLResult::Success ) | 137 | if ( res.state() != OSQLResult::Success ) |
134 | return false; | 138 | return false; |
135 | 139 | ||
136 | update(); | 140 | update(); |
137 | 141 | ||
138 | return true; | 142 | return true; |
139 | } | 143 | } |
140 | 144 | ||
141 | void ODateBookAccessBackend_SQL::update() | 145 | void ODateBookAccessBackend_SQL::update() |
142 | { | 146 | { |
143 | 147 | ||
144 | QString qu = "select uid from datebook"; | 148 | QString qu = "select uid from datebook"; |
145 | OSQLRawQuery raw( qu ); | 149 | OSQLRawQuery raw( qu ); |
146 | OSQLResult res = m_driver->query( &raw ); | 150 | OSQLResult res = m_driver->query( &raw ); |
147 | if ( res.state() != OSQLResult::Success ){ | 151 | if ( res.state() != OSQLResult::Success ){ |
148 | // m_uids.clear(); | 152 | // m_uids.clear(); |
149 | return; | 153 | return; |
150 | } | 154 | } |
151 | 155 | ||
152 | m_uids = extractUids( res ); | 156 | m_uids = extractUids( res ); |
153 | 157 | ||
154 | } | 158 | } |
155 | 159 | ||
156 | bool ODateBookAccessBackend_SQL::reload() | 160 | bool ODateBookAccessBackend_SQL::reload() |
157 | { | 161 | { |
158 | return load(); | 162 | return load(); |
159 | } | 163 | } |
160 | 164 | ||
161 | bool ODateBookAccessBackend_SQL::save() | 165 | bool ODateBookAccessBackend_SQL::save() |
162 | { | 166 | { |
163 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 167 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
164 | } | 168 | } |
165 | 169 | ||
166 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const | 170 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const |
167 | { | 171 | { |
168 | return m_uids; | 172 | return m_uids; |
169 | } | 173 | } |
170 | 174 | ||
171 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { | 175 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { |
172 | return QArray<int>(); | 176 | return QArray<int>(); |
173 | } | 177 | } |
174 | 178 | ||
175 | void ODateBookAccessBackend_SQL::clear() | 179 | void ODateBookAccessBackend_SQL::clear() |
176 | { | 180 | { |
177 | QString qu = "drop table datebook;"; | 181 | QString qu = "drop table datebook;"; |
178 | qu += "drop table custom_data;"; | 182 | qu += "drop table custom_data;"; |
179 | 183 | ||
180 | OSQLRawQuery raw( qu ); | 184 | OSQLRawQuery raw( qu ); |
181 | OSQLResult res = m_driver->query( &raw ); | 185 | OSQLResult res = m_driver->query( &raw ); |
182 | 186 | ||
183 | reload(); | 187 | reload(); |
184 | } | 188 | } |
185 | 189 | ||
186 | 190 | ||
187 | OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ | 191 | OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ |
188 | QString qu = "select *"; | 192 | QString qu = "select *"; |
189 | qu += "from datebook where uid = " + QString::number(uid); | 193 | qu += "from datebook where uid = " + QString::number(uid); |
190 | 194 | ||
191 | OSQLRawQuery raw( qu ); | 195 | OSQLRawQuery raw( qu ); |
192 | OSQLResult res = m_driver->query( &raw ); | 196 | OSQLResult res = m_driver->query( &raw ); |
193 | 197 | ||
194 | OSQLResultItem resItem = res.first(); | 198 | OSQLResultItem resItem = res.first(); |
195 | 199 | ||
196 | // Create Map for date event and insert UID | 200 | // Create Map for date event and insert UID |
197 | QMap<int,QString> dateEventMap; | 201 | QMap<int,QString> dateEventMap; |
198 | dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); | 202 | dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); |
199 | 203 | ||
200 | // Now insert the data out of the columns into the map. | 204 | // Now insert the data out of the columns into the map. |
201 | QMapConstIterator<int, QString> it; | 205 | QMapConstIterator<int, QString> it; |
202 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 206 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
203 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); | 207 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); |
204 | } | 208 | } |
205 | 209 | ||
206 | // Last step: Put map into date event and return it | 210 | // Last step: Put map into date event and return it |
207 | OEvent retDate( dateEventMap ); | 211 | OEvent retDate( dateEventMap ); |
208 | 212 | ||
209 | return retDate; | 213 | return retDate; |
210 | } | 214 | } |
211 | 215 | ||
212 | // FIXME: Speed up update of uid's.. | 216 | // FIXME: Speed up update of uid's.. |
213 | bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) | 217 | bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) |
214 | { | 218 | { |
215 | QMap<int,QString> eventMap = ev.toMap(); | 219 | QMap<int,QString> eventMap = ev.toMap(); |
216 | 220 | ||
217 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); | 221 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); |
218 | QMap<int, QString>::Iterator it; | 222 | QMap<int, QString>::Iterator it; |
219 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 223 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
220 | if ( !eventMap[it.key()].isEmpty() ) | 224 | if ( !eventMap[it.key()].isEmpty() ) |
221 | qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); | 225 | qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); |
222 | else | 226 | else |
223 | qu += QString( ",\"\"" ); | 227 | qu += QString( ",\"\"" ); |
224 | } | 228 | } |
225 | qu += " );"; | 229 | qu += " );"; |
226 | 230 | ||
227 | // Add custom entries | 231 | // Add custom entries |
228 | int id = 0; | 232 | int id = 0; |
229 | QMap<QString, QString> customMap = ev.toExtraMap(); | 233 | QMap<QString, QString> customMap = ev.toExtraMap(); |
230 | for( QMap<QString, QString>::Iterator it = customMap.begin(); | 234 | for( QMap<QString, QString>::Iterator it = customMap.begin(); |
231 | it != customMap.end(); ++it ){ | 235 | it != customMap.end(); ++it ){ |
232 | qu += "insert into custom_data VALUES(" | 236 | qu += "insert into custom_data VALUES(" |
233 | + QString::number( ev.uid() ) | 237 | + QString::number( ev.uid() ) |
234 | + "," | 238 | + "," |
235 | + QString::number( id++ ) | 239 | + QString::number( id++ ) |
236 | + ",'" | 240 | + ",'" |
237 | + it.key() //.latin1() | 241 | + it.key() //.latin1() |
238 | + "'," | 242 | + "'," |
239 | + "0" // Priority for future enhancements | 243 | + "0" // Priority for future enhancements |
240 | + ",'" | 244 | + ",'" |
241 | + it.data() //.latin1() | 245 | + it.data() //.latin1() |
242 | + "');"; | 246 | + "');"; |
243 | } | 247 | } |
244 | qWarning("add %s", qu.latin1() ); | 248 | qWarning("add %s", qu.latin1() ); |
diff --git a/libopie/pim/odatebookaccessbackend_sql.h b/libopie/pim/odatebookaccessbackend_sql.h index f39e154..ba514bc 100644 --- a/libopie/pim/odatebookaccessbackend_sql.h +++ b/libopie/pim/odatebookaccessbackend_sql.h | |||
@@ -1,62 +1,65 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H | 1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H | 2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <opie2/osqlresult.h> | 5 | #include <opie2/osqlresult.h> |
6 | 6 | ||
7 | #include "odatebookaccessbackend.h" | 7 | #include "odatebookaccessbackend.h" |
8 | 8 | ||
9 | namespace Opie { namespace DB { | ||
9 | class OSQLDriver; | 10 | class OSQLDriver; |
10 | 11 | ||
12 | }} | ||
13 | |||
11 | /** | 14 | /** |
12 | * This is the default SQL implementation for DateBoook SQL storage | 15 | * This is the default SQL implementation for DateBoook SQL storage |
13 | * It fully implements the interface | 16 | * It fully implements the interface |
14 | * @see ODateBookAccessBackend | 17 | * @see ODateBookAccessBackend |
15 | * @see OPimAccessBackend | 18 | * @see OPimAccessBackend |
16 | */ | 19 | */ |
17 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { | 20 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { |
18 | public: | 21 | public: |
19 | ODateBookAccessBackend_SQL( const QString& appName, | 22 | ODateBookAccessBackend_SQL( const QString& appName, |
20 | const QString& fileName = QString::null); | 23 | const QString& fileName = QString::null); |
21 | ~ODateBookAccessBackend_SQL(); | 24 | ~ODateBookAccessBackend_SQL(); |
22 | 25 | ||
23 | bool load(); | 26 | bool load(); |
24 | bool reload(); | 27 | bool reload(); |
25 | bool save(); | 28 | bool save(); |
26 | 29 | ||
27 | QArray<int> allRecords()const; | 30 | QArray<int> allRecords()const; |
28 | QArray<int> matchRegexp(const QRegExp &r) const; | 31 | QArray<int> matchRegexp(const QRegExp &r) const; |
29 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 32 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); |
30 | OEvent find( int uid )const; | 33 | OEvent find( int uid )const; |
31 | void clear(); | 34 | void clear(); |
32 | bool add( const OEvent& ev ); | 35 | bool add( const OEvent& ev ); |
33 | bool remove( int uid ); | 36 | bool remove( int uid ); |
34 | bool replace( const OEvent& ev ); | 37 | bool replace( const OEvent& ev ); |
35 | 38 | ||
36 | QArray<UID> rawEvents()const; | 39 | QArray<UID> rawEvents()const; |
37 | QArray<UID> rawRepeats()const; | 40 | QArray<UID> rawRepeats()const; |
38 | QArray<UID> nonRepeats()const; | 41 | QArray<UID> nonRepeats()const; |
39 | 42 | ||
40 | OEvent::ValueList directNonRepeats(); | 43 | OEvent::ValueList directNonRepeats(); |
41 | OEvent::ValueList directRawRepeats(); | 44 | OEvent::ValueList directRawRepeats(); |
42 | 45 | ||
43 | private: | 46 | private: |
44 | bool loadFile(); | 47 | bool loadFile(); |
45 | QString m_fileName; | 48 | QString m_fileName; |
46 | QArray<int> m_uids; | 49 | QArray<int> m_uids; |
47 | 50 | ||
48 | QMap<int, QString> m_fieldMap; | 51 | QMap<int, QString> m_fieldMap; |
49 | QMap<QString, int> m_reverseFieldMap; | 52 | QMap<QString, int> m_reverseFieldMap; |
50 | 53 | ||
51 | OSQLDriver* m_driver; | 54 | Opie::DB::OSQLDriver* m_driver; |
52 | 55 | ||
53 | class Private; | 56 | class Private; |
54 | Private *d; | 57 | Private *d; |
55 | 58 | ||
56 | void initFields(); | 59 | void initFields(); |
57 | void update(); | 60 | void update(); |
58 | QArray<int> extractUids( OSQLResult& res ) const; | 61 | QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; |
59 | 62 | ||
60 | }; | 63 | }; |
61 | 64 | ||
62 | #endif | 65 | #endif |
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index 3764c7e..fd01a42 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp | |||
@@ -1,207 +1,208 @@ | |||
1 | 1 | ||
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | 3 | ||
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | 5 | ||
6 | #include <opie2/osqldriver.h> | 6 | #include <opie2/osqldriver.h> |
7 | #include <opie2/osqlresult.h> | 7 | #include <opie2/osqlresult.h> |
8 | #include <opie2/osqlmanager.h> | 8 | #include <opie2/osqlmanager.h> |
9 | #include <opie2/osqlquery.h> | 9 | #include <opie2/osqlquery.h> |
10 | 10 | ||
11 | #include "otodoaccesssql.h" | 11 | #include "otodoaccesssql.h" |
12 | #include "opimstate.h" | 12 | #include "opimstate.h" |
13 | #include "opimnotifymanager.h" | 13 | #include "opimnotifymanager.h" |
14 | #include "orecur.h" | 14 | #include "orecur.h" |
15 | 15 | ||
16 | using namespace Opie::DB; | ||
16 | /* | 17 | /* |
17 | * first some query | 18 | * first some query |
18 | * CREATE query | 19 | * CREATE query |
19 | * LOAD query | 20 | * LOAD query |
20 | * INSERT | 21 | * INSERT |
21 | * REMOVE | 22 | * REMOVE |
22 | * CLEAR | 23 | * CLEAR |
23 | */ | 24 | */ |
24 | namespace { | 25 | namespace { |
25 | /** | 26 | /** |
26 | * CreateQuery for the Todolist Table | 27 | * CreateQuery for the Todolist Table |
27 | */ | 28 | */ |
28 | class CreateQuery : public OSQLQuery { | 29 | class CreateQuery : public OSQLQuery { |
29 | public: | 30 | public: |
30 | CreateQuery(); | 31 | CreateQuery(); |
31 | ~CreateQuery(); | 32 | ~CreateQuery(); |
32 | QString query()const; | 33 | QString query()const; |
33 | }; | 34 | }; |
34 | 35 | ||
35 | /** | 36 | /** |
36 | * LoadQuery | 37 | * LoadQuery |
37 | * this one queries for all uids | 38 | * this one queries for all uids |
38 | */ | 39 | */ |
39 | class LoadQuery : public OSQLQuery { | 40 | class LoadQuery : public OSQLQuery { |
40 | public: | 41 | public: |
41 | LoadQuery(); | 42 | LoadQuery(); |
42 | ~LoadQuery(); | 43 | ~LoadQuery(); |
43 | QString query()const; | 44 | QString query()const; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | /** | 47 | /** |
47 | * inserts/adds a OTodo to the table | 48 | * inserts/adds a OTodo to the table |
48 | */ | 49 | */ |
49 | class InsertQuery : public OSQLQuery { | 50 | class InsertQuery : public OSQLQuery { |
50 | public: | 51 | public: |
51 | InsertQuery(const OTodo& ); | 52 | InsertQuery(const OTodo& ); |
52 | ~InsertQuery(); | 53 | ~InsertQuery(); |
53 | QString query()const; | 54 | QString query()const; |
54 | private: | 55 | private: |
55 | OTodo m_todo; | 56 | OTodo m_todo; |
56 | }; | 57 | }; |
57 | 58 | ||
58 | /** | 59 | /** |
59 | * removes one from the table | 60 | * removes one from the table |
60 | */ | 61 | */ |
61 | class RemoveQuery : public OSQLQuery { | 62 | class RemoveQuery : public OSQLQuery { |
62 | public: | 63 | public: |
63 | RemoveQuery(int uid ); | 64 | RemoveQuery(int uid ); |
64 | ~RemoveQuery(); | 65 | ~RemoveQuery(); |
65 | QString query()const; | 66 | QString query()const; |
66 | private: | 67 | private: |
67 | int m_uid; | 68 | int m_uid; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | /** | 71 | /** |
71 | * Clears (delete) a Table | 72 | * Clears (delete) a Table |
72 | */ | 73 | */ |
73 | class ClearQuery : public OSQLQuery { | 74 | class ClearQuery : public OSQLQuery { |
74 | public: | 75 | public: |
75 | ClearQuery(); | 76 | ClearQuery(); |
76 | ~ClearQuery(); | 77 | ~ClearQuery(); |
77 | QString query()const; | 78 | QString query()const; |
78 | 79 | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * a find query | 83 | * a find query |
83 | */ | 84 | */ |
84 | class FindQuery : public OSQLQuery { | 85 | class FindQuery : public OSQLQuery { |
85 | public: | 86 | public: |
86 | FindQuery(int uid); | 87 | FindQuery(int uid); |
87 | FindQuery(const QArray<int>& ); | 88 | FindQuery(const QArray<int>& ); |
88 | ~FindQuery(); | 89 | ~FindQuery(); |
89 | QString query()const; | 90 | QString query()const; |
90 | private: | 91 | private: |
91 | QString single()const; | 92 | QString single()const; |
92 | QString multi()const; | 93 | QString multi()const; |
93 | QArray<int> m_uids; | 94 | QArray<int> m_uids; |
94 | int m_uid; | 95 | int m_uid; |
95 | }; | 96 | }; |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * overdue query | 99 | * overdue query |
99 | */ | 100 | */ |
100 | class OverDueQuery : public OSQLQuery { | 101 | class OverDueQuery : public OSQLQuery { |
101 | public: | 102 | public: |
102 | OverDueQuery(); | 103 | OverDueQuery(); |
103 | ~OverDueQuery(); | 104 | ~OverDueQuery(); |
104 | QString query()const; | 105 | QString query()const; |
105 | }; | 106 | }; |
106 | class EffQuery : public OSQLQuery { | 107 | class EffQuery : public OSQLQuery { |
107 | public: | 108 | public: |
108 | EffQuery( const QDate&, const QDate&, bool inc ); | 109 | EffQuery( const QDate&, const QDate&, bool inc ); |
109 | ~EffQuery(); | 110 | ~EffQuery(); |
110 | QString query()const; | 111 | QString query()const; |
111 | private: | 112 | private: |
112 | QString with()const; | 113 | QString with()const; |
113 | QString out()const; | 114 | QString out()const; |
114 | QDate m_start; | 115 | QDate m_start; |
115 | QDate m_end; | 116 | QDate m_end; |
116 | bool m_inc :1; | 117 | bool m_inc :1; |
117 | }; | 118 | }; |
118 | 119 | ||
119 | 120 | ||
120 | CreateQuery::CreateQuery() : OSQLQuery() {} | 121 | CreateQuery::CreateQuery() : OSQLQuery() {} |
121 | CreateQuery::~CreateQuery() {} | 122 | CreateQuery::~CreateQuery() {} |
122 | QString CreateQuery::query()const { | 123 | QString CreateQuery::query()const { |
123 | QString qu; | 124 | QString qu; |
124 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; | 125 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
125 | qu += "description, summary, priority, DueDate, progress , state, "; | 126 | qu += "description, summary, priority, DueDate, progress , state, "; |
126 | // This is the recurrance-stuff .. Exceptions are currently not supported (see ORecur.cpp) ! (eilers) | 127 | // This is the recurrance-stuff .. Exceptions are currently not supported (see ORecur.cpp) ! (eilers) |
127 | qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; | 128 | qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; |
128 | qu += "reminders, alarms, maintainer, startdate, completeddate);"; | 129 | qu += "reminders, alarms, maintainer, startdate, completeddate);"; |
129 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | 130 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; |
130 | return qu; | 131 | return qu; |
131 | } | 132 | } |
132 | 133 | ||
133 | LoadQuery::LoadQuery() : OSQLQuery() {} | 134 | LoadQuery::LoadQuery() : OSQLQuery() {} |
134 | LoadQuery::~LoadQuery() {} | 135 | LoadQuery::~LoadQuery() {} |
135 | QString LoadQuery::query()const { | 136 | QString LoadQuery::query()const { |
136 | QString qu; | 137 | QString qu; |
137 | // We do not need "distinct" here. The primary key is always unique.. | 138 | // We do not need "distinct" here. The primary key is always unique.. |
138 | //qu += "select distinct uid from todolist"; | 139 | //qu += "select distinct uid from todolist"; |
139 | qu += "select uid from todolist"; | 140 | qu += "select uid from todolist"; |
140 | 141 | ||
141 | return qu; | 142 | return qu; |
142 | } | 143 | } |
143 | 144 | ||
144 | InsertQuery::InsertQuery( const OTodo& todo ) | 145 | InsertQuery::InsertQuery( const OTodo& todo ) |
145 | : OSQLQuery(), m_todo( todo ) { | 146 | : OSQLQuery(), m_todo( todo ) { |
146 | } | 147 | } |
147 | InsertQuery::~InsertQuery() { | 148 | InsertQuery::~InsertQuery() { |
148 | } | 149 | } |
149 | /* | 150 | /* |
150 | * converts from a OTodo to a query | 151 | * converts from a OTodo to a query |
151 | * we leave out X-Ref + Alarms | 152 | * we leave out X-Ref + Alarms |
152 | */ | 153 | */ |
153 | QString InsertQuery::query()const{ | 154 | QString InsertQuery::query()const{ |
154 | 155 | ||
155 | int year, month, day; | 156 | int year, month, day; |
156 | year = month = day = 0; | 157 | year = month = day = 0; |
157 | if (m_todo.hasDueDate() ) { | 158 | if (m_todo.hasDueDate() ) { |
158 | QDate date = m_todo.dueDate(); | 159 | QDate date = m_todo.dueDate(); |
159 | year = date.year(); | 160 | year = date.year(); |
160 | month = date.month(); | 161 | month = date.month(); |
161 | day = date.day(); | 162 | day = date.day(); |
162 | } | 163 | } |
163 | int sYear = 0, sMonth = 0, sDay = 0; | 164 | int sYear = 0, sMonth = 0, sDay = 0; |
164 | if( m_todo.hasStartDate() ){ | 165 | if( m_todo.hasStartDate() ){ |
165 | QDate sDate = m_todo.startDate(); | 166 | QDate sDate = m_todo.startDate(); |
166 | sYear = sDate.year(); | 167 | sYear = sDate.year(); |
167 | sMonth= sDate.month(); | 168 | sMonth= sDate.month(); |
168 | sDay = sDate.day(); | 169 | sDay = sDate.day(); |
169 | } | 170 | } |
170 | 171 | ||
171 | int eYear = 0, eMonth = 0, eDay = 0; | 172 | int eYear = 0, eMonth = 0, eDay = 0; |
172 | if( m_todo.hasCompletedDate() ){ | 173 | if( m_todo.hasCompletedDate() ){ |
173 | QDate eDate = m_todo.completedDate(); | 174 | QDate eDate = m_todo.completedDate(); |
174 | eYear = eDate.year(); | 175 | eYear = eDate.year(); |
175 | eMonth= eDate.month(); | 176 | eMonth= eDate.month(); |
176 | eDay = eDate.day(); | 177 | eDay = eDate.day(); |
177 | } | 178 | } |
178 | QString qu; | 179 | QString qu; |
179 | QMap<int, QString> recMap = m_todo.recurrence().toMap(); | 180 | QMap<int, QString> recMap = m_todo.recurrence().toMap(); |
180 | qu = "insert into todolist VALUES(" | 181 | qu = "insert into todolist VALUES(" |
181 | + QString::number( m_todo.uid() ) + "," | 182 | + QString::number( m_todo.uid() ) + "," |
182 | + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," | 183 | + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," |
183 | + QString::number( m_todo.isCompleted() ) + "," | 184 | + QString::number( m_todo.isCompleted() ) + "," |
184 | + "'" + m_todo.description() + "'" + "," | 185 | + "'" + m_todo.description() + "'" + "," |
185 | + "'" + m_todo.summary() + "'" + "," | 186 | + "'" + m_todo.summary() + "'" + "," |
186 | + QString::number(m_todo.priority() ) + "," | 187 | + QString::number(m_todo.priority() ) + "," |
187 | + "'" + QString::number(year) + "-" | 188 | + "'" + QString::number(year) + "-" |
188 | + QString::number(month) | 189 | + QString::number(month) |
189 | + "-" + QString::number( day ) + "'" + "," | 190 | + "-" + QString::number( day ) + "'" + "," |
190 | + QString::number( m_todo.progress() ) + "," | 191 | + QString::number( m_todo.progress() ) + "," |
191 | + QString::number( m_todo.state().state() ) + "," | 192 | + QString::number( m_todo.state().state() ) + "," |
192 | + "'" + recMap[ ORecur::RType ] + "'" + "," | 193 | + "'" + recMap[ ORecur::RType ] + "'" + "," |
193 | + "'" + recMap[ ORecur::RWeekdays ] + "'" + "," | 194 | + "'" + recMap[ ORecur::RWeekdays ] + "'" + "," |
194 | + "'" + recMap[ ORecur::RPosition ] + "'" + "," | 195 | + "'" + recMap[ ORecur::RPosition ] + "'" + "," |
195 | + "'" + recMap[ ORecur::RFreq ] + "'" + "," | 196 | + "'" + recMap[ ORecur::RFreq ] + "'" + "," |
196 | + "'" + recMap[ ORecur::RHasEndDate ] + "'" + "," | 197 | + "'" + recMap[ ORecur::RHasEndDate ] + "'" + "," |
197 | + "'" + recMap[ ORecur::EndDate ] + "'" + "," | 198 | + "'" + recMap[ ORecur::EndDate ] + "'" + "," |
198 | + "'" + recMap[ ORecur::Created ] + "'" + "," | 199 | + "'" + recMap[ ORecur::Created ] + "'" + "," |
199 | + "'" + recMap[ ORecur::Exceptions ] + "'" + ","; | 200 | + "'" + recMap[ ORecur::Exceptions ] + "'" + ","; |
200 | 201 | ||
201 | if ( m_todo.hasNotifiers() ) { | 202 | if ( m_todo.hasNotifiers() ) { |
202 | OPimNotifyManager manager = m_todo.notifiers(); | 203 | OPimNotifyManager manager = m_todo.notifiers(); |
203 | qu += "'" + manager.remindersToString() + "'" + "," | 204 | qu += "'" + manager.remindersToString() + "'" + "," |
204 | + "'" + manager.alarmsToString() + "'" + ","; | 205 | + "'" + manager.alarmsToString() + "'" + ","; |
205 | } | 206 | } |
206 | else{ | 207 | else{ |
207 | qu += QString( "''" ) + "," | 208 | qu += QString( "''" ) + "," |
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h index 1c55567..72214de 100644 --- a/libopie/pim/otodoaccesssql.h +++ b/libopie/pim/otodoaccesssql.h | |||
@@ -1,56 +1,61 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_SQL_H | 1 | #ifndef OPIE_PIM_ACCESS_SQL_H |
2 | #define OPIE_PIM_ACCESS_SQL_H | 2 | #define OPIE_PIM_ACCESS_SQL_H |
3 | 3 | ||
4 | #include <qasciidict.h> | 4 | #include <qasciidict.h> |
5 | 5 | ||
6 | #include "otodoaccessbackend.h" | 6 | #include "otodoaccessbackend.h" |
7 | 7 | ||
8 | namespace Opie{ | ||
9 | namespace DB { | ||
8 | class OSQLDriver; | 10 | class OSQLDriver; |
9 | class OSQLResult; | 11 | class OSQLResult; |
10 | class OSQLResultItem; | 12 | class OSQLResultItem; |
13 | } | ||
14 | } | ||
15 | |||
11 | class OTodoAccessBackendSQL : public OTodoAccessBackend { | 16 | class OTodoAccessBackendSQL : public OTodoAccessBackend { |
12 | public: | 17 | public: |
13 | OTodoAccessBackendSQL( const QString& file ); | 18 | OTodoAccessBackendSQL( const QString& file ); |
14 | ~OTodoAccessBackendSQL(); | 19 | ~OTodoAccessBackendSQL(); |
15 | 20 | ||
16 | bool load(); | 21 | bool load(); |
17 | bool reload(); | 22 | bool reload(); |
18 | bool save(); | 23 | bool save(); |
19 | QArray<int> allRecords()const; | 24 | QArray<int> allRecords()const; |
20 | 25 | ||
21 | QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); | 26 | QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); |
22 | OTodo find(int uid)const; | 27 | OTodo find(int uid)const; |
23 | OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | 28 | OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; |
24 | void clear(); | 29 | void clear(); |
25 | bool add( const OTodo& t ); | 30 | bool add( const OTodo& t ); |
26 | bool remove( int uid ); | 31 | bool remove( int uid ); |
27 | bool replace( const OTodo& t ); | 32 | bool replace( const OTodo& t ); |
28 | 33 | ||
29 | QArray<int> overDue(); | 34 | QArray<int> overDue(); |
30 | QArray<int> effectiveToDos( const QDate& start, | 35 | QArray<int> effectiveToDos( const QDate& start, |
31 | const QDate& end, bool includeNoDates ); | 36 | const QDate& end, bool includeNoDates ); |
32 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); | 37 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); |
33 | 38 | ||
34 | QBitArray supports()const; | 39 | QBitArray supports()const; |
35 | QArray<int> matchRegexp( const QRegExp &r ) const; | 40 | QArray<int> matchRegexp( const QRegExp &r ) const; |
36 | void removeAllCompleted(); | 41 | void removeAllCompleted(); |
37 | 42 | ||
38 | 43 | ||
39 | private: | 44 | private: |
40 | void update()const; | 45 | void update()const; |
41 | void fillDict(); | 46 | void fillDict(); |
42 | inline bool date( QDate& date, const QString& )const; | 47 | inline bool date( QDate& date, const QString& )const; |
43 | inline OTodo todo( const OSQLResult& )const; | 48 | inline OTodo todo( const Opie::DB::OSQLResult& )const; |
44 | inline OTodo todo( OSQLResultItem& )const; | 49 | inline OTodo todo( Opie::DB::OSQLResultItem& )const; |
45 | inline QArray<int> uids( const OSQLResult& )const; | 50 | inline QArray<int> uids( const Opie::DB::OSQLResult& )const; |
46 | OTodo todo( int uid )const; | 51 | OTodo todo( int uid )const; |
47 | QBitArray sup() const; | 52 | QBitArray sup() const; |
48 | 53 | ||
49 | QAsciiDict<int> m_dict; | 54 | QAsciiDict<int> m_dict; |
50 | OSQLDriver* m_driver; | 55 | Opie::DB::OSQLDriver* m_driver; |
51 | QArray<int> m_uids; | 56 | QArray<int> m_uids; |
52 | bool m_dirty : 1; | 57 | bool m_dirty : 1; |
53 | }; | 58 | }; |
54 | 59 | ||
55 | 60 | ||
56 | #endif | 61 | #endif |