summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp
index 4abf4d9..9fe3d1e 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -1,67 +1,71 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML 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 * 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 2003/03/21 12:26:28 eilers
21 * Fixing small bug: If we search a birthday from today to today, it returned
22 * every contact ..
23 *
20 * Revision 1.2 2003/03/21 10:33:09 eilers 24 * Revision 1.2 2003/03/21 10:33:09 eilers
21 * Merged speed optimized xml backend for contacts to main. 25 * Merged speed optimized xml backend for contacts to main.
22 * Added QDateTime to querybyexample. For instance, it is now possible to get 26 * Added QDateTime to querybyexample. For instance, it is now possible to get
23 * all Birthdays/Anniversaries between two dates. This should be used 27 * all Birthdays/Anniversaries between two dates. This should be used
24 * to show all birthdays in the datebook.. 28 * to show all birthdays in the datebook..
25 * This change is sourcecode backward compatible but you have to upgrade 29 * This change is sourcecode backward compatible but you have to upgrade
26 * the binaries for today-addressbook. 30 * the binaries for today-addressbook.
27 * 31 *
28 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 32 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
29 * Speed optimization. Removed the sequential search loops. 33 * Speed optimization. Removed the sequential search loops.
30 * 34 *
31 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers 35 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
32 * Writing offsets to debug output.. 36 * Writing offsets to debug output..
33 * 37 *
34 * Revision 1.1 2003/02/09 15:05:01 eilers 38 * Revision 1.1 2003/02/09 15:05:01 eilers
35 * Nothing happened.. Just some cleanup before I will start.. 39 * Nothing happened.. Just some cleanup before I will start..
36 * 40 *
37 * Revision 1.12 2003/01/03 16:58:03 eilers 41 * Revision 1.12 2003/01/03 16:58:03 eilers
38 * Reenable debug output 42 * Reenable debug output
39 * 43 *
40 * Revision 1.11 2003/01/03 12:31:28 eilers 44 * Revision 1.11 2003/01/03 12:31:28 eilers
41 * Bugfix for calculating data diffs.. 45 * Bugfix for calculating data diffs..
42 * 46 *
43 * Revision 1.10 2003/01/02 14:27:12 eilers 47 * Revision 1.10 2003/01/02 14:27:12 eilers
44 * Improved query by example: Search by date is possible.. First step 48 * Improved query by example: Search by date is possible.. First step
45 * for a today plugin for birthdays.. 49 * for a today plugin for birthdays..
46 * 50 *
47 * Revision 1.9 2002/12/08 12:48:57 eilers 51 * Revision 1.9 2002/12/08 12:48:57 eilers
48 * Moved journal-enum from ocontact into i the xml-backend.. 52 * Moved journal-enum from ocontact into i the xml-backend..
49 * 53 *
50 * Revision 1.8 2002/11/14 17:04:24 eilers 54 * Revision 1.8 2002/11/14 17:04:24 eilers
51 * Sorting will now work if fullname is identical on some entries 55 * Sorting will now work if fullname is identical on some entries
52 * 56 *
53 * Revision 1.7 2002/11/13 15:02:46 eilers 57 * Revision 1.7 2002/11/13 15:02:46 eilers
54 * Small Bug in sorted fixed 58 * Small Bug in sorted fixed
55 * 59 *
56 * Revision 1.6 2002/11/13 14:14:51 eilers 60 * Revision 1.6 2002/11/13 14:14:51 eilers
57 * Added sorted for Contacts.. 61 * Added sorted for Contacts..
58 * 62 *
59 * Revision 1.5 2002/11/01 15:10:42 eilers 63 * Revision 1.5 2002/11/01 15:10:42 eilers
60 * Added regExp-search in database for all fields in a contact. 64 * Added regExp-search in database for all fields in a contact.
61 * 65 *
62 * Revision 1.4 2002/10/16 10:52:40 eilers 66 * Revision 1.4 2002/10/16 10:52:40 eilers
63 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 67 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
64 * 68 *
65 * Revision 1.3 2002/10/14 16:21:54 eilers 69 * Revision 1.3 2002/10/14 16:21:54 eilers
66 * Some minor interface updates 70 * Some minor interface updates
67 * 71 *
@@ -280,97 +284,97 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
280 checkDate = new QDate( (*it)->birthday() ); 284 checkDate = new QDate( (*it)->birthday() );
281 case Qtopia::Anniversary: 285 case Qtopia::Anniversary:
282 if ( queryDate == 0l ){ 286 if ( queryDate == 0l ){
283 queryDate = new QDate( query.anniversary() ); 287 queryDate = new QDate( query.anniversary() );
284 checkDate = new QDate( (*it)->anniversary() ); 288 checkDate = new QDate( (*it)->anniversary() );
285 } 289 }
286 290
287 if ( queryDate->isValid() ){ 291 if ( queryDate->isValid() ){
288 if( checkDate->isValid() ){ 292 if( checkDate->isValid() ){
289 if ( settings & OContactAccess::DateYear ){ 293 if ( settings & OContactAccess::DateYear ){
290 if ( queryDate->year() != checkDate->year() ) 294 if ( queryDate->year() != checkDate->year() )
291 allcorrect = false; 295 allcorrect = false;
292 } 296 }
293 if ( settings & OContactAccess::DateMonth ){ 297 if ( settings & OContactAccess::DateMonth ){
294 if ( queryDate->month() != checkDate->month() ) 298 if ( queryDate->month() != checkDate->month() )
295 allcorrect = false; 299 allcorrect = false;
296 } 300 }
297 if ( settings & OContactAccess::DateDay ){ 301 if ( settings & OContactAccess::DateDay ){
298 if ( queryDate->day() != checkDate->day() ) 302 if ( queryDate->day() != checkDate->day() )
299 allcorrect = false; 303 allcorrect = false;
300 } 304 }
301 if ( settings & OContactAccess::DateDiff ) { 305 if ( settings & OContactAccess::DateDiff ) {
302 QDate current; 306 QDate current;
303 // If we get an additional date, we 307 // If we get an additional date, we
304 // will take this date instead of 308 // will take this date instead of
305 // the current one.. 309 // the current one..
306 if ( !d.date().isValid() ) 310 if ( !d.date().isValid() )
307 current = QDate::currentDate(); 311 current = QDate::currentDate();
308 else 312 else
309 current = d.date(); 313 current = d.date();
310 314
311 // We have to equalize the year, otherwise 315 // We have to equalize the year, otherwise
312 // the search will fail.. 316 // the search will fail..
313 checkDate->setYMD( current.year(), 317 checkDate->setYMD( current.year(),
314 checkDate->month(), 318 checkDate->month(),
315 checkDate->day() ); 319 checkDate->day() );
316 if ( *checkDate < current ) 320 if ( *checkDate < current )
317 checkDate->setYMD( current.year()+1, 321 checkDate->setYMD( current.year()+1,
318 checkDate->month(), 322 checkDate->month(),
319 checkDate->day() ); 323 checkDate->day() );
320 324
321 // Check whether the birthday/anniversary date is between 325 // Check whether the birthday/anniversary date is between
322 // the current/given date and the maximum date 326 // the current/given date and the maximum date
323 // ( maximum time range ) ! 327 // ( maximum time range ) !
324 qWarning("Checking if %s is between %s and %s ! ", 328 qWarning("Checking if %s is between %s and %s ! ",
325 checkDate->toString().latin1(), 329 checkDate->toString().latin1(),
326 current.toString().latin1(), 330 current.toString().latin1(),
327 queryDate->toString().latin1() ); 331 queryDate->toString().latin1() );
328 if ( current.daysTo( *queryDate ) > 0 ){ 332 if ( current.daysTo( *queryDate ) >= 0 ){
329 if ( !( ( *checkDate >= current ) && 333 if ( !( ( *checkDate >= current ) &&
330 ( *checkDate <= *queryDate ) ) ){ 334 ( *checkDate <= *queryDate ) ) ){
331 allcorrect = false; 335 allcorrect = false;
332 qWarning (" Nope!.."); 336 qWarning (" Nope!..");
333 } 337 }
334 } 338 }
335 } 339 }
336 } else{ 340 } else{
337 // checkDate is invalid. Therefore this entry is always rejected 341 // checkDate is invalid. Therefore this entry is always rejected
338 allcorrect = false; 342 allcorrect = false;
339 } 343 }
340 } 344 }
341 345
342 delete queryDate; 346 delete queryDate;
343 queryDate = 0l; 347 queryDate = 0l;
344 delete checkDate; 348 delete checkDate;
345 checkDate = 0l; 349 checkDate = 0l;
346 break; 350 break;
347 default: 351 default:
348 /* Just compare fields which are not empty in the query object */ 352 /* Just compare fields which are not empty in the query object */
349 if ( !query.field(i).isEmpty() ){ 353 if ( !query.field(i).isEmpty() ){
350 switch ( settings & ~( OContactAccess::IgnoreCase 354 switch ( settings & ~( OContactAccess::IgnoreCase
351 | OContactAccess::DateDiff 355 | OContactAccess::DateDiff
352 | OContactAccess::DateYear 356 | OContactAccess::DateYear
353 | OContactAccess::DateMonth 357 | OContactAccess::DateMonth
354 | OContactAccess::DateDay 358 | OContactAccess::DateDay
355 | OContactAccess::MatchOne 359 | OContactAccess::MatchOne
356 ) ){ 360 ) ){
357 361
358 case OContactAccess::RegExp:{ 362 case OContactAccess::RegExp:{
359 QRegExp expr ( query.field(i), 363 QRegExp expr ( query.field(i),
360 !(settings & OContactAccess::IgnoreCase), 364 !(settings & OContactAccess::IgnoreCase),
361 false ); 365 false );
362 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 366 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
363 allcorrect = false; 367 allcorrect = false;
364 } 368 }
365 break; 369 break;
366 case OContactAccess::WildCards:{ 370 case OContactAccess::WildCards:{
367 QRegExp expr ( query.field(i), 371 QRegExp expr ( query.field(i),
368 !(settings & OContactAccess::IgnoreCase), 372 !(settings & OContactAccess::IgnoreCase),
369 true ); 373 true );
370 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 374 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
371 allcorrect = false; 375 allcorrect = false;
372 } 376 }
373 break; 377 break;
374 case OContactAccess::ExactMatch:{ 378 case OContactAccess::ExactMatch:{
375 if (settings & OContactAccess::IgnoreCase){ 379 if (settings & OContactAccess::IgnoreCase){
376 if ( query.field(i).upper() != 380 if ( query.field(i).upper() !=