summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp75
1 files changed, 68 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 16e1653..ec9f893 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -235,4 +235,5 @@ AddressBook::AddressBook( const QString &config, const QString &family )
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false;
237 d = new AddressBookData; 238 d = new AddressBookData;
238 QString fami = family; 239 QString fami = family;
@@ -346,4 +347,5 @@ bool AddressBook::load()
346 (*addrIt).setChanged( false ); 347 (*addrIt).setChanged( false );
347 348
349 blockLSEchange = true;
348 return ok; 350 return ok;
349} 351}
@@ -448,10 +450,12 @@ Ticket *AddressBook::requestSaveTicket( Resource *resource )
448void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 450void AddressBook::insertAddressee( const Addressee &a, bool setRev )
449{ 451{
452 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
453 return;
454 }
455 bool found = false;
450 Addressee::List::Iterator it; 456 Addressee::List::Iterator it;
451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 457 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
452 if ( a.uid() == (*it).uid() ) { 458 if ( a.uid() == (*it).uid() ) {
453 if ( setRev && (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 459
454 return;
455 }
456 bool changed = false; 460 bool changed = false;
457 Addressee addr = a; 461 Addressee addr = a;
@@ -475,7 +479,24 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev )
475 } 479 }
476 480
477 return; 481 found = true;
482 } else {
483 if ( (*it).uid() == QString("last-syncAddressee-") ) {
484 QString name = (*it).uid().mid( 19 );
485 Addressee b = a;
486 QString id = b.getID( name );
487 if ( ! id.isEmpty() ) {
488 QString des = (*it).note();
489 int startN;
490 if( (startN = des.find( id ) ) >= 0 ) {
491 int endN = des.find( ",", startN+1 );
492 des = des.left( startN ) + des.mid( endN+1 );
493 (*it).setNote( des );
494 }
478 } 495 }
479 } 496 }
497 }
498 }
499 if ( found )
500 return;
480 d->mAddressees.append( a ); 501 d->mAddressees.append( a );
481 Addressee& addr = d->mAddressees.last(); 502 Addressee& addr = d->mAddressees.last();
@@ -489,10 +510,48 @@ void AddressBook::removeAddressee( const Addressee &a )
489{ 510{
490 Iterator it; 511 Iterator it;
512 Iterator it2;
513 bool found = false;
491 for ( it = begin(); it != end(); ++it ) { 514 for ( it = begin(); it != end(); ++it ) {
492 if ( a.uid() == (*it).uid() ) { 515 if ( a.uid() == (*it).uid() ) {
493 removeAddressee( it ); 516 found = true;
494 return; 517 it2 = it;
518 } else {
519 if ( (*it).uid() == QString("last-syncAddressee-") ) {
520 QString name = (*it).uid().mid( 19 );
521 Addressee b = a;
522 QString id = b.getID( name );
523 if ( ! id.isEmpty() ) {
524 QString des = (*it).note();
525 if( des.find( id ) < 0 ) {
526 des += id + ",";
527 (*it).setNote( des );
528 }
495 } 529 }
496 } 530 }
531
532 }
533 }
534
535 if ( found )
536 removeAddressee( it2 );
537
538}
539
540void AddressBook::removeDeletedAddressees()
541{
542 deleteRemovedAddressees();
543 Iterator it = begin();
544 Iterator it2 ;
545 QDateTime dt ( QDate( 2004,1,1) );
546 while ( it != end() ) {
547 (*it).setRevision( dt );
548 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
549 it2 = it;
550 ++it;
551 removeAddressee( it2 );
552 } else
553 ++it;
554 }
555 deleteRemovedAddressees();
497} 556}
498 557
@@ -524,4 +583,5 @@ Addressee AddressBook::findByUid( const QString &uid )
524 return Addressee(); 583 return Addressee();
525} 584}
585#if 0
526Addressee::List AddressBook::getExternLastSyncAddressees() 586Addressee::List AddressBook::getExternLastSyncAddressees()
527{ 587{
@@ -531,5 +591,5 @@ Addressee::List AddressBook::getExternLastSyncAddressees()
531 for ( it = begin(); it != end(); ++it ) { 591 for ( it = begin(); it != end(); ++it ) {
532 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 592 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
533 if ( (*it).familyName().left(3) == "E: " ) 593 if ( (*it).familyName().left(4) == "!E: " )
534 results.append( *it ); 594 results.append( *it );
535 } 595 }
@@ -538,4 +598,5 @@ Addressee::List AddressBook::getExternLastSyncAddressees()
538 return results; 598 return results;
539} 599}
600#endif
540void AddressBook::resetTempSyncStat() 601void AddressBook::resetTempSyncStat()
541{ 602{