author | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
commit | d41893fb0a49fbb080326a4c1fd98e1a032a182a (patch) (unidiff) | |
tree | 9b95603ff93801accaa94de4b73d88ea9c5c9386 /kabc/addressee.cpp | |
parent | efdd0735bda81dcd82dfb6d6dc0d0c143f249336 (diff) | |
download | kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.zip kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.gz kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.bz2 |
merge contact fixes
-rw-r--r-- | kabc/addressee.cpp | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2aca559..295ee4f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -299,7 +299,7 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | if ( isSubSet ) { | 302 | |
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
@@ -313,25 +313,24 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | if ( ! found ) | 316 | if ( isSubSet && ! found ) |
317 | mData->phoneNumbers.append( *phoneItAD ); | 317 | mData->phoneNumbers.append( *phoneItAD ); |
318 | } | 318 | } |
319 | if ( isSubSet ) { | ||
319 | // ************* emails; | 320 | // ************* emails; |
320 | t = mData->emails; | 321 | t = mData->emails; |
321 | tAD = ad.mData->emails; | 322 | tAD = ad.mData->emails; |
322 | for ( iii = 0; iii < tAD.count(); ++iii) | 323 | for ( iii = 0; iii < tAD.count(); ++iii) |
323 | if ( !t.contains(tAD[iii] ) ) | 324 | if ( !t.contains(tAD[iii] ) ) |
324 | mData->emails.append( tAD[iii] ); | 325 | mData->emails.append( tAD[iii] ); |
326 | } | ||
327 | |||
325 | // ************* categories; | 328 | // ************* categories; |
326 | t = mData->categories; | 329 | t = mData->categories; |
327 | tAD = ad.mData->categories; | 330 | tAD = ad.mData->categories; |
328 | for ( iii = 0; iii < tAD.count(); ++iii) | 331 | for ( iii = 0; iii < tAD.count(); ++iii) |
329 | if ( !t.contains(tAD[iii] ) ) | 332 | if ( !t.contains(tAD[iii] ) ) |
330 | mData->categories.append( tAD[iii] ); | 333 | mData->categories.append( tAD[iii] ); |
331 | |||
332 | |||
333 | } | ||
334 | |||
335 | QStringList::ConstIterator it; | 334 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 336 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
@@ -389,7 +388,7 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
389 | } | 388 | } |
390 | 389 | ||
391 | } | 390 | } |
392 | if ( ! found ) { | 391 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 392 | mData->addresses.append( *addressIterA ); |
394 | } | 393 | } |
395 | } | 394 | } |
@@ -478,8 +477,43 @@ void Addressee::simplifyEmails() | |||
478 | 477 | ||
479 | void Addressee::simplifyPhoneNumbers() | 478 | void Addressee::simplifyPhoneNumbers() |
480 | { | 479 | { |
480 | int max = 4; | ||
481 | int inList = mData->phoneNumbers.count(); | ||
481 | KABC::PhoneNumber::List removeNumbers; | 482 | KABC::PhoneNumber::List removeNumbers; |
482 | KABC::PhoneNumber::List::Iterator phoneIter; | 483 | KABC::PhoneNumber::List::Iterator phoneIter; |
484 | if ( inList > max ) { | ||
485 | // delete non-preferred numbers | ||
486 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
487 | ++phoneIter ) { | ||
488 | if ( inList > max ) { | ||
489 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | ||
490 | removeNumbers.append( ( *phoneIter ) ); | ||
491 | --inList; | ||
492 | } | ||
493 | } else | ||
494 | break; | ||
495 | } | ||
496 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
497 | ++phoneIter ) { | ||
498 | removePhoneNumber(( *phoneIter )); | ||
499 | } | ||
500 | // delete preferred numbers | ||
501 | if ( inList > max ) { | ||
502 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
503 | ++phoneIter ) { | ||
504 | if ( inList > max ) { | ||
505 | removeNumbers.append( ( *phoneIter ) ); | ||
506 | --inList; | ||
507 | } else | ||
508 | break; | ||
509 | } | ||
510 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
511 | ++phoneIter ) { | ||
512 | removePhoneNumber(( *phoneIter )); | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | // remove non-numeric characters | ||
483 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 517 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
484 | ++phoneIter ) { | 518 | ++phoneIter ) { |
485 | if ( ! ( *phoneIter ).simplifyNumber() ) | 519 | if ( ! ( *phoneIter ).simplifyNumber() ) |