author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (side-by-side diff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /kabc/addressee.cpp | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | kabc/addressee.cpp | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -33,4 +33,5 @@ $Id$ #include <kapplication.h> #include <klocale.h> +#include <kmessagebox.h> #include <kidmanager.h> //US @@ -212,5 +213,5 @@ void Addressee::computeCsum(const QString &dev) QStringList l; //if ( !mData->name.isEmpty() ) l.append(mData->name); - //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); + if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); @@ -333,4 +334,51 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const } +void Addressee::mergeOLContact( const Addressee& ad ) +{ + if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; + 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->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; + } + } + { + Key::List::Iterator itA; + for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { + bool found = false; + Key::List::Iterator it; + for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { + if ( (*it) == (*itA)) { + found = true; + break; + + } + } + if ( ! found ) { + mData->keys.append( *itA ); + } + } + } + + KABC::Address addthis = otherAddress(); + KABC::Address addother = ad.otherAddress(); + if ( !addthis.isEmpty() && !addother.isEmpty() ) + addthis.setType( addother.type() ); + //qDebug("merge contact %s ", ad.uid().latin1()); + setUid( ad.uid() ); + setRevision( ad.revision() ); + + +} + void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) { @@ -1654,5 +1702,4 @@ void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) detach(); mData->empty = false; - PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { @@ -1721,4 +1768,15 @@ PhoneNumber::List Addressee::phoneNumbers( int type ) const return list; } +QString Addressee::phoneNumberString( int type ) const +{ + + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { + if ((*it).type() == type ) { + return ( *it ).number(); + } + } + return ""; +} PhoneNumber Addressee::findPhoneNumber( const QString &id ) const @@ -1926,5 +1984,16 @@ void Addressee::removeAddress( const Address &address ) } } - +Address Addressee::otherAddress() const +{ + Address::List::ConstIterator it; + for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { + if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) ) + continue; + if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) ) + continue; + return (*it); + } + return Address(); +} Address Addressee::address( int type ) const { |