-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 @@ -301,3 +301,3 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) uint iii; - if ( isSubSet ) { + // ********** phone numbers @@ -315,5 +315,6 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) } - if ( ! found ) + if ( isSubSet && ! found ) mData->phoneNumbers.append( *phoneItAD ); } + if ( isSubSet ) { // ************* emails; @@ -324,2 +325,4 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) mData->emails.append( tAD[iii] ); + } + // ************* categories; @@ -330,6 +333,2 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) mData->categories.append( tAD[iii] ); - - - } - QStringList::ConstIterator it; @@ -391,3 +390,3 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) } - if ( ! found ) { + if ( isSubSet && ! found ) { mData->addresses.append( *addressIterA ); @@ -480,4 +479,39 @@ void Addressee::simplifyPhoneNumbers() { + int max = 4; + int inList = mData->phoneNumbers.count(); KABC::PhoneNumber::List removeNumbers; KABC::PhoneNumber::List::Iterator phoneIter; + if ( inList > max ) { + // delete non-preferred numbers + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + if ( inList > max ) { + if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { + removeNumbers.append( ( *phoneIter ) ); + --inList; + } + } else + break; + } + for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); + ++phoneIter ) { + removePhoneNumber(( *phoneIter )); + } + // delete preferred numbers + if ( inList > max ) { + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + if ( inList > max ) { + removeNumbers.append( ( *phoneIter ) ); + --inList; + } else + break; + } + for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); + ++phoneIter ) { + removePhoneNumber(( *phoneIter )); + } + } + } + // remove non-numeric characters for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |