Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_xml.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index 97ef40f..50ea329 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h | |||
@@ -8,24 +8,27 @@ | |||
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 | * ToDo: XML-Backend: Automatic reload if something was changed... | 12 | * ToDo: XML-Backend: Automatic reload if something was changed... |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.3 2002/10/14 16:21:54 eilers | ||
21 | * Some minor interface updates | ||
22 | * | ||
20 | * Revision 1.2 2002/10/07 17:34:24 eilers | 23 | * Revision 1.2 2002/10/07 17:34:24 eilers |
21 | * added OBackendFactory for advanced backend access | 24 | * added OBackendFactory for advanced backend access |
22 | * | 25 | * |
23 | * Revision 1.1 2002/09/27 17:11:44 eilers | 26 | * Revision 1.1 2002/09/27 17:11:44 eilers |
24 | * Added API for accessing the Contact-Database ! It is compiling, but | 27 | * Added API for accessing the Contact-Database ! It is compiling, but |
25 | * please do not expect that anything is working ! | 28 | * please do not expect that anything is working ! |
26 | * I will debug that stuff in the next time .. | 29 | * I will debug that stuff in the next time .. |
27 | * Please read README_COMPILE for compiling ! | 30 | * Please read README_COMPILE for compiling ! |
28 | * | 31 | * |
29 | * | 32 | * |
30 | */ | 33 | */ |
31 | 34 | ||
@@ -190,43 +193,43 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
190 | QArray<int> m_currentQuery( m_contactList.count() ); | 193 | QArray<int> m_currentQuery( m_contactList.count() ); |
191 | QValueListConstIterator<OContact> it; | 194 | QValueListConstIterator<OContact> it; |
192 | uint arraycounter = 0; | 195 | uint arraycounter = 0; |
193 | 196 | ||
194 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | 197 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ |
195 | /* Search all fields and compare them with query object. Store them into list | 198 | /* Search all fields and compare them with query object. Store them into list |
196 | * if all fields matches. | 199 | * if all fields matches. |
197 | */ | 200 | */ |
198 | bool allcorrect = true; | 201 | bool allcorrect = true; |
199 | for ( int i = 0; i < Qtopia::rid; i++ ) { | 202 | for ( int i = 0; i < Qtopia::rid; i++ ) { |
200 | /* Just compare fields which are not empty in the query object */ | 203 | /* Just compare fields which are not empty in the query object */ |
201 | if ( !query.field(i).isEmpty() ){ | 204 | if ( !query.field(i).isEmpty() ){ |
202 | switch ( settings & ~OContactAccess::query_IgnoreCase ){ | 205 | switch ( settings & ~OContactAccess::IgnoreCase ){ |
203 | case OContactAccess::query_RegExp:{ | 206 | case OContactAccess::RegExp:{ |
204 | QRegExp expr ( query.field(i), | 207 | QRegExp expr ( query.field(i), |
205 | !(settings & OContactAccess::query_IgnoreCase), | 208 | !(settings & OContactAccess::IgnoreCase), |
206 | false ); | 209 | false ); |
207 | if ( expr.find ( (*it).field(i), 0 ) == -1 ) | 210 | if ( expr.find ( (*it).field(i), 0 ) == -1 ) |
208 | allcorrect = false; | 211 | allcorrect = false; |
209 | } | 212 | } |
210 | break; | 213 | break; |
211 | case OContactAccess::query_WildCards:{ | 214 | case OContactAccess::WildCards:{ |
212 | QRegExp expr ( query.field(i), | 215 | QRegExp expr ( query.field(i), |
213 | !(settings & OContactAccess::query_IgnoreCase), | 216 | !(settings & OContactAccess::IgnoreCase), |
214 | true ); | 217 | true ); |
215 | if ( expr.find ( (*it).field(i), 0 ) == -1 ) | 218 | if ( expr.find ( (*it).field(i), 0 ) == -1 ) |
216 | allcorrect = false; | 219 | allcorrect = false; |
217 | } | 220 | } |
218 | break; | 221 | break; |
219 | case OContactAccess::query_ExactMatch:{ | 222 | case OContactAccess::ExactMatch:{ |
220 | if (settings & OContactAccess::query_IgnoreCase){ | 223 | if (settings & OContactAccess::IgnoreCase){ |
221 | if ( query.field(i).upper() != | 224 | if ( query.field(i).upper() != |
222 | (*it).field(i).upper() ) | 225 | (*it).field(i).upper() ) |
223 | allcorrect = false; | 226 | allcorrect = false; |
224 | }else{ | 227 | }else{ |
225 | if ( query.field(i) != (*it).field(i) ) | 228 | if ( query.field(i) != (*it).field(i) ) |
226 | allcorrect = false; | 229 | allcorrect = false; |
227 | } | 230 | } |
228 | } | 231 | } |
229 | break; | 232 | break; |
230 | } | 233 | } |
231 | } | 234 | } |
232 | } | 235 | } |
@@ -234,42 +237,42 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
234 | m_currentQuery[arraycounter++] = (*it).uid(); | 237 | m_currentQuery[arraycounter++] = (*it).uid(); |
235 | } | 238 | } |
236 | } | 239 | } |
237 | 240 | ||
238 | // Shrink to fit.. | 241 | // Shrink to fit.. |
239 | m_currentQuery.resize(arraycounter); | 242 | m_currentQuery.resize(arraycounter); |
240 | 243 | ||
241 | return m_currentQuery; | 244 | return m_currentQuery; |
242 | } | 245 | } |
243 | 246 | ||
244 | const uint querySettings() | 247 | const uint querySettings() |
245 | { | 248 | { |
246 | return ( OContactAccess::query_WildCards | 249 | return ( OContactAccess::WildCards |
247 | & OContactAccess::query_IgnoreCase | 250 | & OContactAccess::IgnoreCase |
248 | & OContactAccess::query_RegExp | 251 | & OContactAccess::RegExp |
249 | & OContactAccess::query_ExactMatch ); | 252 | & OContactAccess::ExactMatch ); |
250 | } | 253 | } |
251 | 254 | ||
252 | bool hasQuerySettings (uint querySettings) const | 255 | bool hasQuerySettings (uint querySettings) const |
253 | { | 256 | { |
254 | /* OContactAccess::query_IgnoreCase may be added with one | 257 | /* OContactAccess::IgnoreCase may be added with one |
255 | * of the other settings, but never used alone. | 258 | * of the other settings, but never used alone. |
256 | * The other settings are just valid alone... | 259 | * The other settings are just valid alone... |
257 | */ | 260 | */ |
258 | switch ( querySettings & ~OContactAccess::query_IgnoreCase ){ | 261 | switch ( querySettings & ~OContactAccess::IgnoreCase ){ |
259 | case OContactAccess::query_RegExp: | 262 | case OContactAccess::RegExp: |
260 | return ( true ); | 263 | return ( true ); |
261 | case OContactAccess::query_WildCards: | 264 | case OContactAccess::WildCards: |
262 | return ( true ); | 265 | return ( true ); |
263 | case OContactAccess::query_ExactMatch: | 266 | case OContactAccess::ExactMatch: |
264 | return ( true ); | 267 | return ( true ); |
265 | default: | 268 | default: |
266 | return ( false ); | 269 | return ( false ); |
267 | } | 270 | } |
268 | } | 271 | } |
269 | 272 | ||
270 | bool add ( const OContact &newcontact ) | 273 | bool add ( const OContact &newcontact ) |
271 | { | 274 | { |
272 | //qWarning("odefaultbackend: ACTION::ADD"); | 275 | //qWarning("odefaultbackend: ACTION::ADD"); |
273 | updateJournal (newcontact, OContact::ACTION_ADD); | 276 | updateJournal (newcontact, OContact::ACTION_ADD); |
274 | addContact_p( newcontact ); | 277 | addContact_p( newcontact ); |
275 | return true; | 278 | return true; |