summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 607ae26..548305a 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -290,70 +290,110 @@ void Addressee::mergeContact( const Addressee& ad )
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;
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 ) {
+
+ }
// pending:
// merging phonenumbers
// merging addresses
// merging emails;
// merging categories;
// merging custom;
// merging keys
- qDebug("merge contact %s ", ad.uid().latin1());
+ //qDebug("merge contact %s ", ad.uid().latin1());
setUid( ad.uid() );
setRevision( ad.revision() );
}
bool Addressee::removeVoice()
{
PhoneNumber::List phoneN = phoneNumbers();
PhoneNumber::List::Iterator phoneIt;
bool found = false;
for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
if ((*phoneIt).type() - PhoneNumber::Voice ) {
(*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
insertPhoneNumber( (*phoneIt) );
found = true;
}
}
}
return found;
}
+
+bool Addressee::containsAdr(const Addressee& ad )
+{
+ if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
+ if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
+ if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
+ if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
+ if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
+ if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
+ if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
+
+ // compare phone numbers
+ PhoneNumber::List phoneN = ad.phoneNumbers();
+ PhoneNumber::List::Iterator phoneIt;
+ bool found = false;
+ for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
+ bool found = false;
+ PhoneNumber::List phoneL = ad.phoneNumbers();
+ PhoneNumber::List::Iterator phoneItL;
+ for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
+ if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
+ found = true;
+ break;
+ }
+ }
+ if ( ! found )
+ return false;
+ }
+ return true;
+
+}
void Addressee::simplifyAddresses()
{
- if ( mData->addresses.count() < 3 ) return ;
+ int max = 2;
+ if ( mData->url.isValid() )
+ max = 1;
+ if ( mData->addresses.count() <= max ) return ;
int count = 0;
Address::List list;
Address::List::Iterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
- if ( count > 1 )
+ if ( count >= max )
list.append( *it );
++count;
}
for( it = list.begin(); it != list.end(); ++it ) {
removeAddress( (*it) );
}
}
// removes all emails but the first
// needed by phone sync
void Addressee::simplifyEmails()
{
if ( mData->emails.count() == 0 ) return ;
QString email = mData->emails.first();
detach();
mData->emails.clear();