summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-13 07:02:20 (UTC)
committer zautrix <zautrix>2004-10-13 07:02:20 (UTC)
commitf22ee1ec902fe2fc610786f39049fb84542b8726 (patch) (side-by-side diff)
tree22e8f0378410dd183dd8efc6cac418ec074321de
parentf08cf9044213a60c87e2bf299665d13a335feff5 (diff)
downloadkdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.zip
kdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.tar.gz
kdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.tar.bz2
merging contacts
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
@@ -229,21 +229,14 @@ void Addressee::computeCsum(const QString &dev)
if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
// if ( !mData->logo.isEmpty() ) l.append( );
//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;
QStringList t;
for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
++phoneIter )
@@ -274,13 +267,13 @@ void Addressee::computeCsum(const QString &dev)
}
uint cs = getCsum4List(l);
// qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
setCsum( dev, QString::number (cs ));
}
-void Addressee::mergeContact( const Addressee& ad )
+void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
detach();
if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
@@ -288,37 +281,127 @@ void Addressee::mergeContact( const Addressee& ad )
if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
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;
if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
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() );
setRevision( ad.revision() );
}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 03138f6..e7900c6 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -113,13 +113,13 @@ class Addressee
*/
bool isEmpty() const;
void setExternalUID( const QString &id );
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();
void simplifyPhoneNumberTypes();
bool removeVoice();
bool containsAdr(const Addressee& addr );