summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 295ee4f..2564894 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -426,55 +426,73 @@ bool Addressee::containsAdr(const Addressee& ad )
426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
427 427
428 // compare phone numbers 428 // compare phone numbers
429 PhoneNumber::List phoneN = ad.phoneNumbers(); 429 PhoneNumber::List phoneN = ad.phoneNumbers();
430 PhoneNumber::List::Iterator phoneIt; 430 PhoneNumber::List::Iterator phoneIt;
431 bool found = false; 431 bool found = false;
432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
433 bool found = false; 433 bool found = false;
434 PhoneNumber::List phoneL = ad.phoneNumbers(); 434 PhoneNumber::List phoneL = ad.phoneNumbers();
435 PhoneNumber::List::Iterator phoneItL; 435 PhoneNumber::List::Iterator phoneItL;
436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
438 found = true; 438 found = true;
439 break; 439 break;
440 } 440 }
441 } 441 }
442 if ( ! found ) 442 if ( ! found )
443 return false; 443 return false;
444 } 444 }
445 return true; 445 return true;
446 446
447} 447}
448void Addressee::simplifyAddresses() 448void Addressee::simplifyAddresses()
449{ 449{
450
451
452 Address::List list;
453 Address::List::Iterator it;
454 Address::List::Iterator it2;
455 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
456 it2 = it;
457 ++it2;
458 for( ; it2 != mData->addresses.end(); ++it2 ) {
459 if ( (*it) == (*it2) ) {
460 list.append( *it );
461 break;
462 }
463 }
464 }
465 for( it = list.begin(); it != list.end(); ++it ) {
466 removeAddress( (*it) );
467 }
468
469 list.clear();
450 int max = 2; 470 int max = 2;
451 if ( mData->url.isValid() ) 471 if ( mData->url.isValid() )
452 max = 1; 472 max = 1;
453 if ( mData->addresses.count() <= max ) return ; 473 if ( mData->addresses.count() <= max ) return ;
454 int count = 0; 474 int count = 0;
455 Address::List list;
456 Address::List::Iterator it;
457 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 475 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
458 if ( count >= max ) 476 if ( count >= max )
459 list.append( *it ); 477 list.append( *it );
460 ++count; 478 ++count;
461 } 479 }
462 for( it = list.begin(); it != list.end(); ++it ) { 480 for( it = list.begin(); it != list.end(); ++it ) {
463 removeAddress( (*it) ); 481 removeAddress( (*it) );
464 } 482 }
465} 483}
466 484
467// removes all emails but the first 485// removes all emails but the first
468// needed by phone sync 486// needed by phone sync
469void Addressee::simplifyEmails() 487void Addressee::simplifyEmails()
470{ 488{
471 if ( mData->emails.count() == 0 ) return ; 489 if ( mData->emails.count() == 0 ) return ;
472 QString email = mData->emails.first(); 490 QString email = mData->emails.first();
473 detach(); 491 detach();
474 mData->emails.clear(); 492 mData->emails.clear();
475 mData->emails.append( email ); 493 mData->emails.append( email );
476} 494}
477 495
478void Addressee::simplifyPhoneNumbers() 496void Addressee::simplifyPhoneNumbers()
479{ 497{
480 int max = 4; 498 int max = 4;