summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.cpp22
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp22
2 files changed, 44 insertions, 0 deletions
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp
index 661cd51..097142b 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -1,67 +1,70 @@
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.6 2003/07/07 16:19:47 eilers
21 * Fixing serious bug in hasQuerySettings()
22 *
20 * Revision 1.5 2003/04/13 18:07:10 zecke 23 * Revision 1.5 2003/04/13 18:07:10 zecke
21 * More API doc 24 * More API doc
22 * QString -> const QString& 25 * QString -> const QString&
23 * QString = 0l -> QString::null 26 * QString = 0l -> QString::null
24 * 27 *
25 * Revision 1.4 2003/03/21 14:32:54 mickeyl 28 * Revision 1.4 2003/03/21 14:32:54 mickeyl
26 * g++ compliance fix: default arguments belong into the declaration, but not the definition 29 * g++ compliance fix: default arguments belong into the declaration, but not the definition
27 * 30 *
28 * Revision 1.3 2003/03/21 12:26:28 eilers 31 * Revision 1.3 2003/03/21 12:26:28 eilers
29 * Fixing small bug: If we search a birthday from today to today, it returned 32 * Fixing small bug: If we search a birthday from today to today, it returned
30 * every contact .. 33 * every contact ..
31 * 34 *
32 * Revision 1.2 2003/03/21 10:33:09 eilers 35 * Revision 1.2 2003/03/21 10:33:09 eilers
33 * Merged speed optimized xml backend for contacts to main. 36 * Merged speed optimized xml backend for contacts to main.
34 * Added QDateTime to querybyexample. For instance, it is now possible to get 37 * Added QDateTime to querybyexample. For instance, it is now possible to get
35 * all Birthdays/Anniversaries between two dates. This should be used 38 * all Birthdays/Anniversaries between two dates. This should be used
36 * to show all birthdays in the datebook.. 39 * to show all birthdays in the datebook..
37 * This change is sourcecode backward compatible but you have to upgrade 40 * This change is sourcecode backward compatible but you have to upgrade
38 * the binaries for today-addressbook. 41 * the binaries for today-addressbook.
39 * 42 *
40 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 43 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
41 * Speed optimization. Removed the sequential search loops. 44 * Speed optimization. Removed the sequential search loops.
42 * 45 *
43 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers 46 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
44 * Writing offsets to debug output.. 47 * Writing offsets to debug output..
45 * 48 *
46 * Revision 1.1 2003/02/09 15:05:01 eilers 49 * Revision 1.1 2003/02/09 15:05:01 eilers
47 * Nothing happened.. Just some cleanup before I will start.. 50 * Nothing happened.. Just some cleanup before I will start..
48 * 51 *
49 * Revision 1.12 2003/01/03 16:58:03 eilers 52 * Revision 1.12 2003/01/03 16:58:03 eilers
50 * Reenable debug output 53 * Reenable debug output
51 * 54 *
52 * Revision 1.11 2003/01/03 12:31:28 eilers 55 * Revision 1.11 2003/01/03 12:31:28 eilers
53 * Bugfix for calculating data diffs.. 56 * Bugfix for calculating data diffs..
54 * 57 *
55 * Revision 1.10 2003/01/02 14:27:12 eilers 58 * Revision 1.10 2003/01/02 14:27:12 eilers
56 * Improved query by example: Search by date is possible.. First step 59 * Improved query by example: Search by date is possible.. First step
57 * for a today plugin for birthdays.. 60 * for a today plugin for birthdays..
58 * 61 *
59 * Revision 1.9 2002/12/08 12:48:57 eilers 62 * Revision 1.9 2002/12/08 12:48:57 eilers
60 * Moved journal-enum from ocontact into i the xml-backend.. 63 * Moved journal-enum from ocontact into i the xml-backend..
61 * 64 *
62 * Revision 1.8 2002/11/14 17:04:24 eilers 65 * Revision 1.8 2002/11/14 17:04:24 eilers
63 * Sorting will now work if fullname is identical on some entries 66 * Sorting will now work if fullname is identical on some entries
64 * 67 *
65 * Revision 1.7 2002/11/13 15:02:46 eilers 68 * Revision 1.7 2002/11/13 15:02:46 eilers
66 * Small Bug in sorted fixed 69 * Small Bug in sorted fixed
67 * 70 *
@@ -402,112 +405,131 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
402 m_currentQuery[arraycounter++] = (*it)->uid(); 405 m_currentQuery[arraycounter++] = (*it)->uid();
403 } 406 }
404 } 407 }
405 408
406 // Shrink to fit.. 409 // Shrink to fit..
407 m_currentQuery.resize(arraycounter); 410 m_currentQuery.resize(arraycounter);
408 411
409 return m_currentQuery; 412 return m_currentQuery;
410} 413}
411 414
412QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const 415QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
413{ 416{
414 QArray<int> m_currentQuery( m_contactList.count() ); 417 QArray<int> m_currentQuery( m_contactList.count() );
415 QListIterator<OContact> it( m_contactList ); 418 QListIterator<OContact> it( m_contactList );
416 uint arraycounter = 0; 419 uint arraycounter = 0;
417 420
418 for( ; it.current(); ++it ){ 421 for( ; it.current(); ++it ){
419 if ( (*it)->match( r ) ){ 422 if ( (*it)->match( r ) ){
420 m_currentQuery[arraycounter++] = (*it)->uid(); 423 m_currentQuery[arraycounter++] = (*it)->uid();
421 } 424 }
422 425
423 } 426 }
424 // Shrink to fit.. 427 // Shrink to fit..
425 m_currentQuery.resize(arraycounter); 428 m_currentQuery.resize(arraycounter);
426 429
427 return m_currentQuery; 430 return m_currentQuery;
428} 431}
429 432
430const uint OContactAccessBackend_XML::querySettings() 433const uint OContactAccessBackend_XML::querySettings()
431{ 434{
432 return ( OContactAccess::WildCards 435 return ( OContactAccess::WildCards
433 | OContactAccess::IgnoreCase 436 | OContactAccess::IgnoreCase
434 | OContactAccess::RegExp 437 | OContactAccess::RegExp
435 | OContactAccess::ExactMatch 438 | OContactAccess::ExactMatch
436 | OContactAccess::DateDiff 439 | OContactAccess::DateDiff
437 | OContactAccess::DateYear 440 | OContactAccess::DateYear
438 | OContactAccess::DateMonth 441 | OContactAccess::DateMonth
439 | OContactAccess::DateDay 442 | OContactAccess::DateDay
440 ); 443 );
441} 444}
442 445
443bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const 446bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
444{ 447{
445 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 448 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
446 * may be added with any of the other settings. IgnoreCase should never used alone. 449 * may be added with any of the other settings. IgnoreCase should never used alone.
447 * Wildcards, RegExp, ExactMatch should never used at the same time... 450 * Wildcards, RegExp, ExactMatch should never used at the same time...
448 */ 451 */
449 452
453 // Step 1: Check whether the given settings are supported by this backend
454 if ( ( querySettings & (
455 OContactAccess::IgnoreCase
456 | OContactAccess::WildCards
457 | OContactAccess::DateDiff
458 | OContactAccess::DateYear
459 | OContactAccess::DateMonth
460 | OContactAccess::DateDay
461 | OContactAccess::RegExp
462 | OContactAccess::ExactMatch
463 ) ) != querySettings )
464 return false;
465
466 // Step 2: Check whether the given combinations are ok..
467
468 // IngoreCase alone is invalid
450 if ( querySettings == OContactAccess::IgnoreCase ) 469 if ( querySettings == OContactAccess::IgnoreCase )
451 return false; 470 return false;
452 471
472 // WildCards, RegExp and ExactMatch should never used at the same time
453 switch ( querySettings & ~( OContactAccess::IgnoreCase 473 switch ( querySettings & ~( OContactAccess::IgnoreCase
454 | OContactAccess::DateDiff 474 | OContactAccess::DateDiff
455 | OContactAccess::DateYear 475 | OContactAccess::DateYear
456 | OContactAccess::DateMonth 476 | OContactAccess::DateMonth
457 | OContactAccess::DateDay 477 | OContactAccess::DateDay
458 ) 478 )
459 ){ 479 ){
460 case OContactAccess::RegExp: 480 case OContactAccess::RegExp:
461 return ( true ); 481 return ( true );
462 case OContactAccess::WildCards: 482 case OContactAccess::WildCards:
463 return ( true ); 483 return ( true );
464 case OContactAccess::ExactMatch: 484 case OContactAccess::ExactMatch:
465 return ( true ); 485 return ( true );
486 case 0: // one of the upper removed bits were set..
487 return ( true );
466 default: 488 default:
467 return ( false ); 489 return ( false );
468 } 490 }
469} 491}
470 492
471// Currently only asc implemented.. 493// Currently only asc implemented..
472QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) 494QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
473{ 495{
474 QMap<QString, int> nameToUid; 496 QMap<QString, int> nameToUid;
475 QStringList names; 497 QStringList names;
476 QArray<int> m_currentQuery( m_contactList.count() ); 498 QArray<int> m_currentQuery( m_contactList.count() );
477 499
478 // First fill map and StringList with all Names 500 // First fill map and StringList with all Names
479 // Afterwards sort namelist and use map to fill array to return.. 501 // Afterwards sort namelist and use map to fill array to return..
480 QListIterator<OContact> it( m_contactList ); 502 QListIterator<OContact> it( m_contactList );
481 for( ; it.current(); ++it ){ 503 for( ; it.current(); ++it ){
482 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); 504 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
483 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); 505 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
484 } 506 }
485 names.sort(); 507 names.sort();
486 508
487 int i = 0; 509 int i = 0;
488 if ( asc ){ 510 if ( asc ){
489 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) 511 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
490 m_currentQuery[i++] = nameToUid[ (*it) ]; 512 m_currentQuery[i++] = nameToUid[ (*it) ];
491 }else{ 513 }else{
492 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) 514 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
493 m_currentQuery[i++] = nameToUid[ (*it) ]; 515 m_currentQuery[i++] = nameToUid[ (*it) ];
494 } 516 }
495 517
496 return m_currentQuery; 518 return m_currentQuery;
497 519
498} 520}
499 521
500bool OContactAccessBackend_XML::add ( const OContact &newcontact ) 522bool OContactAccessBackend_XML::add ( const OContact &newcontact )
501{ 523{
502 //qWarning("odefaultbackend: ACTION::ADD"); 524 //qWarning("odefaultbackend: ACTION::ADD");
503 updateJournal (newcontact, ACTION_ADD); 525 updateJournal (newcontact, ACTION_ADD);
504 addContact_p( newcontact ); 526 addContact_p( newcontact );
505 527
506 m_changed = true; 528 m_changed = true;
507 529
508 return true; 530 return true;
509} 531}
510 532
511bool OContactAccessBackend_XML::replace ( const OContact &contact ) 533bool OContactAccessBackend_XML::replace ( const OContact &contact )
512{ 534{
513 m_changed = true; 535 m_changed = true;
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 661cd51..097142b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,67 +1,70 @@
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.6 2003/07/07 16:19:47 eilers
21 * Fixing serious bug in hasQuerySettings()
22 *
20 * Revision 1.5 2003/04/13 18:07:10 zecke 23 * Revision 1.5 2003/04/13 18:07:10 zecke
21 * More API doc 24 * More API doc
22 * QString -> const QString& 25 * QString -> const QString&
23 * QString = 0l -> QString::null 26 * QString = 0l -> QString::null
24 * 27 *
25 * Revision 1.4 2003/03/21 14:32:54 mickeyl 28 * Revision 1.4 2003/03/21 14:32:54 mickeyl
26 * g++ compliance fix: default arguments belong into the declaration, but not the definition 29 * g++ compliance fix: default arguments belong into the declaration, but not the definition
27 * 30 *
28 * Revision 1.3 2003/03/21 12:26:28 eilers 31 * Revision 1.3 2003/03/21 12:26:28 eilers
29 * Fixing small bug: If we search a birthday from today to today, it returned 32 * Fixing small bug: If we search a birthday from today to today, it returned
30 * every contact .. 33 * every contact ..
31 * 34 *
32 * Revision 1.2 2003/03/21 10:33:09 eilers 35 * Revision 1.2 2003/03/21 10:33:09 eilers
33 * Merged speed optimized xml backend for contacts to main. 36 * Merged speed optimized xml backend for contacts to main.
34 * Added QDateTime to querybyexample. For instance, it is now possible to get 37 * Added QDateTime to querybyexample. For instance, it is now possible to get
35 * all Birthdays/Anniversaries between two dates. This should be used 38 * all Birthdays/Anniversaries between two dates. This should be used
36 * to show all birthdays in the datebook.. 39 * to show all birthdays in the datebook..
37 * This change is sourcecode backward compatible but you have to upgrade 40 * This change is sourcecode backward compatible but you have to upgrade
38 * the binaries for today-addressbook. 41 * the binaries for today-addressbook.
39 * 42 *
40 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 43 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
41 * Speed optimization. Removed the sequential search loops. 44 * Speed optimization. Removed the sequential search loops.
42 * 45 *
43 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers 46 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
44 * Writing offsets to debug output.. 47 * Writing offsets to debug output..
45 * 48 *
46 * Revision 1.1 2003/02/09 15:05:01 eilers 49 * Revision 1.1 2003/02/09 15:05:01 eilers
47 * Nothing happened.. Just some cleanup before I will start.. 50 * Nothing happened.. Just some cleanup before I will start..
48 * 51 *
49 * Revision 1.12 2003/01/03 16:58:03 eilers 52 * Revision 1.12 2003/01/03 16:58:03 eilers
50 * Reenable debug output 53 * Reenable debug output
51 * 54 *
52 * Revision 1.11 2003/01/03 12:31:28 eilers 55 * Revision 1.11 2003/01/03 12:31:28 eilers
53 * Bugfix for calculating data diffs.. 56 * Bugfix for calculating data diffs..
54 * 57 *
55 * Revision 1.10 2003/01/02 14:27:12 eilers 58 * Revision 1.10 2003/01/02 14:27:12 eilers
56 * Improved query by example: Search by date is possible.. First step 59 * Improved query by example: Search by date is possible.. First step
57 * for a today plugin for birthdays.. 60 * for a today plugin for birthdays..
58 * 61 *
59 * Revision 1.9 2002/12/08 12:48:57 eilers 62 * Revision 1.9 2002/12/08 12:48:57 eilers
60 * Moved journal-enum from ocontact into i the xml-backend.. 63 * Moved journal-enum from ocontact into i the xml-backend..
61 * 64 *
62 * Revision 1.8 2002/11/14 17:04:24 eilers 65 * Revision 1.8 2002/11/14 17:04:24 eilers
63 * Sorting will now work if fullname is identical on some entries 66 * Sorting will now work if fullname is identical on some entries
64 * 67 *
65 * Revision 1.7 2002/11/13 15:02:46 eilers 68 * Revision 1.7 2002/11/13 15:02:46 eilers
66 * Small Bug in sorted fixed 69 * Small Bug in sorted fixed
67 * 70 *
@@ -402,112 +405,131 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
402 m_currentQuery[arraycounter++] = (*it)->uid(); 405 m_currentQuery[arraycounter++] = (*it)->uid();
403 } 406 }
404 } 407 }
405 408
406 // Shrink to fit.. 409 // Shrink to fit..
407 m_currentQuery.resize(arraycounter); 410 m_currentQuery.resize(arraycounter);
408 411
409 return m_currentQuery; 412 return m_currentQuery;
410} 413}
411 414
412QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const 415QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
413{ 416{
414 QArray<int> m_currentQuery( m_contactList.count() ); 417 QArray<int> m_currentQuery( m_contactList.count() );
415 QListIterator<OContact> it( m_contactList ); 418 QListIterator<OContact> it( m_contactList );
416 uint arraycounter = 0; 419 uint arraycounter = 0;
417 420
418 for( ; it.current(); ++it ){ 421 for( ; it.current(); ++it ){
419 if ( (*it)->match( r ) ){ 422 if ( (*it)->match( r ) ){
420 m_currentQuery[arraycounter++] = (*it)->uid(); 423 m_currentQuery[arraycounter++] = (*it)->uid();
421 } 424 }
422 425
423 } 426 }
424 // Shrink to fit.. 427 // Shrink to fit..
425 m_currentQuery.resize(arraycounter); 428 m_currentQuery.resize(arraycounter);
426 429
427 return m_currentQuery; 430 return m_currentQuery;
428} 431}
429 432
430const uint OContactAccessBackend_XML::querySettings() 433const uint OContactAccessBackend_XML::querySettings()
431{ 434{
432 return ( OContactAccess::WildCards 435 return ( OContactAccess::WildCards
433 | OContactAccess::IgnoreCase 436 | OContactAccess::IgnoreCase
434 | OContactAccess::RegExp 437 | OContactAccess::RegExp
435 | OContactAccess::ExactMatch 438 | OContactAccess::ExactMatch
436 | OContactAccess::DateDiff 439 | OContactAccess::DateDiff
437 | OContactAccess::DateYear 440 | OContactAccess::DateYear
438 | OContactAccess::DateMonth 441 | OContactAccess::DateMonth
439 | OContactAccess::DateDay 442 | OContactAccess::DateDay
440 ); 443 );
441} 444}
442 445
443bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const 446bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
444{ 447{
445 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 448 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
446 * may be added with any of the other settings. IgnoreCase should never used alone. 449 * may be added with any of the other settings. IgnoreCase should never used alone.
447 * Wildcards, RegExp, ExactMatch should never used at the same time... 450 * Wildcards, RegExp, ExactMatch should never used at the same time...
448 */ 451 */
449 452
453 // Step 1: Check whether the given settings are supported by this backend
454 if ( ( querySettings & (
455 OContactAccess::IgnoreCase
456 | OContactAccess::WildCards
457 | OContactAccess::DateDiff
458 | OContactAccess::DateYear
459 | OContactAccess::DateMonth
460 | OContactAccess::DateDay
461 | OContactAccess::RegExp
462 | OContactAccess::ExactMatch
463 ) ) != querySettings )
464 return false;
465
466 // Step 2: Check whether the given combinations are ok..
467
468 // IngoreCase alone is invalid
450 if ( querySettings == OContactAccess::IgnoreCase ) 469 if ( querySettings == OContactAccess::IgnoreCase )
451 return false; 470 return false;
452 471
472 // WildCards, RegExp and ExactMatch should never used at the same time
453 switch ( querySettings & ~( OContactAccess::IgnoreCase 473 switch ( querySettings & ~( OContactAccess::IgnoreCase
454 | OContactAccess::DateDiff 474 | OContactAccess::DateDiff
455 | OContactAccess::DateYear 475 | OContactAccess::DateYear
456 | OContactAccess::DateMonth 476 | OContactAccess::DateMonth
457 | OContactAccess::DateDay 477 | OContactAccess::DateDay
458 ) 478 )
459 ){ 479 ){
460 case OContactAccess::RegExp: 480 case OContactAccess::RegExp:
461 return ( true ); 481 return ( true );
462 case OContactAccess::WildCards: 482 case OContactAccess::WildCards:
463 return ( true ); 483 return ( true );
464 case OContactAccess::ExactMatch: 484 case OContactAccess::ExactMatch:
465 return ( true ); 485 return ( true );
486 case 0: // one of the upper removed bits were set..
487 return ( true );
466 default: 488 default:
467 return ( false ); 489 return ( false );
468 } 490 }
469} 491}
470 492
471// Currently only asc implemented.. 493// Currently only asc implemented..
472QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) 494QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
473{ 495{
474 QMap<QString, int> nameToUid; 496 QMap<QString, int> nameToUid;
475 QStringList names; 497 QStringList names;
476 QArray<int> m_currentQuery( m_contactList.count() ); 498 QArray<int> m_currentQuery( m_contactList.count() );
477 499
478 // First fill map and StringList with all Names 500 // First fill map and StringList with all Names
479 // Afterwards sort namelist and use map to fill array to return.. 501 // Afterwards sort namelist and use map to fill array to return..
480 QListIterator<OContact> it( m_contactList ); 502 QListIterator<OContact> it( m_contactList );
481 for( ; it.current(); ++it ){ 503 for( ; it.current(); ++it ){
482 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); 504 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
483 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); 505 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
484 } 506 }
485 names.sort(); 507 names.sort();
486 508
487 int i = 0; 509 int i = 0;
488 if ( asc ){ 510 if ( asc ){
489 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) 511 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
490 m_currentQuery[i++] = nameToUid[ (*it) ]; 512 m_currentQuery[i++] = nameToUid[ (*it) ];
491 }else{ 513 }else{
492 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) 514 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
493 m_currentQuery[i++] = nameToUid[ (*it) ]; 515 m_currentQuery[i++] = nameToUid[ (*it) ];
494 } 516 }
495 517
496 return m_currentQuery; 518 return m_currentQuery;
497 519
498} 520}
499 521
500bool OContactAccessBackend_XML::add ( const OContact &newcontact ) 522bool OContactAccessBackend_XML::add ( const OContact &newcontact )
501{ 523{
502 //qWarning("odefaultbackend: ACTION::ADD"); 524 //qWarning("odefaultbackend: ACTION::ADD");
503 updateJournal (newcontact, ACTION_ADD); 525 updateJournal (newcontact, ACTION_ADD);
504 addContact_p( newcontact ); 526 addContact_p( newcontact );
505 527
506 m_changed = true; 528 m_changed = true;
507 529
508 return true; 530 return true;
509} 531}
510 532
511bool OContactAccessBackend_XML::replace ( const OContact &contact ) 533bool OContactAccessBackend_XML::replace ( const OContact &contact )
512{ 534{
513 m_changed = true; 535 m_changed = true;