summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
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
@@ -300,21 +300,27 @@ void Addressee::mergeContact( const Addressee& ad )
300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 PhoneNumber::List phoneAD = phoneNumbers();
307 PhoneNumber::List::Iterator phoneItAD;
308 bool found = false;
309 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
306 310
311
312 }
307 // pending: 313 // pending:
308 // merging phonenumbers 314 // merging phonenumbers
309 // merging addresses 315 // merging addresses
310 // merging emails; 316 // merging emails;
311 // merging categories; 317 // merging categories;
312 // merging custom; 318 // merging custom;
313 // merging keys 319 // merging keys
314 qDebug("merge contact %s ", ad.uid().latin1()); 320 //qDebug("merge contact %s ", ad.uid().latin1());
315 setUid( ad.uid() ); 321 setUid( ad.uid() );
316 setRevision( ad.revision() ); 322 setRevision( ad.revision() );
317} 323}
318 324
319bool Addressee::removeVoice() 325bool Addressee::removeVoice()
320{ 326{
@@ -330,20 +336,54 @@ bool Addressee::removeVoice()
330 } 336 }
331 } 337 }
332 338
333 } 339 }
334 return found; 340 return found;
335} 341}
342
343bool Addressee::containsAdr(const Addressee& ad )
344{
345 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
346 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
347 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
348 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
349 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
350 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
351 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
352
353 // compare phone numbers
354 PhoneNumber::List phoneN = ad.phoneNumbers();
355 PhoneNumber::List::Iterator phoneIt;
356 bool found = false;
357 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
358 bool found = false;
359 PhoneNumber::List phoneL = ad.phoneNumbers();
360 PhoneNumber::List::Iterator phoneItL;
361 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
362 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
363 found = true;
364 break;
365 }
366 }
367 if ( ! found )
368 return false;
369 }
370 return true;
371
372}
336void Addressee::simplifyAddresses() 373void Addressee::simplifyAddresses()
337{ 374{
338 if ( mData->addresses.count() < 3 ) return ; 375 int max = 2;
376 if ( mData->url.isValid() )
377 max = 1;
378 if ( mData->addresses.count() <= max ) return ;
339 int count = 0; 379 int count = 0;
340 Address::List list; 380 Address::List list;
341 Address::List::Iterator it; 381 Address::List::Iterator it;
342 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 382 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
343 if ( count > 1 ) 383 if ( count >= max )
344 list.append( *it ); 384 list.append( *it );
345 ++count; 385 ++count;
346 } 386 }
347 for( it = list.begin(); it != list.end(); ++it ) { 387 for( it = list.begin(); it != list.end(); ++it ) {
348 removeAddress( (*it) ); 388 removeAddress( (*it) );
349 } 389 }