summaryrefslogtreecommitdiffabout
Unidiff
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)
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 //if ( mData->url.isValid() ) l.append( ); 235 if ( mData->url.isValid() )
236#if 0 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
238 if ( !mData->addresses.isEmpty() ) l.append( );
239 //if ( !mData->keys.isEmpty() ) l.append( );
240 if ( !mData->emails.isEmpty() ) l.append( );
241 if ( !mData->categories .isEmpty() ) l.append( );
242 if ( !mData->custom.isEmpty() ) l.append( );
243#endif
244 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
245 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
246 239
247 QStringList t; 240 QStringList t;
248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
249 ++phoneIter ) 242 ++phoneIter )
@@ -274,13 +267,13 @@ void Addressee::computeCsum(const QString &dev)
274 } 267 }
275 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
277 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
278} 271}
279 272
280void Addressee::mergeContact( const Addressee& ad ) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
281{ 274{
282 275
283 detach(); 276 detach();
284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
@@ -288,37 +281,127 @@ void Addressee::mergeContact( const Addressee& ad )
288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
292 if ( !mData->birthday.isValid() ) 285 if ( !mData->birthday.isValid() )
293 if ( ad.mData->birthday.isValid()) 286 if ( ad.mData->birthday.isValid())
294 mData->birthday = ad.mData->birthday; 287 mData->birthday = ad.mData->birthday;
295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 PhoneNumber::List phoneAD = phoneNumbers(); 299 QStringList t;
307 PhoneNumber::List::Iterator phoneItAD; 300 QStringList tAD;
308 bool found = false; 301 uint iii;
309 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 302 if ( isSubSet ) {
303 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false;
308 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( (*it) == ( *phoneItAD ) ) {
311 found = true;
312 break;
313 }
314 }
315 if ( ! found )
316 mData->phoneNumbers.append( *phoneItAD );
317 }
318 // ************* emails;
319 t = mData->emails;
320 tAD = ad.mData->emails;
321 for ( iii = 0; iii < tAD.count(); ++iii)
322 if ( !t.contains(tAD[iii] ) )
323 mData->emails.append( tAD[iii] );
324 // ************* categories;
325 t = mData->categories;
326 tAD = ad.mData->categories;
327 for ( iii = 0; iii < tAD.count(); ++iii)
328 if ( !t.contains(tAD[iii] ) )
329 mData->categories.append( tAD[iii] );
310 330
311 331
332 }
333
334 QStringList::ConstIterator it;
335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
336 QString qualifiedName = (*it).left( (*it).find( ":" ));
337 bool found = false;
338 QStringList::ConstIterator itL;
339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
340 if ( (*itL).startsWith( qualifiedName ) ) {
341 found = true;
342 break;
343 }
344 }
345 if ( ! found ) {
346 mData->custom.append( *it );
347 }
348 }
349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
351 if ( !mData->sound.isIntern() ) {
352 if ( mData->sound.url().isEmpty() ) {
353 mData->sound = ad.mData->sound;
354 }
355 }
356 if ( !mData->agent.isIntern() ) {
357 if ( mData->agent.url().isEmpty() ) {
358 mData->agent = ad.mData->agent;
359 }
312 } 360 }
361
362#if 0
363
364 if ( mData->url.isValid() )
365 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
366 KABC::PhoneNumber::List phoneNumbers;
367 KABC::PhoneNumber::List::Iterator phoneIter;
368
369 QStringList t;
370 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
371 ++phoneIter )
372 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
373 t.sort();
374 uint iii;
375 for ( iii = 0; iii < t.count(); ++iii)
376 l.append( t[iii] );
377 t = mData->emails;
378 t.sort();
379 for ( iii = 0; iii < t.count(); ++iii)
380 l.append( t[iii] );
381 t = mData->categories;
382 t.sort();
383 for ( iii = 0; iii < t.count(); ++iii)
384 l.append( t[iii] );
385 t = mData->custom;
386 t.sort();
387 for ( iii = 0; iii < t.count(); ++iii)
388 l.append( t[iii] );
389 KABC::Address::List::Iterator addressIter;
390 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
391 ++addressIter ) {
392 t = (*addressIter).asList();
393 t.sort();
394 for ( iii = 0; iii < t.count(); ++iii)
395 l.append( t[iii] );
396 }
397
398#endif
399
313 // pending: 400 // pending:
314 // merging phonenumbers
315 // merging addresses 401 // merging addresses
316 // merging emails;
317 // merging categories;
318 // merging custom;
319 // merging keys 402 // merging keys
320 //qDebug("merge contact %s ", ad.uid().latin1()); 403 //qDebug("merge contact %s ", ad.uid().latin1());
321 setUid( ad.uid() ); 404 setUid( ad.uid() );
322 setRevision( ad.revision() ); 405 setRevision( ad.revision() );
323} 406}
324 407
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
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad, bool isSubSet = false );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );