summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp8
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp48
-rw-r--r--kabc/addressee.h2
-rw-r--r--kaddressbook/kabcore.cpp6
5 files changed, 51 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 19c26eb..8882259 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -865,3 +865,3 @@ Addressee AddressBook::findByUid( const QString &uid )
}
-void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
+void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
{
@@ -873,3 +873,3 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
}
- mergeAB( aBook ,csd );
+ mergeAB( aBook ,csd, isSubset );
}
@@ -915,3 +915,3 @@ Addressee AddressBook::findByExternUid( const QString& uid , const QString& pr
}
-void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
+void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
{
@@ -922,3 +922,3 @@ void AddressBook::mergeAB( AddressBook *aBook, const QString& 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
@@ -303,3 +303,3 @@ class AddressBook : public QObject
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 );
@@ -307,3 +307,3 @@ class AddressBook : public QObject
- void preExternSync( AddressBook* aBook, const QString& csd );
+ void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
void postExternSync( AddressBook* aBook, const QString& csd );
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();
diff --git a/kabc/addressee.h b/kabc/addressee.h
index e7900c6..2c81c1a 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -118,3 +118,3 @@ class Addressee
QString originalExternalUID() const;
- void mergeContact( const Addressee& ad, bool isSubSet = false );
+ void mergeContact( const Addressee& ad, bool isSubSet );
void simplifyEmails();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 205dbc8..ea34be2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2734,3 +2734,3 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
isXML = true;
- abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
} else {
@@ -2789,3 +2789,3 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
- abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
@@ -2831,3 +2831,3 @@ bool KABCore::syncPhone()
abLocal.preparePhoneSync( mCurrentSyncDevice, true );
- abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );