-rw-r--r-- | kabc/addressbook.cpp | 8 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 48 | ||||
-rw-r--r-- | kabc/addressee.h | 2 |
4 files changed, 48 insertions, 14 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 19c26eb..8882259 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -864,5 +864,5 @@ Addressee AddressBook::findByUid( const QString &uid ) return Addressee(); } -void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) +void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) { //qDebug("AddressBook::preExternSync "); @@ -872,5 +872,5 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) (*it).computeCsum( csd ); } - mergeAB( aBook ,csd ); + mergeAB( aBook ,csd, isSubset ); } void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) @@ -914,5 +914,5 @@ Addressee AddressBook::findByExternUid( const QString& uid , const QString& pr return Addressee(); } -void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) +void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) { Iterator it; @@ -921,5 +921,5 @@ void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) ad = aBook->findByExternUid( (*it).externalUID(), profile ); if ( !ad.isEmpty() ) { - (*it).mergeContact( ad ); + (*it).mergeContact( ad ,isSubset); } } diff --git a/kabc/addressbook.h b/kabc/addressbook.h index df9048b..a6bf451 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -302,9 +302,9 @@ class AddressBook : public QObject QStringList uidList(); void removeSyncAddressees( bool removeDeleted = false ); - void mergeAB( AddressBook *aBook, const QString& profile ); + void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); Addressee findByExternUid( const QString& uid , const QString& profile ); bool containsExternalUid( const QString& uid ); - void preExternSync( AddressBook* aBook, const QString& csd ); + void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); void postExternSync( AddressBook* aBook, const QString& csd ); signals: diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2aca559..295ee4f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -300,5 +300,5 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) QStringList tAD; uint iii; - if ( isSubSet ) { + // ********** phone numbers PhoneNumber::List phoneAD = ad.phoneNumbers(); @@ -314,7 +314,8 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) } } - if ( ! found ) + if ( isSubSet && ! found ) mData->phoneNumbers.append( *phoneItAD ); } + if ( isSubSet ) { // ************* emails; t = mData->emails; @@ -323,4 +324,6 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) if ( !t.contains(tAD[iii] ) ) mData->emails.append( tAD[iii] ); + } + // ************* categories; t = mData->categories; @@ -329,8 +332,4 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) if ( !t.contains(tAD[iii] ) ) mData->categories.append( tAD[iii] ); - - - } - QStringList::ConstIterator it; for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { @@ -390,5 +389,5 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) } - if ( ! found ) { + if ( isSubSet && ! found ) { mData->addresses.append( *addressIterA ); } @@ -479,6 +478,41 @@ void Addressee::simplifyEmails() 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(); ++phoneIter ) { diff --git a/kabc/addressee.h b/kabc/addressee.h index e7900c6..2c81c1a 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -117,5 +117,5 @@ class Addressee void setOriginalExternalUID( const QString &id ); QString originalExternalUID() const; - void mergeContact( const Addressee& ad, bool isSubSet = false ); + void mergeContact( const Addressee& ad, bool isSubSet ); void simplifyEmails(); void simplifyAddresses(); |