summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/addressee.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e8e440c..9994e29 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -266,257 +266,257 @@ void Addressee::computeCsum(const QString &dev)
266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
267 ++phoneIter ) 267 ++phoneIter )
268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
269 t.sort(); 269 t.sort();
270 uint iii; 270 uint iii;
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 t = mData->emails; 273 t = mData->emails;
274 t.sort(); 274 t.sort();
275 for ( iii = 0; iii < t.count(); ++iii) 275 for ( iii = 0; iii < t.count(); ++iii)
276 l.append( t[iii] ); 276 l.append( t[iii] );
277 t = mData->categories; 277 t = mData->categories;
278 t.sort(); 278 t.sort();
279 for ( iii = 0; iii < t.count(); ++iii) 279 for ( iii = 0; iii < t.count(); ++iii)
280 l.append( t[iii] ); 280 l.append( t[iii] );
281 t = mData->custom; 281 t = mData->custom;
282 t.sort(); 282 t.sort();
283 for ( iii = 0; iii < t.count(); ++iii) 283 for ( iii = 0; iii < t.count(); ++iii)
284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
285 int find = t[iii].find (':')+1; 285 int find = t[iii].find (':')+1;
286 //qDebug("lennnn %d %d ", find, t[iii].length()); 286 //qDebug("lennnn %d %d ", find, t[iii].length());
287 if ( find < t[iii].length()) 287 if ( find < t[iii].length())
288 l.append( t[iii] ); 288 l.append( t[iii] );
289 289
290 } 290 }
291 KABC::Address::List::Iterator addressIter; 291 KABC::Address::List::Iterator addressIter;
292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
293 ++addressIter ) { 293 ++addressIter ) {
294 t = (*addressIter).asList(); 294 t = (*addressIter).asList();
295 t.sort(); 295 t.sort();
296 for ( iii = 0; iii < t.count(); ++iii) 296 for ( iii = 0; iii < t.count(); ++iii)
297 l.append( t[iii] ); 297 l.append( t[iii] );
298 } 298 }
299 uint cs = getCsum4List(l); 299 uint cs = getCsum4List(l);
300 300
301#if 0 301#if 0
302 for ( iii = 0; iii < l.count(); ++iii) 302 for ( iii = 0; iii < l.count(); ++iii)
303 qDebug("%d***%s***",iii,l[iii].latin1()); 303 qDebug("%d***%s***",iii,l[iii].latin1());
304 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 304 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
305#endif 305#endif
306 306
307 307
308 setCsum( dev, QString::number (cs )); 308 setCsum( dev, QString::number (cs ));
309} 309}
310bool Addressee::matchAddress( QRegExp* re ) const 310bool Addressee::matchAddress( QRegExp* re ) const
311{ 311{
312 KABC::Address::List::Iterator addressIter; 312 KABC::Address::List::Iterator addressIter;
313 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 313 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
314 ++addressIter ) { 314 ++addressIter ) {
315 if ( (*addressIter).matchAddress( re ) ) 315 if ( (*addressIter).matchAddress( re ) )
316 return true; 316 return true;
317 } 317 }
318 return false; 318 return false;
319} 319}
320bool Addressee::matchPhoneNumber( QRegExp* re ) const 320bool Addressee::matchPhoneNumber( QRegExp* re ) const
321{ 321{
322 KABC::PhoneNumber::List::Iterator phoneIter; 322 KABC::PhoneNumber::List::Iterator phoneIter;
323 323
324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { 324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
325#if QT_VERSION >= 0x030000 325#if QT_VERSION >= 0x030000
326 if (re->search( (*phoneIter).number() ) == 0) 326 if (re->search( (*phoneIter).number() ) == 0)
327#else 327#else
328 if (re->match( (*phoneIter).number() ) == 0) 328 if (re->match( (*phoneIter).number() ) == 0)
329#endif 329#endif
330 return true; 330 return true;
331 331
332 } 332 }
333 return false; 333 return false;
334 334
335} 335}
336void Addressee::mergeOLContact( const Addressee& ad ) 336void Addressee::mergeOLContact( const Addressee& ad )
337{ 337{
338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
342 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 342 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
343 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 343 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
344 if ( !mData->sound.isIntern() ) { 344 if ( !mData->sound.isIntern() ) {
345 if ( mData->sound.url().isEmpty() ) { 345 if ( mData->sound.url().isEmpty() ) {
346 mData->sound = ad.mData->sound; 346 mData->sound = ad.mData->sound;
347 } 347 }
348 } 348 }
349 if ( !mData->agent.isIntern() ) { 349 if ( !mData->agent.isIntern() ) {
350 if ( mData->agent.url().isEmpty() ) { 350 if ( mData->agent.url().isEmpty() ) {
351 mData->agent = ad.mData->agent; 351 mData->agent = ad.mData->agent;
352 } 352 }
353 } 353 }
354 { 354 {
355 Key::List::Iterator itA; 355 Key::List::Iterator itA;
356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
357 bool found = false; 357 bool found = false;
358 Key::List::Iterator it; 358 Key::List::Iterator it;
359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
360 if ( (*it) == (*itA)) { 360 if ( (*it) == (*itA)) {
361 found = true; 361 found = true;
362 break; 362 break;
363 363
364 } 364 }
365 } 365 }
366 if ( ! found ) { 366 if ( ! found ) {
367 mData->keys.append( *itA ); 367 mData->keys.append( *itA );
368 } 368 }
369 } 369 }
370 } 370 }
371 371
372 KABC::Address addthis = otherAddress(); 372 KABC::Address addthis = otherAddress();
373 KABC::Address addother = ad.otherAddress(); 373 KABC::Address addother = ad.otherAddress();
374 if ( !addthis.isEmpty() && !addother.isEmpty() ) 374 if ( !addthis.isEmpty() && !addother.isEmpty() )
375 addthis.setType( addother.type() ); 375 addthis.setType( addother.type() );
376 //qDebug("merge contact %s ", ad.uid().latin1()); 376 //qDebug("merge contact %s ", ad.uid().latin1());
377 setUid( ad.uid() ); 377 setUid( ad.uid() );
378 setRevision( ad.revision() ); 378 setRevision( ad.revision() );
379 379
380 380
381} 381}
382 382
383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
384{ 384{
385 // merge all standard non-outlook fields. 385 // merge all standard non-outlook fields.
386 //if isSubSet (e.g. mobile phone sync) merge all fields 386 //if isSubSet (e.g. mobile phone sync) merge all fields
387 387
388 detach(); 388 detach();
389 if ( isSubSet ) { 389 if ( isSubSet ) {
390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
394 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 394 if ( mData->additionalName.isEmpty() ) mData->additionalName = ad.mData->additionalName;
395 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 395 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
396 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 396 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
397 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 397 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
398 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 398 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
399 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 399 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
400 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 400 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
401 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 401 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
402 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 402 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
403 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 403 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
404 if ( !mData->birthday.isValid() ) 404 if ( !mData->birthday.isValid() )
405 if ( ad.mData->birthday.isValid()) 405 if ( ad.mData->birthday.isValid())
406 mData->birthday = ad.mData->birthday; 406 mData->birthday = ad.mData->birthday;
407 407
408 } 408 }
409 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 409 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
410 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 410 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
411 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 411 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
412 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 412 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
413 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 413 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
414 QStringList t; 414 QStringList t;
415 QStringList tAD; 415 QStringList tAD;
416 uint iii; 416 uint iii;
417 417
418 // ********** phone numbers 418 // ********** phone numbers
419 if ( isSubSet ) { 419 if ( isSubSet ) {
420 PhoneNumber::List phoneAD = ad.phoneNumbers(); 420 PhoneNumber::List phoneAD = ad.phoneNumbers();
421 PhoneNumber::List::Iterator phoneItAD; 421 PhoneNumber::List::Iterator phoneItAD;
422 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 422 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
423 bool found = false; 423 bool found = false;
424 PhoneNumber::List::Iterator it; 424 PhoneNumber::List::Iterator it;
425 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 425 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
426 if ( ( *phoneItAD ).contains( (*it) ) ) { 426 if ( ( *phoneItAD ).contains( (*it) ) ) {
427 found = true; 427 found = true;
428 (*it).setType( ( *phoneItAD ).type() ); 428 (*it).setType( ( *phoneItAD ).type() );
429 (*it).setNumber( ( *phoneItAD ).number() ); 429 (*it).setNumber( ( *phoneItAD ).number() );
430 break; 430 break;
431 } 431 }
432 } 432 }
433 // if ( isSubSet && ! found ) 433 // if ( isSubSet && ! found )
434 if ( ! found ) // LR try this one... 434 if ( ! found ) // LR try this one...
435 mData->phoneNumbers.append( *phoneItAD ); 435 mData->phoneNumbers.append( *phoneItAD );
436 } 436 }
437 } else { 437 } else {
438 PhoneNumber::List phoneAD = ad.phoneNumbers(); 438 PhoneNumber::List phoneAD = ad.phoneNumbers();
439 PhoneNumber::List::Iterator phoneItAD; 439 PhoneNumber::List::Iterator phoneItAD;
440 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 440 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
441 bool found = false; 441 bool found = false;
442 PhoneNumber::List::Iterator it; 442 PhoneNumber::List::Iterator it;
443 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 443 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
444 if ( ( *phoneItAD ).contains( (*it) ) ) { 444 if ( ( *phoneItAD ).contains( (*it) ) ) {
445 found = true; 445 found = true;
446 (*it).setType( ( *phoneItAD ).type() ); 446 (*it).setType( ( *phoneItAD ).type() );
447 (*it).setNumber( ( *phoneItAD ).number() ); 447 (*it).setNumber( ( *phoneItAD ).number() );
448 break; 448 break;
449 } 449 }
450 } 450 }
451 if ( ! found ) { // append numbers which do not have work or home type 451 if ( ! found ) { // append numbers which do not have work or home type
452 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 452 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
453 mData->phoneNumbers.append( *phoneItAD ); 453 mData->phoneNumbers.append( *phoneItAD );
454 } 454 }
455 } 455 }
456 } 456 }
457 if ( isSubSet ) { 457 if ( isSubSet ) {
458 // ************* emails; 458 // ************* emails;
459 t = mData->emails; 459 t = mData->emails;
460 tAD = ad.mData->emails; 460 tAD = ad.mData->emails;
461 for ( iii = 0; iii < tAD.count(); ++iii) 461 for ( iii = 0; iii < tAD.count(); ++iii)
462 if ( !t.contains(tAD[iii] ) ) 462 if ( !t.contains(tAD[iii] ) )
463 mData->emails.append( tAD[iii] ); 463 mData->emails.append( tAD[iii] );
464 } 464 }
465 465
466 // ************* categories; 466 // ************* categories;
467 if ( isSubSet ) { 467 if ( isSubSet ) {
468 t = mData->categories; 468 t = mData->categories;
469 tAD = ad.mData->categories; 469 tAD = ad.mData->categories;
470 for ( iii = 0; iii < tAD.count(); ++iii) 470 for ( iii = 0; iii < tAD.count(); ++iii)
471 if ( !t.contains(tAD[iii] ) ) 471 if ( !t.contains(tAD[iii] ) )
472 mData->categories.append( tAD[iii] ); 472 mData->categories.append( tAD[iii] );
473 } 473 }
474 QStringList::ConstIterator it; 474 QStringList::ConstIterator it;
475 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 475 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
476 QString qualifiedName = (*it).left( (*it).find( ":" )); 476 QString qualifiedName = (*it).left( (*it).find( ":" ));
477 bool found = false; 477 bool found = false;
478 QStringList::ConstIterator itL; 478 QStringList::ConstIterator itL;
479 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 479 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
480 if ( (*itL).startsWith( qualifiedName ) ) { 480 if ( (*itL).startsWith( qualifiedName ) ) {
481 found = true; 481 found = true;
482 break; 482 break;
483 } 483 }
484 } 484 }
485 if ( ! found ) { 485 if ( ! found ) {
486 mData->custom.append( *it ); 486 mData->custom.append( *it );
487 } 487 }
488 } 488 }
489 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 489 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
490 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 490 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
491 if ( !mData->sound.isIntern() ) { 491 if ( !mData->sound.isIntern() ) {
492 if ( mData->sound.url().isEmpty() ) { 492 if ( mData->sound.url().isEmpty() ) {
493 mData->sound = ad.mData->sound; 493 mData->sound = ad.mData->sound;
494 } 494 }
495 } 495 }
496 if ( !mData->agent.isIntern() ) { 496 if ( !mData->agent.isIntern() ) {
497 if ( mData->agent.url().isEmpty() ) { 497 if ( mData->agent.url().isEmpty() ) {
498 mData->agent = ad.mData->agent; 498 mData->agent = ad.mData->agent;
499 } 499 }
500 } 500 }
501 { 501 {
502 Key::List::Iterator itA; 502 Key::List::Iterator itA;
503 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 503 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
504 bool found = false; 504 bool found = false;
505 Key::List::Iterator it; 505 Key::List::Iterator it;
506 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 506 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
507 if ( (*it) == (*itA)) { 507 if ( (*it) == (*itA)) {
508 found = true; 508 found = true;
509 break; 509 break;
510 510
511 } 511 }
512 } 512 }
513 if ( ! found ) { 513 if ( ! found ) {
514 mData->keys.append( *itA ); 514 mData->keys.append( *itA );
515 } 515 }
516 } 516 }
517 } 517 }
518 if ( isSubSet ) { 518 if ( isSubSet ) {
519 KABC::Address::List::Iterator addressIterA; 519 KABC::Address::List::Iterator addressIterA;
520 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 520 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
521 bool found = false; 521 bool found = false;
522 KABC::Address::List::Iterator addressIter; 522 KABC::Address::List::Iterator addressIter;