summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp123
-rw-r--r--kabc/addressee.h2
2 files changed, 104 insertions, 21 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 548305a..cb10160 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -232,15 +232,8 @@ void Addressee::computeCsum(const QString &dev)
//if ( !mData->photo.isEmpty() ) l.append( );
//if ( !mData->sound.isEmpty() ) l.append( );
//if ( !mData->agent.isEmpty() ) l.append( );
- //if ( mData->url.isValid() ) l.append( );
-#if 0
- if ( !mData->phoneNumbers.isEmpty() ) l.append( );
- if ( !mData->addresses.isEmpty() ) l.append( );
- //if ( !mData->keys.isEmpty() ) l.append( );
- if ( !mData->emails.isEmpty() ) l.append( );
- if ( !mData->categories .isEmpty() ) l.append( );
- if ( !mData->custom.isEmpty() ) l.append( );
-#endif
+ if ( mData->url.isValid() )
+ if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
KABC::PhoneNumber::List phoneNumbers;
KABC::PhoneNumber::List::Iterator phoneIter;
@@ -277,7 +270,7 @@ void Addressee::computeCsum(const QString &dev)
setCsum( dev, QString::number (cs ));
}
-void Addressee::mergeContact( const Addressee& ad )
+void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
detach();
@@ -291,7 +284,7 @@ void Addressee::mergeContact( const Addressee& ad )
if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
if ( !mData->birthday.isValid() )
if ( ad.mData->birthday.isValid())
- mData->birthday = ad.mData->birthday;
+ mData->birthday = ad.mData->birthday;
if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
@@ -303,19 +296,109 @@ void Addressee::mergeContact( const Addressee& ad )
if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
- PhoneNumber::List phoneAD = phoneNumbers();
- PhoneNumber::List::Iterator phoneItAD;
- bool found = false;
- for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
+ QStringList t;
+ QStringList tAD;
+ uint iii;
+ if ( isSubSet ) {
+ // ********** phone numbers
+ PhoneNumber::List phoneAD = ad.phoneNumbers();
+ PhoneNumber::List::Iterator phoneItAD;
+ for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
+ bool found = false;
+ PhoneNumber::List::Iterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( (*it) == ( *phoneItAD ) ) {
+ found = true;
+ break;
+ }
+ }
+ if ( ! found )
+ mData->phoneNumbers.append( *phoneItAD );
+ }
+ // ************* emails;
+ t = mData->emails;
+ tAD = ad.mData->emails;
+ for ( iii = 0; iii < tAD.count(); ++iii)
+ if ( !t.contains(tAD[iii] ) )
+ mData->emails.append( tAD[iii] );
+ // ************* categories;
+ t = mData->categories;
+ tAD = ad.mData->categories;
+ for ( iii = 0; iii < tAD.count(); ++iii)
+ 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 ) {
+ QString qualifiedName = (*it).left( (*it).find( ":" ));
+ bool found = false;
+ QStringList::ConstIterator itL;
+ for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
+ if ( (*itL).startsWith( qualifiedName ) ) {
+ found = true;
+ break;
+ }
+ }
+ if ( ! found ) {
+ mData->custom.append( *it );
+ }
+ }
+ if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
+ if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
+ if ( !mData->sound.isIntern() ) {
+ if ( mData->sound.url().isEmpty() ) {
+ mData->sound = ad.mData->sound;
+ }
+ }
+ if ( !mData->agent.isIntern() ) {
+ if ( mData->agent.url().isEmpty() ) {
+ mData->agent = ad.mData->agent;
+ }
}
+
+#if 0
+
+ if ( mData->url.isValid() )
+ if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
+ KABC::PhoneNumber::List phoneNumbers;
+ KABC::PhoneNumber::List::Iterator phoneIter;
+
+ QStringList t;
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
+ ++phoneIter )
+ t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
+ t.sort();
+ uint iii;
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->emails;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->categories;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ t = mData->custom;
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ KABC::Address::List::Iterator addressIter;
+ for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
+ ++addressIter ) {
+ t = (*addressIter).asList();
+ t.sort();
+ for ( iii = 0; iii < t.count(); ++iii)
+ l.append( t[iii] );
+ }
+
+#endif
+
// pending:
- // merging phonenumbers
// merging addresses
- // merging emails;
- // merging categories;
- // merging custom;
// merging keys
//qDebug("merge contact %s ", ad.uid().latin1());
setUid( ad.uid() );
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 03138f6..e7900c6 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -116,7 +116,7 @@ class Addressee
QString externalUID() const;
void setOriginalExternalUID( const QString &id );
QString originalExternalUID() const;
- void mergeContact( const Addressee& ad );
+ void mergeContact( const Addressee& ad, bool isSubSet = false );
void simplifyEmails();
void simplifyAddresses();
void simplifyPhoneNumbers();