summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-29 22:45:39 (UTC)
committer zautrix <zautrix>2005-10-29 22:45:39 (UTC)
commitb06fa1090f3fa7a71ab2710be444815df8bd6c17 (patch) (unidiff)
tree16f5aed10d0c78c255ae732959e3dd184ae5e218
parenta4f17bd35c56280c45bda847b42b7d3a003b0a42 (diff)
downloadkdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.zip
kdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.tar.gz
kdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.tar.bz2
commit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp2
-rw-r--r--kabc/addresseeview.cpp29
-rw-r--r--kabc/phonenumber.cpp15
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp2
4 files changed, 39 insertions, 9 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 2f4a9af..6cfac80 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -327,1537 +327,1537 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const
327 if (re->match( (*phoneIter).number() ) == 0) 327 if (re->match( (*phoneIter).number() ) == 0)
328#endif 328#endif
329 return true; 329 return true;
330 330
331 } 331 }
332 return false; 332 return false;
333 333
334} 334}
335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
336{ 336{
337 // merge all standard non-outlook fields. 337 // merge all standard non-outlook fields.
338 //if isSubSet (e.g. mobile phone sync) merge all fields 338 //if isSubSet (e.g. mobile phone sync) merge all fields
339 339
340 detach(); 340 detach();
341 if ( isSubSet ) { 341 if ( isSubSet ) {
342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
347 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 347 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
348 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 348 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
349 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 349 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
350 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 350 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
351 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 351 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
352 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 352 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
353 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 353 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
354 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 354 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
355 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 355 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
356 if ( !mData->birthday.isValid() ) 356 if ( !mData->birthday.isValid() )
357 if ( ad.mData->birthday.isValid()) 357 if ( ad.mData->birthday.isValid())
358 mData->birthday = ad.mData->birthday; 358 mData->birthday = ad.mData->birthday;
359 359
360 } 360 }
361 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 361 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
362 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 362 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
363 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 363 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
364 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 364 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
365 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 365 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
366 QStringList t; 366 QStringList t;
367 QStringList tAD; 367 QStringList tAD;
368 uint iii; 368 uint iii;
369 369
370 // ********** phone numbers 370 // ********** phone numbers
371 if ( isSubSet ) { 371 if ( isSubSet ) {
372 PhoneNumber::List phoneAD = ad.phoneNumbers(); 372 PhoneNumber::List phoneAD = ad.phoneNumbers();
373 PhoneNumber::List::Iterator phoneItAD; 373 PhoneNumber::List::Iterator phoneItAD;
374 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 374 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
375 bool found = false; 375 bool found = false;
376 PhoneNumber::List::Iterator it; 376 PhoneNumber::List::Iterator it;
377 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 377 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
378 if ( ( *phoneItAD ).contains( (*it) ) ) { 378 if ( ( *phoneItAD ).contains( (*it) ) ) {
379 found = true; 379 found = true;
380 (*it).setType( ( *phoneItAD ).type() ); 380 (*it).setType( ( *phoneItAD ).type() );
381 (*it).setNumber( ( *phoneItAD ).number() ); 381 (*it).setNumber( ( *phoneItAD ).number() );
382 break; 382 break;
383 } 383 }
384 } 384 }
385 // if ( isSubSet && ! found ) 385 // if ( isSubSet && ! found )
386 if ( ! found ) // LR try this one... 386 if ( ! found ) // LR try this one...
387 mData->phoneNumbers.append( *phoneItAD ); 387 mData->phoneNumbers.append( *phoneItAD );
388 } 388 }
389 } else { 389 } else {
390 PhoneNumber::List phoneAD = ad.phoneNumbers(); 390 PhoneNumber::List phoneAD = ad.phoneNumbers();
391 PhoneNumber::List::Iterator phoneItAD; 391 PhoneNumber::List::Iterator phoneItAD;
392 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 392 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
393 bool found = false; 393 bool found = false;
394 PhoneNumber::List::Iterator it; 394 PhoneNumber::List::Iterator it;
395 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 395 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
396 if ( ( *phoneItAD ).contains( (*it) ) ) { 396 if ( ( *phoneItAD ).contains( (*it) ) ) {
397 found = true; 397 found = true;
398 (*it).setType( ( *phoneItAD ).type() ); 398 (*it).setType( ( *phoneItAD ).type() );
399 (*it).setNumber( ( *phoneItAD ).number() ); 399 (*it).setNumber( ( *phoneItAD ).number() );
400 break; 400 break;
401 } 401 }
402 } 402 }
403 if ( ! found ) { // append numbers which do not have work or home type 403 if ( ! found ) { // append numbers which do not have work or home type
404 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 404 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
405 mData->phoneNumbers.append( *phoneItAD ); 405 mData->phoneNumbers.append( *phoneItAD );
406 } 406 }
407 } 407 }
408 } 408 }
409 if ( isSubSet ) { 409 if ( isSubSet ) {
410 // ************* emails; 410 // ************* emails;
411 t = mData->emails; 411 t = mData->emails;
412 tAD = ad.mData->emails; 412 tAD = ad.mData->emails;
413 for ( iii = 0; iii < tAD.count(); ++iii) 413 for ( iii = 0; iii < tAD.count(); ++iii)
414 if ( !t.contains(tAD[iii] ) ) 414 if ( !t.contains(tAD[iii] ) )
415 mData->emails.append( tAD[iii] ); 415 mData->emails.append( tAD[iii] );
416 } 416 }
417 417
418 // ************* categories; 418 // ************* categories;
419 if ( isSubSet ) { 419 if ( isSubSet ) {
420 t = mData->categories; 420 t = mData->categories;
421 tAD = ad.mData->categories; 421 tAD = ad.mData->categories;
422 for ( iii = 0; iii < tAD.count(); ++iii) 422 for ( iii = 0; iii < tAD.count(); ++iii)
423 if ( !t.contains(tAD[iii] ) ) 423 if ( !t.contains(tAD[iii] ) )
424 mData->categories.append( tAD[iii] ); 424 mData->categories.append( tAD[iii] );
425 } 425 }
426 QStringList::ConstIterator it; 426 QStringList::ConstIterator it;
427 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 427 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
428 QString qualifiedName = (*it).left( (*it).find( ":" )); 428 QString qualifiedName = (*it).left( (*it).find( ":" ));
429 bool found = false; 429 bool found = false;
430 QStringList::ConstIterator itL; 430 QStringList::ConstIterator itL;
431 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 431 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
432 if ( (*itL).startsWith( qualifiedName ) ) { 432 if ( (*itL).startsWith( qualifiedName ) ) {
433 found = true; 433 found = true;
434 break; 434 break;
435 } 435 }
436 } 436 }
437 if ( ! found ) { 437 if ( ! found ) {
438 mData->custom.append( *it ); 438 mData->custom.append( *it );
439 } 439 }
440 } 440 }
441 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 441 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
442 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 442 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
443 if ( !mData->sound.isIntern() ) { 443 if ( !mData->sound.isIntern() ) {
444 if ( mData->sound.url().isEmpty() ) { 444 if ( mData->sound.url().isEmpty() ) {
445 mData->sound = ad.mData->sound; 445 mData->sound = ad.mData->sound;
446 } 446 }
447 } 447 }
448 if ( !mData->agent.isIntern() ) { 448 if ( !mData->agent.isIntern() ) {
449 if ( mData->agent.url().isEmpty() ) { 449 if ( mData->agent.url().isEmpty() ) {
450 mData->agent = ad.mData->agent; 450 mData->agent = ad.mData->agent;
451 } 451 }
452 } 452 }
453 { 453 {
454 Key::List::Iterator itA; 454 Key::List::Iterator itA;
455 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 455 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
456 bool found = false; 456 bool found = false;
457 Key::List::Iterator it; 457 Key::List::Iterator it;
458 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 458 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
459 if ( (*it) == (*itA)) { 459 if ( (*it) == (*itA)) {
460 found = true; 460 found = true;
461 break; 461 break;
462 462
463 } 463 }
464 } 464 }
465 if ( ! found ) { 465 if ( ! found ) {
466 mData->keys.append( *itA ); 466 mData->keys.append( *itA );
467 } 467 }
468 } 468 }
469 } 469 }
470 if ( isSubSet ) { 470 if ( isSubSet ) {
471 KABC::Address::List::Iterator addressIterA; 471 KABC::Address::List::Iterator addressIterA;
472 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 472 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
473 bool found = false; 473 bool found = false;
474 KABC::Address::List::Iterator addressIter; 474 KABC::Address::List::Iterator addressIter;
475 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 475 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
476 ++addressIter ) { 476 ++addressIter ) {
477 if ( (*addressIter) == (*addressIterA)) { 477 if ( (*addressIter) == (*addressIterA)) {
478 found = true; 478 found = true;
479 (*addressIter).setType( (*addressIterA).type() ); 479 (*addressIter).setType( (*addressIterA).type() );
480 break; 480 break;
481 } 481 }
482 482
483 } 483 }
484 if ( isSubSet && ! found ) { 484 if ( isSubSet && ! found ) {
485 mData->addresses.append( *addressIterA ); 485 mData->addresses.append( *addressIterA );
486 } 486 }
487 } 487 }
488 } 488 }
489 //qDebug("merge contact %s ", ad.uid().latin1()); 489 //qDebug("merge contact %s ", ad.uid().latin1());
490 setUid( ad.uid() ); 490 setUid( ad.uid() );
491 setRevision( ad.revision() ); 491 setRevision( ad.revision() );
492} 492}
493 493
494bool Addressee::removeVoice() 494bool Addressee::removeVoice()
495{ 495{
496 PhoneNumber::List phoneN = phoneNumbers(); 496 PhoneNumber::List phoneN = phoneNumbers();
497 PhoneNumber::List::Iterator phoneIt; 497 PhoneNumber::List::Iterator phoneIt;
498 bool found = false; 498 bool found = false;
499 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 499 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
500 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 500 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
501 if ((*phoneIt).type() - PhoneNumber::Voice ) { 501 if ((*phoneIt).type() - PhoneNumber::Voice ) {
502 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 502 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
503 insertPhoneNumber( (*phoneIt) ); 503 insertPhoneNumber( (*phoneIt) );
504 found = true; 504 found = true;
505 } 505 }
506 } 506 }
507 507
508 } 508 }
509 return found; 509 return found;
510} 510}
511 511
512bool Addressee::containsAdr(const Addressee& ad ) 512bool Addressee::containsAdr(const Addressee& ad )
513{ 513{
514 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 514 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
515 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 515 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
516 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 516 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
517 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 517 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
518 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 518 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
519 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 519 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
520 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 520 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
521 521
522 // compare phone numbers 522 // compare phone numbers
523 PhoneNumber::List phoneN = ad.phoneNumbers(); 523 PhoneNumber::List phoneN = ad.phoneNumbers();
524 PhoneNumber::List::Iterator phoneIt; 524 PhoneNumber::List::Iterator phoneIt;
525 bool found = false; 525 bool found = false;
526 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 526 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
527 bool found = false; 527 bool found = false;
528 PhoneNumber::List phoneL = ad.phoneNumbers(); 528 PhoneNumber::List phoneL = ad.phoneNumbers();
529 PhoneNumber::List::Iterator phoneItL; 529 PhoneNumber::List::Iterator phoneItL;
530 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 530 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
531 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 531 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
532 found = true; 532 found = true;
533 break; 533 break;
534 } 534 }
535 } 535 }
536 if ( ! found ) 536 if ( ! found )
537 return false; 537 return false;
538 } 538 }
539 return true; 539 return true;
540 540
541} 541}
542void Addressee::simplifyAddresses() 542void Addressee::simplifyAddresses()
543{ 543{
544 544
545 545
546 Address::List list; 546 Address::List list;
547 Address::List::Iterator it; 547 Address::List::Iterator it;
548 Address::List::Iterator it2; 548 Address::List::Iterator it2;
549 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 549 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
550 it2 = it; 550 it2 = it;
551 ++it2; 551 ++it2;
552 for( ; it2 != mData->addresses.end(); ++it2 ) { 552 for( ; it2 != mData->addresses.end(); ++it2 ) {
553 if ( (*it) == (*it2) ) { 553 if ( (*it) == (*it2) ) {
554 list.append( *it ); 554 list.append( *it );
555 break; 555 break;
556 } 556 }
557 } 557 }
558 } 558 }
559 for( it = list.begin(); it != list.end(); ++it ) { 559 for( it = list.begin(); it != list.end(); ++it ) {
560 removeAddress( (*it) ); 560 removeAddress( (*it) );
561 } 561 }
562 562
563 list.clear(); 563 list.clear();
564 int max = 2; 564 int max = 2;
565 if ( mData->url.isValid() ) 565 if ( mData->url.isValid() )
566 max = 1; 566 max = 1;
567 if ( mData->addresses.count() <= max ) return ; 567 if ( mData->addresses.count() <= max ) return ;
568 int count = 0; 568 int count = 0;
569 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 569 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
570 if ( count >= max ) 570 if ( count >= max )
571 list.append( *it ); 571 list.append( *it );
572 ++count; 572 ++count;
573 } 573 }
574 for( it = list.begin(); it != list.end(); ++it ) { 574 for( it = list.begin(); it != list.end(); ++it ) {
575 removeAddress( (*it) ); 575 removeAddress( (*it) );
576 } 576 }
577} 577}
578 578
579// removes all emails but the first 579// removes all emails but the first
580// needed by phone sync 580// needed by phone sync
581void Addressee::simplifyEmails() 581void Addressee::simplifyEmails()
582{ 582{
583 if ( mData->emails.count() == 0 ) return ; 583 if ( mData->emails.count() == 0 ) return ;
584 QString email = mData->emails.first(); 584 QString email = mData->emails.first();
585 detach(); 585 detach();
586 mData->emails.clear(); 586 mData->emails.clear();
587 mData->emails.append( email ); 587 mData->emails.append( email );
588} 588}
589void Addressee::makePhoneNumbersOLcompatible() 589void Addressee::makePhoneNumbersOLcompatible()
590{ 590{
591 KABC::PhoneNumber::List::Iterator phoneIter; 591 KABC::PhoneNumber::List::Iterator phoneIter;
592 KABC::PhoneNumber::List::Iterator phoneIter2; 592 KABC::PhoneNumber::List::Iterator phoneIter2;
593 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 593 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
594 ++phoneIter ) { 594 ++phoneIter ) {
595 ( *phoneIter ).makeCompat(); 595 ( *phoneIter ).makeCompat();
596 } 596 }
597 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); 597 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref );
598 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); 598 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home );
599 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); 599 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref );
600 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); 600 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work );
601 int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); 601 int hasCell = hasPhoneNumberType( PhoneNumber::Cell );
602 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); 602 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car );
603 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 603 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
604 ++phoneIter ) { 604 ++phoneIter ) {
605 if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) { 605 if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) {
606 (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref ); 606 (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref );
607 ++hasHome; 607 ++hasHome;
608 if ( hasHome2 ) --hasHome2; 608 if ( hasHome2 ) --hasHome2;
609 } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) { 609 } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) {
610 (*phoneIter).setType( PhoneNumber::Home ); 610 (*phoneIter).setType( PhoneNumber::Home );
611 --hasHome; 611 --hasHome;
612 ++hasHome2; 612 ++hasHome2;
613 } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) { 613 } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) {
614 (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref ); 614 (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref );
615 ++hasWork; 615 ++hasWork;
616 if ( hasWork2 ) --hasWork2; 616 if ( hasWork2 ) --hasWork2;
617 } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) { 617 } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) {
618 (*phoneIter).setType( PhoneNumber::Work ); 618 (*phoneIter).setType( PhoneNumber::Work );
619 --hasWork; 619 --hasWork;
620 ++hasWork2; 620 ++hasWork2;
621 } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) { 621 } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) {
622 (*phoneIter).setType( PhoneNumber::Car ); 622 (*phoneIter).setType( PhoneNumber::Car );
623 ++hasCell2; 623 ++hasCell2;
624 --hasCell; 624 --hasCell;
625 } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) { 625 } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) {
626 (*phoneIter).setType( PhoneNumber::Cell ); 626 (*phoneIter).setType( PhoneNumber::Cell );
627 ++hasCell; 627 ++hasCell;
628 --hasCell2; 628 --hasCell2;
629 } else{ 629 } else{
630 phoneIter2 = phoneIter; 630 phoneIter2 = phoneIter;
631 ++phoneIter2; 631 ++phoneIter2;
632 for ( ; phoneIter2 != mData->phoneNumbers.end(); 632 for ( ; phoneIter2 != mData->phoneNumbers.end();
633 ++phoneIter2 ) { 633 ++phoneIter2 ) {
634 if ( (*phoneIter2).type() == (*phoneIter).type() ) { 634 if ( (*phoneIter2).type() == (*phoneIter).type() ) {
635 (*phoneIter2).setType( PhoneNumber::Voice ); 635 (*phoneIter2).setType( PhoneNumber::Voice );
636 636
637 } 637 }
638 } 638 }
639 } 639 }
640 } 640 }
641} 641}
642void Addressee::simplifyPhoneNumbers() 642void Addressee::simplifyPhoneNumbers()
643{ 643{
644 int max = 4; 644 int max = 4;
645 int inList = mData->phoneNumbers.count(); 645 int inList = mData->phoneNumbers.count();
646 KABC::PhoneNumber::List removeNumbers; 646 KABC::PhoneNumber::List removeNumbers;
647 KABC::PhoneNumber::List::Iterator phoneIter; 647 KABC::PhoneNumber::List::Iterator phoneIter;
648 if ( inList > max ) { 648 if ( inList > max ) {
649 // delete non-preferred numbers 649 // delete non-preferred numbers
650 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 650 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
651 ++phoneIter ) { 651 ++phoneIter ) {
652 if ( inList > max ) { 652 if ( inList > max ) {
653 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 653 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
654 removeNumbers.append( ( *phoneIter ) ); 654 removeNumbers.append( ( *phoneIter ) );
655 --inList; 655 --inList;
656 } 656 }
657 } else 657 } else
658 break; 658 break;
659 } 659 }
660 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 660 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
661 ++phoneIter ) { 661 ++phoneIter ) {
662 removePhoneNumber(( *phoneIter )); 662 removePhoneNumber(( *phoneIter ));
663 } 663 }
664 // delete preferred numbers 664 // delete preferred numbers
665 if ( inList > max ) { 665 if ( inList > max ) {
666 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 666 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
667 ++phoneIter ) { 667 ++phoneIter ) {
668 if ( inList > max ) { 668 if ( inList > max ) {
669 removeNumbers.append( ( *phoneIter ) ); 669 removeNumbers.append( ( *phoneIter ) );
670 --inList; 670 --inList;
671 } else 671 } else
672 break; 672 break;
673 } 673 }
674 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 674 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
675 ++phoneIter ) { 675 ++phoneIter ) {
676 removePhoneNumber(( *phoneIter )); 676 removePhoneNumber(( *phoneIter ));
677 } 677 }
678 } 678 }
679 } 679 }
680 // remove non-numeric characters 680 // remove non-numeric characters
681 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 681 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
682 ++phoneIter ) { 682 ++phoneIter ) {
683 if ( ! ( *phoneIter ).simplifyNumber() ) 683 if ( ! ( *phoneIter ).simplifyNumber() )
684 removeNumbers.append( ( *phoneIter ) ); 684 removeNumbers.append( ( *phoneIter ) );
685 } 685 }
686 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 686 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
687 ++phoneIter ) { 687 ++phoneIter ) {
688 removePhoneNumber(( *phoneIter )); 688 removePhoneNumber(( *phoneIter ));
689 } 689 }
690} 690}
691void Addressee::simplifyPhoneNumberTypes() 691void Addressee::simplifyPhoneNumberTypes()
692{ 692{
693 KABC::PhoneNumber::List::Iterator phoneIter; 693 KABC::PhoneNumber::List::Iterator phoneIter;
694 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 694 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
695 ++phoneIter ) 695 ++phoneIter )
696 ( *phoneIter ).simplifyType(); 696 ( *phoneIter ).simplifyType();
697} 697}
698void Addressee::removeID(const QString &prof) 698void Addressee::removeID(const QString &prof)
699{ 699{
700 detach(); 700 detach();
701 if ( prof.isEmpty() ) 701 if ( prof.isEmpty() )
702 mData->mExternalId = ":"; 702 mData->mExternalId = ":";
703 else 703 else
704 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 704 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
705 705
706} 706}
707void Addressee::setID( const QString & prof , const QString & id ) 707void Addressee::setID( const QString & prof , const QString & id )
708{ 708{
709 detach(); 709 detach();
710 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 710 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
711 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 711 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
712} 712}
713void Addressee::setTempSyncStat( int id ) 713void Addressee::setTempSyncStat( int id )
714{ 714{
715 if ( mData->mTempSyncStat == id ) return; 715 if ( mData->mTempSyncStat == id ) return;
716 detach(); 716 detach();
717 mData->mTempSyncStat = id; 717 mData->mTempSyncStat = id;
718} 718}
719int Addressee::tempSyncStat() const 719int Addressee::tempSyncStat() const
720{ 720{
721 return mData->mTempSyncStat; 721 return mData->mTempSyncStat;
722} 722}
723 723
724const QString Addressee::getID( const QString & prof) const 724const QString Addressee::getID( const QString & prof) const
725{ 725{
726 return KIdManager::getId ( mData->mExternalId, prof ); 726 return KIdManager::getId ( mData->mExternalId, prof );
727} 727}
728 728
729void Addressee::setCsum( const QString & prof , const QString & id ) 729void Addressee::setCsum( const QString & prof , const QString & id )
730{ 730{
731 detach(); 731 detach();
732 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 732 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
733 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 733 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
734 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 734 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
735} 735}
736 736
737const QString Addressee::getCsum( const QString & prof) const 737const QString Addressee::getCsum( const QString & prof) const
738{ 738{
739 return KIdManager::getCsum ( mData->mExternalId, prof ); 739 return KIdManager::getCsum ( mData->mExternalId, prof );
740} 740}
741 741
742void Addressee::setIDStr( const QString & s ) 742void Addressee::setIDStr( const QString & s )
743{ 743{
744 detach(); 744 detach();
745 mData->mExternalId = s; 745 mData->mExternalId = s;
746} 746}
747 747
748const QString Addressee::IDStr() const 748const QString Addressee::IDStr() const
749{ 749{
750 return mData->mExternalId; 750 return mData->mExternalId;
751} 751}
752 752
753void Addressee::setExternalUID( const QString &id ) 753void Addressee::setExternalUID( const QString &id )
754{ 754{
755 if ( id == mData->externalUID ) return; 755 if ( id == mData->externalUID ) return;
756 detach(); 756 detach();
757 mData->empty = false; 757 mData->empty = false;
758 mData->externalUID = id; 758 mData->externalUID = id;
759} 759}
760 760
761const QString Addressee::externalUID() const 761const QString Addressee::externalUID() const
762{ 762{
763 return mData->externalUID; 763 return mData->externalUID;
764} 764}
765void Addressee::setOriginalExternalUID( const QString &id ) 765void Addressee::setOriginalExternalUID( const QString &id )
766{ 766{
767 if ( id == mData->originalExternalUID ) return; 767 if ( id == mData->originalExternalUID ) return;
768 detach(); 768 detach();
769 mData->empty = false; 769 mData->empty = false;
770 //qDebug("*******Set orig uid %s ", id.latin1()); 770 //qDebug("*******Set orig uid %s ", id.latin1());
771 mData->originalExternalUID = id; 771 mData->originalExternalUID = id;
772} 772}
773 773
774QString Addressee::originalExternalUID() const 774QString Addressee::originalExternalUID() const
775{ 775{
776 return mData->originalExternalUID; 776 return mData->originalExternalUID;
777} 777}
778 778
779void Addressee::setUid( const QString &id ) 779void Addressee::setUid( const QString &id )
780{ 780{
781 if ( id == mData->uid ) return; 781 if ( id == mData->uid ) return;
782 detach(); 782 detach();
783 //qDebug("****setuid %s ", id.latin1()); 783 //qDebug("****setuid %s ", id.latin1());
784 mData->empty = false; 784 mData->empty = false;
785 mData->uid = id; 785 mData->uid = id;
786} 786}
787 787
788const QString Addressee::uid() const 788const QString Addressee::uid() const
789{ 789{
790 if ( mData->uid.isEmpty() ) 790 if ( mData->uid.isEmpty() )
791 mData->uid = KApplication::randomString( 10 ); 791 mData->uid = KApplication::randomString( 10 );
792 792
793 return mData->uid; 793 return mData->uid;
794} 794}
795 795
796QString Addressee::uidLabel() 796QString Addressee::uidLabel()
797{ 797{
798 return i18n("Unique Identifier"); 798 return i18n("Unique Identifier");
799} 799}
800 800
801void Addressee::setName( const QString &name ) 801void Addressee::setName( const QString &name )
802{ 802{
803 if ( name == mData->name ) return; 803 if ( name == mData->name ) return;
804 detach(); 804 detach();
805 mData->empty = false; 805 mData->empty = false;
806 mData->name = name; 806 mData->name = name;
807} 807}
808 808
809QString Addressee::name() const 809QString Addressee::name() const
810{ 810{
811 return mData->name; 811 return mData->name;
812} 812}
813 813
814QString Addressee::nameLabel() 814QString Addressee::nameLabel()
815{ 815{
816 return i18n("Name"); 816 return i18n("Name");
817} 817}
818 818
819 819
820void Addressee::setFormattedName( const QString &formattedName ) 820void Addressee::setFormattedName( const QString &formattedName )
821{ 821{
822 if ( formattedName == mData->formattedName ) return; 822 if ( formattedName == mData->formattedName ) return;
823 detach(); 823 detach();
824 mData->empty = false; 824 mData->empty = false;
825 mData->formattedName = formattedName; 825 mData->formattedName = formattedName;
826} 826}
827 827
828QString Addressee::formattedName() const 828QString Addressee::formattedName() const
829{ 829{
830 return mData->formattedName; 830 return mData->formattedName;
831} 831}
832 832
833QString Addressee::formattedNameLabel() 833QString Addressee::formattedNameLabel()
834{ 834{
835 return i18n("Formatted Name"); 835 return i18n("Formatted Name");
836} 836}
837 837
838 838
839void Addressee::setFamilyName( const QString &familyName ) 839void Addressee::setFamilyName( const QString &familyName )
840{ 840{
841 if ( familyName == mData->familyName ) return; 841 if ( familyName == mData->familyName ) return;
842 detach(); 842 detach();
843 mData->empty = false; 843 mData->empty = false;
844 mData->familyName = familyName; 844 mData->familyName = familyName;
845} 845}
846 846
847QString Addressee::familyName() const 847QString Addressee::familyName() const
848{ 848{
849 return mData->familyName; 849 return mData->familyName;
850} 850}
851 851
852QString Addressee::familyNameLabel() 852QString Addressee::familyNameLabel()
853{ 853{
854 return i18n("Family Name"); 854 return i18n("Family Name");
855} 855}
856 856
857 857
858void Addressee::setGivenName( const QString &givenName ) 858void Addressee::setGivenName( const QString &givenName )
859{ 859{
860 if ( givenName == mData->givenName ) return; 860 if ( givenName == mData->givenName ) return;
861 detach(); 861 detach();
862 mData->empty = false; 862 mData->empty = false;
863 mData->givenName = givenName; 863 mData->givenName = givenName;
864} 864}
865 865
866QString Addressee::givenName() const 866QString Addressee::givenName() const
867{ 867{
868 return mData->givenName; 868 return mData->givenName;
869} 869}
870 870
871QString Addressee::givenNameLabel() 871QString Addressee::givenNameLabel()
872{ 872{
873 return i18n("Given Name"); 873 return i18n("Given Name");
874} 874}
875 875
876 876
877void Addressee::setAdditionalName( const QString &additionalName ) 877void Addressee::setAdditionalName( const QString &additionalName )
878{ 878{
879 if ( additionalName == mData->additionalName ) return; 879 if ( additionalName == mData->additionalName ) return;
880 detach(); 880 detach();
881 mData->empty = false; 881 mData->empty = false;
882 mData->additionalName = additionalName; 882 mData->additionalName = additionalName;
883} 883}
884 884
885QString Addressee::additionalName() const 885QString Addressee::additionalName() const
886{ 886{
887 return mData->additionalName; 887 return mData->additionalName;
888} 888}
889 889
890QString Addressee::additionalNameLabel() 890QString Addressee::additionalNameLabel()
891{ 891{
892 return i18n("Additional Names"); 892 return i18n("Additional Names");
893} 893}
894 894
895 895
896void Addressee::setPrefix( const QString &prefix ) 896void Addressee::setPrefix( const QString &prefix )
897{ 897{
898 if ( prefix == mData->prefix ) return; 898 if ( prefix == mData->prefix ) return;
899 detach(); 899 detach();
900 mData->empty = false; 900 mData->empty = false;
901 mData->prefix = prefix; 901 mData->prefix = prefix;
902} 902}
903 903
904QString Addressee::prefix() const 904QString Addressee::prefix() const
905{ 905{
906 return mData->prefix; 906 return mData->prefix;
907} 907}
908 908
909QString Addressee::prefixLabel() 909QString Addressee::prefixLabel()
910{ 910{
911 return i18n("Honorific Prefixes"); 911 return i18n("Honorific Prefixes");
912} 912}
913 913
914 914
915void Addressee::setSuffix( const QString &suffix ) 915void Addressee::setSuffix( const QString &suffix )
916{ 916{
917 if ( suffix == mData->suffix ) return; 917 if ( suffix == mData->suffix ) return;
918 detach(); 918 detach();
919 mData->empty = false; 919 mData->empty = false;
920 mData->suffix = suffix; 920 mData->suffix = suffix;
921} 921}
922 922
923QString Addressee::suffix() const 923QString Addressee::suffix() const
924{ 924{
925 return mData->suffix; 925 return mData->suffix;
926} 926}
927 927
928QString Addressee::suffixLabel() 928QString Addressee::suffixLabel()
929{ 929{
930 return i18n("Honorific Suffixes"); 930 return i18n("Honorific Suffixes");
931} 931}
932 932
933 933
934void Addressee::setNickName( const QString &nickName ) 934void Addressee::setNickName( const QString &nickName )
935{ 935{
936 if ( nickName == mData->nickName ) return; 936 if ( nickName == mData->nickName ) return;
937 detach(); 937 detach();
938 mData->empty = false; 938 mData->empty = false;
939 mData->nickName = nickName; 939 mData->nickName = nickName;
940} 940}
941 941
942QString Addressee::nickName() const 942QString Addressee::nickName() const
943{ 943{
944 return mData->nickName; 944 return mData->nickName;
945} 945}
946 946
947QString Addressee::nickNameLabel() 947QString Addressee::nickNameLabel()
948{ 948{
949 return i18n("Nick Name"); 949 return i18n("Nick Name");
950} 950}
951 951
952 952
953void Addressee::setBirthday( const QDateTime &birthday ) 953void Addressee::setBirthday( const QDateTime &birthday )
954{ 954{
955 if ( birthday == mData->birthday ) return; 955 if ( birthday == mData->birthday ) return;
956 detach(); 956 detach();
957 mData->empty = false; 957 mData->empty = false;
958 mData->birthday = birthday; 958 mData->birthday = birthday;
959} 959}
960 960
961QDateTime Addressee::birthday() const 961QDateTime Addressee::birthday() const
962{ 962{
963 return mData->birthday; 963 return mData->birthday;
964} 964}
965 965
966QString Addressee::birthdayLabel() 966QString Addressee::birthdayLabel()
967{ 967{
968 return i18n("Birthday"); 968 return i18n("Birthday");
969} 969}
970 970
971 971
972QString Addressee::homeAddressStreetLabel() 972QString Addressee::homeAddressStreetLabel()
973{ 973{
974 return i18n("Home Address Street"); 974 return i18n("Home Address Street");
975} 975}
976 976
977 977
978QString Addressee::homeAddressLocalityLabel() 978QString Addressee::homeAddressLocalityLabel()
979{ 979{
980 return i18n("Home Address Locality"); 980 return i18n("Home Address Locality");
981} 981}
982 982
983 983
984QString Addressee::homeAddressRegionLabel() 984QString Addressee::homeAddressRegionLabel()
985{ 985{
986 return i18n("Home Address Region"); 986 return i18n("Home Address Region");
987} 987}
988 988
989 989
990QString Addressee::homeAddressPostalCodeLabel() 990QString Addressee::homeAddressPostalCodeLabel()
991{ 991{
992 return i18n("Home Address Postal Code"); 992 return i18n("Home Address Postal Code");
993} 993}
994 994
995 995
996QString Addressee::homeAddressCountryLabel() 996QString Addressee::homeAddressCountryLabel()
997{ 997{
998 return i18n("Home Address Country"); 998 return i18n("Home Address Country");
999} 999}
1000 1000
1001 1001
1002QString Addressee::homeAddressLabelLabel() 1002QString Addressee::homeAddressLabelLabel()
1003{ 1003{
1004 return i18n("Home Address Label"); 1004 return i18n("Home Address Label");
1005} 1005}
1006 1006
1007 1007
1008QString Addressee::businessAddressStreetLabel() 1008QString Addressee::businessAddressStreetLabel()
1009{ 1009{
1010 return i18n("Business Address Street"); 1010 return i18n("Business Address Street");
1011} 1011}
1012 1012
1013 1013
1014QString Addressee::businessAddressLocalityLabel() 1014QString Addressee::businessAddressLocalityLabel()
1015{ 1015{
1016 return i18n("Business Address Locality"); 1016 return i18n("Business Address Locality");
1017} 1017}
1018 1018
1019 1019
1020QString Addressee::businessAddressRegionLabel() 1020QString Addressee::businessAddressRegionLabel()
1021{ 1021{
1022 return i18n("Business Address Region"); 1022 return i18n("Business Address Region");
1023} 1023}
1024 1024
1025 1025
1026QString Addressee::businessAddressPostalCodeLabel() 1026QString Addressee::businessAddressPostalCodeLabel()
1027{ 1027{
1028 return i18n("Business Address Postal Code"); 1028 return i18n("Business Address Postal Code");
1029} 1029}
1030 1030
1031 1031
1032QString Addressee::businessAddressCountryLabel() 1032QString Addressee::businessAddressCountryLabel()
1033{ 1033{
1034 return i18n("Business Address Country"); 1034 return i18n("Business Address Country");
1035} 1035}
1036 1036
1037 1037
1038QString Addressee::businessAddressLabelLabel() 1038QString Addressee::businessAddressLabelLabel()
1039{ 1039{
1040 return i18n("Business Address Label"); 1040 return i18n("Business Address Label");
1041} 1041}
1042 1042
1043 1043
1044QString Addressee::homePhoneLabel() 1044QString Addressee::homePhoneLabel()
1045{ 1045{
1046 return i18n("Home Phone"); 1046 return i18n("Home Phone");
1047} 1047}
1048 1048
1049 1049
1050QString Addressee::businessPhoneLabel() 1050QString Addressee::businessPhoneLabel()
1051{ 1051{
1052 return i18n("Work Phone"); 1052 return i18n("Work Phone");
1053} 1053}
1054 1054
1055 1055
1056QString Addressee::mobilePhoneLabel() 1056QString Addressee::mobilePhoneLabel()
1057{ 1057{
1058 return i18n("Mobile"); 1058 return i18n("Mobile");
1059} 1059}
1060QString Addressee::mobileWorkPhoneLabel() 1060QString Addressee::mobileWorkPhoneLabel()
1061{ 1061{
1062 return i18n("Mobile2"); 1062 return i18n("Mobile2");
1063} 1063}
1064 1064
1065 1065
1066QString Addressee::homeFaxLabel() 1066QString Addressee::homeFaxLabel()
1067{ 1067{
1068 return i18n("Fax (Home)"); 1068 return i18n("Fax (Home)");
1069} 1069}
1070 1070
1071 1071
1072QString Addressee::businessFaxLabel() 1072QString Addressee::businessFaxLabel()
1073{ 1073{
1074 return i18n("Fax (Work)"); 1074 return i18n("Fax (Work)");
1075} 1075}
1076 1076
1077 1077
1078QString Addressee::isdnLabel() 1078QString Addressee::isdnLabel()
1079{ 1079{
1080 return i18n("ISDN"); 1080 return i18n("ISDN");
1081} 1081}
1082 1082
1083 1083
1084QString Addressee::pagerLabel() 1084QString Addressee::pagerLabel()
1085{ 1085{
1086 return i18n("Pager"); 1086 return i18n("Pager");
1087} 1087}
1088QString Addressee::otherPhoneLabel() 1088QString Addressee::otherPhoneLabel()
1089{ 1089{
1090 return i18n("Other Phone"); 1090 return i18n("Other Phone");
1091} 1091}
1092 1092
1093QString Addressee::sipLabel() 1093QString Addressee::sipLabel()
1094{ 1094{
1095 return i18n("SIP"); 1095 return i18n("SiP");
1096} 1096}
1097 1097
1098QString Addressee::emailLabel() 1098QString Addressee::emailLabel()
1099{ 1099{
1100 return i18n("Email Address"); 1100 return i18n("Email Address");
1101} 1101}
1102 1102
1103 1103
1104void Addressee::setMailer( const QString &mailer ) 1104void Addressee::setMailer( const QString &mailer )
1105{ 1105{
1106 if ( mailer == mData->mailer ) return; 1106 if ( mailer == mData->mailer ) return;
1107 detach(); 1107 detach();
1108 mData->empty = false; 1108 mData->empty = false;
1109 mData->mailer = mailer; 1109 mData->mailer = mailer;
1110} 1110}
1111 1111
1112QString Addressee::mailer() const 1112QString Addressee::mailer() const
1113{ 1113{
1114 return mData->mailer; 1114 return mData->mailer;
1115} 1115}
1116 1116
1117QString Addressee::mailerLabel() 1117QString Addressee::mailerLabel()
1118{ 1118{
1119 return i18n("Mail Client"); 1119 return i18n("Mail Client");
1120} 1120}
1121 1121
1122 1122
1123void Addressee::setTimeZone( const TimeZone &timeZone ) 1123void Addressee::setTimeZone( const TimeZone &timeZone )
1124{ 1124{
1125 if ( timeZone == mData->timeZone ) return; 1125 if ( timeZone == mData->timeZone ) return;
1126 detach(); 1126 detach();
1127 mData->empty = false; 1127 mData->empty = false;
1128 mData->timeZone = timeZone; 1128 mData->timeZone = timeZone;
1129} 1129}
1130 1130
1131TimeZone Addressee::timeZone() const 1131TimeZone Addressee::timeZone() const
1132{ 1132{
1133 return mData->timeZone; 1133 return mData->timeZone;
1134} 1134}
1135 1135
1136QString Addressee::timeZoneLabel() 1136QString Addressee::timeZoneLabel()
1137{ 1137{
1138 return i18n("Time Zone"); 1138 return i18n("Time Zone");
1139} 1139}
1140 1140
1141 1141
1142void Addressee::setGeo( const Geo &geo ) 1142void Addressee::setGeo( const Geo &geo )
1143{ 1143{
1144 if ( geo == mData->geo ) return; 1144 if ( geo == mData->geo ) return;
1145 detach(); 1145 detach();
1146 mData->empty = false; 1146 mData->empty = false;
1147 mData->geo = geo; 1147 mData->geo = geo;
1148} 1148}
1149 1149
1150Geo Addressee::geo() const 1150Geo Addressee::geo() const
1151{ 1151{
1152 return mData->geo; 1152 return mData->geo;
1153} 1153}
1154 1154
1155QString Addressee::geoLabel() 1155QString Addressee::geoLabel()
1156{ 1156{
1157 return i18n("Geographic Position"); 1157 return i18n("Geographic Position");
1158} 1158}
1159 1159
1160 1160
1161void Addressee::setTitle( const QString &title ) 1161void Addressee::setTitle( const QString &title )
1162{ 1162{
1163 if ( title == mData->title ) return; 1163 if ( title == mData->title ) return;
1164 detach(); 1164 detach();
1165 mData->empty = false; 1165 mData->empty = false;
1166 mData->title = title; 1166 mData->title = title;
1167} 1167}
1168 1168
1169QString Addressee::title() const 1169QString Addressee::title() const
1170{ 1170{
1171 return mData->title; 1171 return mData->title;
1172} 1172}
1173 1173
1174QString Addressee::titleLabel() 1174QString Addressee::titleLabel()
1175{ 1175{
1176 return i18n("Title"); 1176 return i18n("Title");
1177} 1177}
1178 1178
1179 1179
1180void Addressee::setRole( const QString &role ) 1180void Addressee::setRole( const QString &role )
1181{ 1181{
1182 if ( role == mData->role ) return; 1182 if ( role == mData->role ) return;
1183 detach(); 1183 detach();
1184 mData->empty = false; 1184 mData->empty = false;
1185 mData->role = role; 1185 mData->role = role;
1186} 1186}
1187 1187
1188QString Addressee::role() const 1188QString Addressee::role() const
1189{ 1189{
1190 return mData->role; 1190 return mData->role;
1191} 1191}
1192 1192
1193QString Addressee::roleLabel() 1193QString Addressee::roleLabel()
1194{ 1194{
1195 return i18n("Role"); 1195 return i18n("Role");
1196} 1196}
1197 1197
1198 1198
1199void Addressee::setOrganization( const QString &organization ) 1199void Addressee::setOrganization( const QString &organization )
1200{ 1200{
1201 if ( organization == mData->organization ) return; 1201 if ( organization == mData->organization ) return;
1202 detach(); 1202 detach();
1203 mData->empty = false; 1203 mData->empty = false;
1204 mData->organization = organization; 1204 mData->organization = organization;
1205} 1205}
1206 1206
1207QString Addressee::organization() const 1207QString Addressee::organization() const
1208{ 1208{
1209 return mData->organization; 1209 return mData->organization;
1210} 1210}
1211 1211
1212QString Addressee::organizationLabel() 1212QString Addressee::organizationLabel()
1213{ 1213{
1214 return i18n("Organization"); 1214 return i18n("Organization");
1215} 1215}
1216 1216
1217 1217
1218void Addressee::setNote( const QString &note ) 1218void Addressee::setNote( const QString &note )
1219{ 1219{
1220 if ( note == mData->note ) return; 1220 if ( note == mData->note ) return;
1221 detach(); 1221 detach();
1222 mData->empty = false; 1222 mData->empty = false;
1223 mData->note = note; 1223 mData->note = note;
1224} 1224}
1225 1225
1226QString Addressee::note() const 1226QString Addressee::note() const
1227{ 1227{
1228 return mData->note; 1228 return mData->note;
1229} 1229}
1230 1230
1231QString Addressee::noteLabel() 1231QString Addressee::noteLabel()
1232{ 1232{
1233 return i18n("Note"); 1233 return i18n("Note");
1234} 1234}
1235 1235
1236 1236
1237void Addressee::setProductId( const QString &productId ) 1237void Addressee::setProductId( const QString &productId )
1238{ 1238{
1239 if ( productId == mData->productId ) return; 1239 if ( productId == mData->productId ) return;
1240 detach(); 1240 detach();
1241 mData->empty = false; 1241 mData->empty = false;
1242 mData->productId = productId; 1242 mData->productId = productId;
1243} 1243}
1244 1244
1245QString Addressee::productId() const 1245QString Addressee::productId() const
1246{ 1246{
1247 return mData->productId; 1247 return mData->productId;
1248} 1248}
1249 1249
1250QString Addressee::productIdLabel() 1250QString Addressee::productIdLabel()
1251{ 1251{
1252 return i18n("Product Identifier"); 1252 return i18n("Product Identifier");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setRevision( const QDateTime &revision ) 1256void Addressee::setRevision( const QDateTime &revision )
1257{ 1257{
1258 if ( revision == mData->revision ) return; 1258 if ( revision == mData->revision ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->revision = QDateTime( revision.date(), 1261 mData->revision = QDateTime( revision.date(),
1262 QTime (revision.time().hour(), 1262 QTime (revision.time().hour(),
1263 revision.time().minute(), 1263 revision.time().minute(),
1264 revision.time().second())); 1264 revision.time().second()));
1265} 1265}
1266 1266
1267QDateTime Addressee::revision() const 1267QDateTime Addressee::revision() const
1268{ 1268{
1269 return mData->revision; 1269 return mData->revision;
1270} 1270}
1271 1271
1272QString Addressee::revisionLabel() 1272QString Addressee::revisionLabel()
1273{ 1273{
1274 return i18n("Revision Date"); 1274 return i18n("Revision Date");
1275} 1275}
1276 1276
1277 1277
1278void Addressee::setSortString( const QString &sortString ) 1278void Addressee::setSortString( const QString &sortString )
1279{ 1279{
1280 if ( sortString == mData->sortString ) return; 1280 if ( sortString == mData->sortString ) return;
1281 detach(); 1281 detach();
1282 mData->empty = false; 1282 mData->empty = false;
1283 mData->sortString = sortString; 1283 mData->sortString = sortString;
1284} 1284}
1285 1285
1286QString Addressee::sortString() const 1286QString Addressee::sortString() const
1287{ 1287{
1288 return mData->sortString; 1288 return mData->sortString;
1289} 1289}
1290 1290
1291QString Addressee::sortStringLabel() 1291QString Addressee::sortStringLabel()
1292{ 1292{
1293 return i18n("Sort String"); 1293 return i18n("Sort String");
1294} 1294}
1295 1295
1296 1296
1297void Addressee::setUrl( const KURL &url ) 1297void Addressee::setUrl( const KURL &url )
1298{ 1298{
1299 if ( url == mData->url ) return; 1299 if ( url == mData->url ) return;
1300 detach(); 1300 detach();
1301 mData->empty = false; 1301 mData->empty = false;
1302 mData->url = url; 1302 mData->url = url;
1303} 1303}
1304 1304
1305KURL Addressee::url() const 1305KURL Addressee::url() const
1306{ 1306{
1307 return mData->url; 1307 return mData->url;
1308} 1308}
1309 1309
1310QString Addressee::urlLabel() 1310QString Addressee::urlLabel()
1311{ 1311{
1312 return i18n("URL"); 1312 return i18n("URL");
1313} 1313}
1314 1314
1315 1315
1316void Addressee::setSecrecy( const Secrecy &secrecy ) 1316void Addressee::setSecrecy( const Secrecy &secrecy )
1317{ 1317{
1318 if ( secrecy == mData->secrecy ) return; 1318 if ( secrecy == mData->secrecy ) return;
1319 detach(); 1319 detach();
1320 mData->empty = false; 1320 mData->empty = false;
1321 mData->secrecy = secrecy; 1321 mData->secrecy = secrecy;
1322} 1322}
1323 1323
1324Secrecy Addressee::secrecy() const 1324Secrecy Addressee::secrecy() const
1325{ 1325{
1326 return mData->secrecy; 1326 return mData->secrecy;
1327} 1327}
1328 1328
1329QString Addressee::secrecyLabel() 1329QString Addressee::secrecyLabel()
1330{ 1330{
1331 return i18n("Security Class"); 1331 return i18n("Security Class");
1332} 1332}
1333 1333
1334 1334
1335void Addressee::setLogo( const Picture &logo ) 1335void Addressee::setLogo( const Picture &logo )
1336{ 1336{
1337 if ( logo == mData->logo ) return; 1337 if ( logo == mData->logo ) return;
1338 detach(); 1338 detach();
1339 mData->empty = false; 1339 mData->empty = false;
1340 mData->logo = logo; 1340 mData->logo = logo;
1341} 1341}
1342 1342
1343Picture Addressee::logo() const 1343Picture Addressee::logo() const
1344{ 1344{
1345 return mData->logo; 1345 return mData->logo;
1346} 1346}
1347 1347
1348QString Addressee::logoLabel() 1348QString Addressee::logoLabel()
1349{ 1349{
1350 return i18n("Logo"); 1350 return i18n("Logo");
1351} 1351}
1352 1352
1353 1353
1354void Addressee::setPhoto( const Picture &photo ) 1354void Addressee::setPhoto( const Picture &photo )
1355{ 1355{
1356 if ( photo == mData->photo ) return; 1356 if ( photo == mData->photo ) return;
1357 detach(); 1357 detach();
1358 mData->empty = false; 1358 mData->empty = false;
1359 mData->photo = photo; 1359 mData->photo = photo;
1360} 1360}
1361 1361
1362Picture Addressee::photo() const 1362Picture Addressee::photo() const
1363{ 1363{
1364 return mData->photo; 1364 return mData->photo;
1365} 1365}
1366 1366
1367QString Addressee::photoLabel() 1367QString Addressee::photoLabel()
1368{ 1368{
1369 return i18n("Photo"); 1369 return i18n("Photo");
1370} 1370}
1371 1371
1372 1372
1373void Addressee::setSound( const Sound &sound ) 1373void Addressee::setSound( const Sound &sound )
1374{ 1374{
1375 if ( sound == mData->sound ) return; 1375 if ( sound == mData->sound ) return;
1376 detach(); 1376 detach();
1377 mData->empty = false; 1377 mData->empty = false;
1378 mData->sound = sound; 1378 mData->sound = sound;
1379} 1379}
1380 1380
1381Sound Addressee::sound() const 1381Sound Addressee::sound() const
1382{ 1382{
1383 return mData->sound; 1383 return mData->sound;
1384} 1384}
1385 1385
1386QString Addressee::soundLabel() 1386QString Addressee::soundLabel()
1387{ 1387{
1388 return i18n("Sound"); 1388 return i18n("Sound");
1389} 1389}
1390 1390
1391 1391
1392void Addressee::setAgent( const Agent &agent ) 1392void Addressee::setAgent( const Agent &agent )
1393{ 1393{
1394 if ( agent == mData->agent ) return; 1394 if ( agent == mData->agent ) return;
1395 detach(); 1395 detach();
1396 mData->empty = false; 1396 mData->empty = false;
1397 mData->agent = agent; 1397 mData->agent = agent;
1398} 1398}
1399 1399
1400Agent Addressee::agent() const 1400Agent Addressee::agent() const
1401{ 1401{
1402 return mData->agent; 1402 return mData->agent;
1403} 1403}
1404 1404
1405QString Addressee::agentLabel() 1405QString Addressee::agentLabel()
1406{ 1406{
1407 return i18n("Agent"); 1407 return i18n("Agent");
1408} 1408}
1409 1409
1410 1410
1411 1411
1412void Addressee::setNameFromString( const QString &str ) 1412void Addressee::setNameFromString( const QString &str )
1413{ 1413{
1414 setFormattedName( str ); 1414 setFormattedName( str );
1415 setName( str ); 1415 setName( str );
1416 1416
1417 static bool first = true; 1417 static bool first = true;
1418 static QStringList titles; 1418 static QStringList titles;
1419 static QStringList suffixes; 1419 static QStringList suffixes;
1420 static QStringList prefixes; 1420 static QStringList prefixes;
1421 1421
1422 if ( first ) { 1422 if ( first ) {
1423 first = false; 1423 first = false;
1424 titles += i18n( "Dr." ); 1424 titles += i18n( "Dr." );
1425 titles += i18n( "Miss" ); 1425 titles += i18n( "Miss" );
1426 titles += i18n( "Mr." ); 1426 titles += i18n( "Mr." );
1427 titles += i18n( "Mrs." ); 1427 titles += i18n( "Mrs." );
1428 titles += i18n( "Ms." ); 1428 titles += i18n( "Ms." );
1429 titles += i18n( "Prof." ); 1429 titles += i18n( "Prof." );
1430 1430
1431 suffixes += i18n( "I" ); 1431 suffixes += i18n( "I" );
1432 suffixes += i18n( "II" ); 1432 suffixes += i18n( "II" );
1433 suffixes += i18n( "III" ); 1433 suffixes += i18n( "III" );
1434 suffixes += i18n( "Jr." ); 1434 suffixes += i18n( "Jr." );
1435 suffixes += i18n( "Sr." ); 1435 suffixes += i18n( "Sr." );
1436 1436
1437 prefixes += "van"; 1437 prefixes += "van";
1438 prefixes += "von"; 1438 prefixes += "von";
1439 prefixes += "de"; 1439 prefixes += "de";
1440 1440
1441 KConfig config( locateLocal( "config", "kabcrc") ); 1441 KConfig config( locateLocal( "config", "kabcrc") );
1442 config.setGroup( "General" ); 1442 config.setGroup( "General" );
1443 titles += config.readListEntry( "Prefixes" ); 1443 titles += config.readListEntry( "Prefixes" );
1444 titles.remove( "" ); 1444 titles.remove( "" );
1445 prefixes += config.readListEntry( "Inclusions" ); 1445 prefixes += config.readListEntry( "Inclusions" );
1446 prefixes.remove( "" ); 1446 prefixes.remove( "" );
1447 suffixes += config.readListEntry( "Suffixes" ); 1447 suffixes += config.readListEntry( "Suffixes" );
1448 suffixes.remove( "" ); 1448 suffixes.remove( "" );
1449 } 1449 }
1450 1450
1451 // clear all name parts 1451 // clear all name parts
1452 setPrefix( "" ); 1452 setPrefix( "" );
1453 setGivenName( "" ); 1453 setGivenName( "" );
1454 setAdditionalName( "" ); 1454 setAdditionalName( "" );
1455 setFamilyName( "" ); 1455 setFamilyName( "" );
1456 setSuffix( "" ); 1456 setSuffix( "" );
1457 1457
1458 if ( str.isEmpty() ) 1458 if ( str.isEmpty() )
1459 return; 1459 return;
1460 1460
1461 int i = str.find(','); 1461 int i = str.find(',');
1462 if( i < 0 ) { 1462 if( i < 0 ) {
1463 QStringList parts = QStringList::split( " ", str ); 1463 QStringList parts = QStringList::split( " ", str );
1464 int leftOffset = 0; 1464 int leftOffset = 0;
1465 int rightOffset = parts.count() - 1; 1465 int rightOffset = parts.count() - 1;
1466 1466
1467 QString suffix; 1467 QString suffix;
1468 while ( rightOffset >= 0 ) { 1468 while ( rightOffset >= 0 ) {
1469 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1469 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1470 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1470 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1471 rightOffset--; 1471 rightOffset--;
1472 } else 1472 } else
1473 break; 1473 break;
1474 } 1474 }
1475 setSuffix( suffix ); 1475 setSuffix( suffix );
1476 1476
1477 if ( rightOffset < 0 ) 1477 if ( rightOffset < 0 )
1478 return; 1478 return;
1479 1479
1480 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1480 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1481 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1481 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1482 rightOffset--; 1482 rightOffset--;
1483 } else 1483 } else
1484 setFamilyName( parts[ rightOffset ] ); 1484 setFamilyName( parts[ rightOffset ] );
1485 1485
1486 QString prefix; 1486 QString prefix;
1487 while ( leftOffset < rightOffset ) { 1487 while ( leftOffset < rightOffset ) {
1488 if ( titles.contains( parts[ leftOffset ] ) ) { 1488 if ( titles.contains( parts[ leftOffset ] ) ) {
1489 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1489 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1490 leftOffset++; 1490 leftOffset++;
1491 } else 1491 } else
1492 break; 1492 break;
1493 } 1493 }
1494 setPrefix( prefix ); 1494 setPrefix( prefix );
1495 1495
1496 if ( leftOffset < rightOffset ) { 1496 if ( leftOffset < rightOffset ) {
1497 setGivenName( parts[ leftOffset ] ); 1497 setGivenName( parts[ leftOffset ] );
1498 leftOffset++; 1498 leftOffset++;
1499 } 1499 }
1500 1500
1501 QString additionalName; 1501 QString additionalName;
1502 while ( leftOffset < rightOffset ) { 1502 while ( leftOffset < rightOffset ) {
1503 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1503 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1504 leftOffset++; 1504 leftOffset++;
1505 } 1505 }
1506 setAdditionalName( additionalName ); 1506 setAdditionalName( additionalName );
1507 } else { 1507 } else {
1508 QString part1 = str.left( i ); 1508 QString part1 = str.left( i );
1509 QString part2 = str.mid( i + 1 ); 1509 QString part2 = str.mid( i + 1 );
1510 1510
1511 QStringList parts = QStringList::split( " ", part1 ); 1511 QStringList parts = QStringList::split( " ", part1 );
1512 int leftOffset = 0; 1512 int leftOffset = 0;
1513 int rightOffset = parts.count() - 1; 1513 int rightOffset = parts.count() - 1;
1514 1514
1515 QString suffix; 1515 QString suffix;
1516 while ( rightOffset >= 0 ) { 1516 while ( rightOffset >= 0 ) {
1517 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1517 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1518 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1518 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1519 rightOffset--; 1519 rightOffset--;
1520 } else 1520 } else
1521 break; 1521 break;
1522 } 1522 }
1523 setSuffix( suffix ); 1523 setSuffix( suffix );
1524 1524
1525 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1525 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1526 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1526 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1527 rightOffset--; 1527 rightOffset--;
1528 } else 1528 } else
1529 setFamilyName( parts[ rightOffset ] ); 1529 setFamilyName( parts[ rightOffset ] );
1530 1530
1531 QString prefix; 1531 QString prefix;
1532 while ( leftOffset < rightOffset ) { 1532 while ( leftOffset < rightOffset ) {
1533 if ( titles.contains( parts[ leftOffset ] ) ) { 1533 if ( titles.contains( parts[ leftOffset ] ) ) {
1534 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1534 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1535 leftOffset++; 1535 leftOffset++;
1536 } else 1536 } else
1537 break; 1537 break;
1538 } 1538 }
1539 1539
1540 parts = QStringList::split( " ", part2 ); 1540 parts = QStringList::split( " ", part2 );
1541 1541
1542 leftOffset = 0; 1542 leftOffset = 0;
1543 rightOffset = parts.count(); 1543 rightOffset = parts.count();
1544 1544
1545 while ( leftOffset < rightOffset ) { 1545 while ( leftOffset < rightOffset ) {
1546 if ( titles.contains( parts[ leftOffset ] ) ) { 1546 if ( titles.contains( parts[ leftOffset ] ) ) {
1547 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1547 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1548 leftOffset++; 1548 leftOffset++;
1549 } else 1549 } else
1550 break; 1550 break;
1551 } 1551 }
1552 setPrefix( prefix ); 1552 setPrefix( prefix );
1553 1553
1554 if ( leftOffset < rightOffset ) { 1554 if ( leftOffset < rightOffset ) {
1555 setGivenName( parts[ leftOffset ] ); 1555 setGivenName( parts[ leftOffset ] );
1556 leftOffset++; 1556 leftOffset++;
1557 } 1557 }
1558 1558
1559 QString additionalName; 1559 QString additionalName;
1560 while ( leftOffset < rightOffset ) { 1560 while ( leftOffset < rightOffset ) {
1561 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1561 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1562 leftOffset++; 1562 leftOffset++;
1563 } 1563 }
1564 setAdditionalName( additionalName ); 1564 setAdditionalName( additionalName );
1565 } 1565 }
1566} 1566}
1567 1567
1568QString Addressee::realName() const 1568QString Addressee::realName() const
1569{ 1569{
1570 if ( !formattedName().isEmpty() ) 1570 if ( !formattedName().isEmpty() )
1571 return formattedName(); 1571 return formattedName();
1572 1572
1573 QString n = assembledName(); 1573 QString n = assembledName();
1574 1574
1575 if ( n.isEmpty() ) 1575 if ( n.isEmpty() )
1576 n = name(); 1576 n = name();
1577 if ( n.isEmpty() ) 1577 if ( n.isEmpty() )
1578 n = organization(); 1578 n = organization();
1579 return n; 1579 return n;
1580} 1580}
1581 1581
1582QString Addressee::assembledName() const 1582QString Addressee::assembledName() const
1583{ 1583{
1584 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1584 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1585 familyName() + " " + suffix(); 1585 familyName() + " " + suffix();
1586 1586
1587 return name.simplifyWhiteSpace(); 1587 return name.simplifyWhiteSpace();
1588} 1588}
1589 1589
1590QString Addressee::fullEmail( const QString &email ) const 1590QString Addressee::fullEmail( const QString &email ) const
1591{ 1591{
1592 QString e; 1592 QString e;
1593 if ( email.isNull() ) { 1593 if ( email.isNull() ) {
1594 e = preferredEmail(); 1594 e = preferredEmail();
1595 } else { 1595 } else {
1596 e = email; 1596 e = email;
1597 } 1597 }
1598 if ( e.isEmpty() ) return QString::null; 1598 if ( e.isEmpty() ) return QString::null;
1599 1599
1600 QString text; 1600 QString text;
1601 if ( realName().isEmpty() ) 1601 if ( realName().isEmpty() )
1602 text = e; 1602 text = e;
1603 else 1603 else
1604 text = assembledName() + " <" + e + ">"; 1604 text = assembledName() + " <" + e + ">";
1605 1605
1606 return text; 1606 return text;
1607} 1607}
1608 1608
1609void Addressee::insertEmail( const QString &email, bool preferred ) 1609void Addressee::insertEmail( const QString &email, bool preferred )
1610{ 1610{
1611 detach(); 1611 detach();
1612 1612
1613 QStringList::Iterator it = mData->emails.find( email ); 1613 QStringList::Iterator it = mData->emails.find( email );
1614 1614
1615 if ( it != mData->emails.end() ) { 1615 if ( it != mData->emails.end() ) {
1616 if ( !preferred || it == mData->emails.begin() ) return; 1616 if ( !preferred || it == mData->emails.begin() ) return;
1617 mData->emails.remove( it ); 1617 mData->emails.remove( it );
1618 mData->emails.prepend( email ); 1618 mData->emails.prepend( email );
1619 } else { 1619 } else {
1620 if ( preferred ) { 1620 if ( preferred ) {
1621 mData->emails.prepend( email ); 1621 mData->emails.prepend( email );
1622 } else { 1622 } else {
1623 mData->emails.append( email ); 1623 mData->emails.append( email );
1624 } 1624 }
1625 } 1625 }
1626} 1626}
1627 1627
1628void Addressee::removeEmail( const QString &email ) 1628void Addressee::removeEmail( const QString &email )
1629{ 1629{
1630 detach(); 1630 detach();
1631 1631
1632 QStringList::Iterator it = mData->emails.find( email ); 1632 QStringList::Iterator it = mData->emails.find( email );
1633 if ( it == mData->emails.end() ) return; 1633 if ( it == mData->emails.end() ) return;
1634 1634
1635 mData->emails.remove( it ); 1635 mData->emails.remove( it );
1636} 1636}
1637 1637
1638QString Addressee::preferredEmail() const 1638QString Addressee::preferredEmail() const
1639{ 1639{
1640 if ( mData->emails.count() == 0 ) return QString::null; 1640 if ( mData->emails.count() == 0 ) return QString::null;
1641 else return mData->emails.first(); 1641 else return mData->emails.first();
1642} 1642}
1643 1643
1644QStringList Addressee::emails() const 1644QStringList Addressee::emails() const
1645{ 1645{
1646 return mData->emails; 1646 return mData->emails;
1647} 1647}
1648void Addressee::setEmails( const QStringList& emails ) { 1648void Addressee::setEmails( const QStringList& emails ) {
1649 detach(); 1649 detach();
1650 mData->emails = emails; 1650 mData->emails = emails;
1651} 1651}
1652void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1652void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1653{ 1653{
1654 detach(); 1654 detach();
1655 mData->empty = false; 1655 mData->empty = false;
1656 1656
1657 PhoneNumber::List::Iterator it; 1657 PhoneNumber::List::Iterator it;
1658 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1658 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1659 if ( (*it).id() == phoneNumber.id() ) { 1659 if ( (*it).id() == phoneNumber.id() ) {
1660 *it = phoneNumber; 1660 *it = phoneNumber;
1661 return; 1661 return;
1662 } 1662 }
1663 } 1663 }
1664 mData->phoneNumbers.append( phoneNumber ); 1664 mData->phoneNumbers.append( phoneNumber );
1665} 1665}
1666 1666
1667void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1667void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1668{ 1668{
1669 detach(); 1669 detach();
1670 1670
1671 PhoneNumber::List::Iterator it; 1671 PhoneNumber::List::Iterator it;
1672 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1672 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1673 if ( (*it).id() == phoneNumber.id() ) { 1673 if ( (*it).id() == phoneNumber.id() ) {
1674 mData->phoneNumbers.remove( it ); 1674 mData->phoneNumbers.remove( it );
1675 return; 1675 return;
1676 } 1676 }
1677 } 1677 }
1678} 1678}
1679 1679
1680PhoneNumber Addressee::phoneNumber( int type ) const 1680PhoneNumber Addressee::phoneNumber( int type ) const
1681{ 1681{
1682 PhoneNumber phoneNumber( "", type ); 1682 PhoneNumber phoneNumber( "", type );
1683 PhoneNumber::List::ConstIterator it; 1683 PhoneNumber::List::ConstIterator it;
1684 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1684 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1685 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1685 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1686 if ( (*it).type() & PhoneNumber::Pref ) 1686 if ( (*it).type() & PhoneNumber::Pref )
1687 return (*it); 1687 return (*it);
1688 else if ( phoneNumber.number().isEmpty() ) 1688 else if ( phoneNumber.number().isEmpty() )
1689 phoneNumber = (*it); 1689 phoneNumber = (*it);
1690 } 1690 }
1691 } 1691 }
1692 1692
1693 return phoneNumber; 1693 return phoneNumber;
1694} 1694}
1695 1695
1696PhoneNumber::List Addressee::phoneNumbers() const 1696PhoneNumber::List Addressee::phoneNumbers() const
1697{ 1697{
1698 return mData->phoneNumbers; 1698 return mData->phoneNumbers;
1699} 1699}
1700 1700
1701int Addressee::hasPhoneNumberType( int type ) 1701int Addressee::hasPhoneNumberType( int type )
1702{ 1702{
1703 int retval = 0; 1703 int retval = 0;
1704 PhoneNumber::List::ConstIterator it; 1704 PhoneNumber::List::ConstIterator it;
1705 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1705 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1706 if ( (*it).type() == type ) 1706 if ( (*it).type() == type )
1707 ++retval; 1707 ++retval;
1708 } 1708 }
1709 return retval; 1709 return retval;
1710} 1710}
1711PhoneNumber::List Addressee::phoneNumbers( int type ) const 1711PhoneNumber::List Addressee::phoneNumbers( int type ) const
1712{ 1712{
1713 PhoneNumber::List list; 1713 PhoneNumber::List list;
1714 1714
1715 PhoneNumber::List::ConstIterator it; 1715 PhoneNumber::List::ConstIterator it;
1716 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1716 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1717 if ( matchBinaryPattern( (*it).type(), type ) ) { 1717 if ( matchBinaryPattern( (*it).type(), type ) ) {
1718 list.append( *it ); 1718 list.append( *it );
1719 } 1719 }
1720 } 1720 }
1721 return list; 1721 return list;
1722} 1722}
1723 1723
1724PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1724PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1725{ 1725{
1726 PhoneNumber::List::ConstIterator it; 1726 PhoneNumber::List::ConstIterator it;
1727 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1727 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1728 if ( (*it).id() == id ) { 1728 if ( (*it).id() == id ) {
1729 return *it; 1729 return *it;
1730 } 1730 }
1731 } 1731 }
1732 return PhoneNumber(); 1732 return PhoneNumber();
1733} 1733}
1734 1734
1735void Addressee::insertKey( const Key &key ) 1735void Addressee::insertKey( const Key &key )
1736{ 1736{
1737 detach(); 1737 detach();
1738 mData->empty = false; 1738 mData->empty = false;
1739 1739
1740 Key::List::Iterator it; 1740 Key::List::Iterator it;
1741 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1741 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1742 if ( (*it).id() == key.id() ) { 1742 if ( (*it).id() == key.id() ) {
1743 *it = key; 1743 *it = key;
1744 return; 1744 return;
1745 } 1745 }
1746 } 1746 }
1747 mData->keys.append( key ); 1747 mData->keys.append( key );
1748} 1748}
1749 1749
1750void Addressee::removeKey( const Key &key ) 1750void Addressee::removeKey( const Key &key )
1751{ 1751{
1752 detach(); 1752 detach();
1753 1753
1754 Key::List::Iterator it; 1754 Key::List::Iterator it;
1755 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1755 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1756 if ( (*it).id() == key.id() ) { 1756 if ( (*it).id() == key.id() ) {
1757 mData->keys.remove( key ); 1757 mData->keys.remove( key );
1758 return; 1758 return;
1759 } 1759 }
1760 } 1760 }
1761} 1761}
1762 1762
1763Key Addressee::key( int type, QString customTypeString ) const 1763Key Addressee::key( int type, QString customTypeString ) const
1764{ 1764{
1765 Key::List::ConstIterator it; 1765 Key::List::ConstIterator it;
1766 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1766 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1767 if ( (*it).type() == type ) { 1767 if ( (*it).type() == type ) {
1768 if ( type == Key::Custom ) { 1768 if ( type == Key::Custom ) {
1769 if ( customTypeString.isEmpty() ) { 1769 if ( customTypeString.isEmpty() ) {
1770 return *it; 1770 return *it;
1771 } else { 1771 } else {
1772 if ( (*it).customTypeString() == customTypeString ) 1772 if ( (*it).customTypeString() == customTypeString )
1773 return (*it); 1773 return (*it);
1774 } 1774 }
1775 } else { 1775 } else {
1776 return *it; 1776 return *it;
1777 } 1777 }
1778 } 1778 }
1779 } 1779 }
1780 return Key( QString(), type ); 1780 return Key( QString(), type );
1781} 1781}
1782void Addressee::setKeys( const Key::List& list ) { 1782void Addressee::setKeys( const Key::List& list ) {
1783 detach(); 1783 detach();
1784 mData->keys = list; 1784 mData->keys = list;
1785} 1785}
1786 1786
1787Key::List Addressee::keys() const 1787Key::List Addressee::keys() const
1788{ 1788{
1789 return mData->keys; 1789 return mData->keys;
1790} 1790}
1791 1791
1792Key::List Addressee::keys( int type, QString customTypeString ) const 1792Key::List Addressee::keys( int type, QString customTypeString ) const
1793{ 1793{
1794 Key::List list; 1794 Key::List list;
1795 1795
1796 Key::List::ConstIterator it; 1796 Key::List::ConstIterator it;
1797 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1797 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1798 if ( (*it).type() == type ) { 1798 if ( (*it).type() == type ) {
1799 if ( type == Key::Custom ) { 1799 if ( type == Key::Custom ) {
1800 if ( customTypeString.isEmpty() ) { 1800 if ( customTypeString.isEmpty() ) {
1801 list.append(*it); 1801 list.append(*it);
1802 } else { 1802 } else {
1803 if ( (*it).customTypeString() == customTypeString ) 1803 if ( (*it).customTypeString() == customTypeString )
1804 list.append(*it); 1804 list.append(*it);
1805 } 1805 }
1806 } else { 1806 } else {
1807 list.append(*it); 1807 list.append(*it);
1808 } 1808 }
1809 } 1809 }
1810 } 1810 }
1811 return list; 1811 return list;
1812} 1812}
1813 1813
1814Key Addressee::findKey( const QString &id ) const 1814Key Addressee::findKey( const QString &id ) const
1815{ 1815{
1816 Key::List::ConstIterator it; 1816 Key::List::ConstIterator it;
1817 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1817 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1818 if ( (*it).id() == id ) { 1818 if ( (*it).id() == id ) {
1819 return *it; 1819 return *it;
1820 } 1820 }
1821 } 1821 }
1822 return Key(); 1822 return Key();
1823} 1823}
1824 1824
1825QString Addressee::asString() const 1825QString Addressee::asString() const
1826{ 1826{
1827 return "Smith, agent Smith..."; 1827 return "Smith, agent Smith...";
1828} 1828}
1829 1829
1830void Addressee::dump() const 1830void Addressee::dump() const
1831{ 1831{
1832 return; 1832 return;
1833#if 0 1833#if 0
1834 kdDebug(5700) << "Addressee {" << endl; 1834 kdDebug(5700) << "Addressee {" << endl;
1835 1835
1836 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1836 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1837 1837
1838 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1838 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1839 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1839 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1840 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1840 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1841 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1841 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1842 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1842 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1843 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1843 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1844 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1844 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1845 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1845 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1846 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1846 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1847 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1847 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1848 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1848 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1849 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1849 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1850 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1850 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1851 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1851 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1852 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1852 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1853 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1853 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1854 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1854 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1855 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1855 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1856 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1856 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1857 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1857 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1858 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1858 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1859 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1859 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1860 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1860 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1861 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1861 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1862 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1862 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1863 1863
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 5c24acf..cde19a1 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -1,714 +1,739 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kabc/address.h> 22#include <kabc/address.h>
23#include <kabc/addressee.h> 23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h> 24#include <kabc/phonenumber.h>
25#include <kglobal.h> 25#include <kglobal.h>
26//US#include <kglobalsettings.h> 26//US#include <kglobalsettings.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <klocale.h> 28#include <klocale.h>
29//US #include <kstringhandler.h> 29//US #include <kstringhandler.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qwidget.h> 35#include <qwidget.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40#include <qpaintdevicemetrics.h> 40#include <qpaintdevicemetrics.h>
41#include <qprinter.h> 41#include <qprinter.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#endif 43#endif
44 44
45 45
46#include <qstylesheet.h> 46#include <qstylesheet.h>
47#include "externalapphandler.h" 47#include "externalapphandler.h"
48#include <kabc/addresseeview.h> 48#include <kabc/addresseeview.h>
49 49
50 50
51//US #ifndef DESKTOP_VERSION 51//US #ifndef DESKTOP_VERSION
52//US #include <qtopia/qcopenvelope_qws.h> 52//US #include <qtopia/qcopenvelope_qws.h>
53//US #include <qpe/qpeapplication.h> 53//US #include <qpe/qpeapplication.h>
54//US #endif 54//US #endif
55 55
56//US static int kphoneInstalled = 0; 56//US static int kphoneInstalled = 0;
57 57
58using namespace KABC; 58using namespace KABC;
59bool AddresseeView::sFullDetailsMode = false; 59bool AddresseeView::sFullDetailsMode = false;
60 60
61AddresseeView::AddresseeView( QWidget *parent, const char *name ) 61AddresseeView::AddresseeView( QWidget *parent, const char *name )
62 : QTextBrowser( parent, name ) 62 : QTextBrowser( parent, name )
63 63
64 64
65{ 65{
66//US setWrapPolicy( QTextEdit::AtWordBoundary ); 66//US setWrapPolicy( QTextEdit::AtWordBoundary );
67 setLinkUnderline( false ); 67 setLinkUnderline( false );
68 // setVScrollBarMode( QScrollView::AlwaysOff ); 68 // setVScrollBarMode( QScrollView::AlwaysOff );
69 //setHScrollBarMode( QScrollView::AlwaysOff ); 69 //setHScrollBarMode( QScrollView::AlwaysOff );
70 70
71//US QStyleSheet *sheet = styleSheet(); 71//US QStyleSheet *sheet = styleSheet();
72//US QStyleSheetItem *link = sheet->item( "a" ); 72//US QStyleSheetItem *link = sheet->item( "a" );
73//US link->setColor( KGlobalSettings::linkColor() ); 73//US link->setColor( KGlobalSettings::linkColor() );
74 74
75 75
76} 76}
77void AddresseeView::printMe() 77void AddresseeView::printMe()
78{ 78{
79#ifdef DESKTOP_VERSION 79#ifdef DESKTOP_VERSION
80 QPrinter printer; 80 QPrinter printer;
81 if (!printer.setup() ) 81 if (!printer.setup() )
82 return; 82 return;
83 QPainter p; 83 QPainter p;
84 p.begin ( &printer ); 84 p.begin ( &printer );
85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
86 float dx, dy; 86 float dx, dy;
87 int wid = (m.width() * 9)/10; 87 int wid = (m.width() * 9)/10;
88 dx = (float) wid/(float)contentsWidth (); 88 dx = (float) wid/(float)contentsWidth ();
89 dy = (float)(m.height()) / (float)contentsHeight (); 89 dy = (float)(m.height()) / (float)contentsHeight ();
90 float scale; 90 float scale;
91 // scale to fit the width or height of the paper 91 // scale to fit the width or height of the paper
92 if ( dx < dy ) 92 if ( dx < dy )
93 scale = dx; 93 scale = dx;
94 else 94 else
95 scale = dy; 95 scale = dy;
96 p.translate( m.width()/10,0 ); 96 p.translate( m.width()/10,0 );
97 p.scale( scale, scale ); 97 p.scale( scale, scale );
98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
99 p.end(); 99 p.end();
100#endif 100#endif
101} 101}
102void AddresseeView::setSource(const QString& n) 102void AddresseeView::setSource(const QString& n)
103{ 103{
104 //qDebug("********AddresseeView::setSource %s", n.latin1()); 104 //qDebug("********AddresseeView::setSource %s", n.latin1());
105 105
106 if ( n == "allDetails" ) { 106 if ( n == "allDetails" ) {
107 sFullDetailsMode = true; 107 sFullDetailsMode = true;
108 setAddressee( mCurrentContact ); 108 setAddressee( mCurrentContact );
109 } else if ( n == "notAllDetails" ) { 109 } else if ( n == "notAllDetails" ) {
110 sFullDetailsMode = false; 110 sFullDetailsMode = false;
111 setAddressee( mCurrentContact ); 111 setAddressee( mCurrentContact );
112 } else if ( n.left( 6 ) == "mailto" ) 112 } else if ( n.left( 6 ) == "mailto" )
113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
114 else if ( n.left( 7 ) == "phoneto" ) 114 else if ( n.left( 7 ) == "phoneto" )
115 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 115 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
116 else if ( n.left( 5 ) == "faxto" ) 116 else if ( n.left( 5 ) == "faxto" )
117 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 117 ExternalAppHandler::instance()->callByFax( n.mid(6) );
118 else if ( n.left( 5 ) == "smsto" ) 118 else if ( n.left( 5 ) == "smsto" )
119 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 119 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
120 else if ( n.left( 7 ) == "pagerto" ) 120 else if ( n.left( 7 ) == "pagerto" )
121 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 121 ExternalAppHandler::instance()->callByPager( n.mid(8) );
122 else if ( n.left( 5 ) == "sipto" ) 122 else if ( n.left( 5 ) == "sipto" )
123 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 123 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
124 124
125} 125}
126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) 126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
127{ 127{
128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); 128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
129 // mAddressee = addr; 129 // mAddressee = addr;
130 // clear view 130 // clear view
131 //setText( QString::null ); 131 //setText( QString::null );
132 mCurrentContact = mAddressee; 132 mCurrentContact = mAddressee;
133 if ( mAddressee.isEmpty() ) { 133 if ( mAddressee.isEmpty() ) {
134 setText( QString::null); 134 setText( QString::null);
135 return; 135 return;
136 } 136 }
137#if 0 137#if 0
138 QString name = ( mAddressee.assembledName().isEmpty() ? 138 QString name = ( mAddressee.assembledName().isEmpty() ?
139 mAddressee.formattedName() : mAddressee.assembledName() ); 139 mAddressee.formattedName() : mAddressee.assembledName() );
140#endif 140#endif
141 141
142 QString name = mAddressee.realName(); 142 QString name = mAddressee.realName();
143 QString assName = mAddressee.assembledName(); 143 QString assName = mAddressee.assembledName();
144 if ( assName.isEmpty() ) 144 if ( assName.isEmpty() )
145 assName = name; 145 assName = name;
146 QString dynamicPart; 146 QString dynamicPart;
147 147
148 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); 148 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
149 QStringList emails = mAddressee.emails(); 149 QStringList emails = mAddressee.emails();
150 QStringList::ConstIterator emailIt; 150 QStringList::ConstIterator emailIt;
151 QString type = i18n( "Email" ); 151 QString type = i18n( "Email" );
152 emailIt = emails.begin(); 152 emailIt = emails.begin();
153 if ( emailIt != emails.end() ) { 153 if ( emailIt != emails.end() ) {
154 if ( kemailAvail ) { 154 if ( kemailAvail ) {
155 dynamicPart += QString( 155 dynamicPart += QString(
156 "<tr><td align=\"right\"><b>%1</b></td>" 156 "<tr><td align=\"right\"><b>%1</b></td>"
157 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 157 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
158 .arg( type ) 158 .arg( type )
159 .arg( assName ) 159 .arg( assName )
160 .arg( *emailIt ) 160 .arg( *emailIt )
161 .arg( *emailIt ); 161 .arg( *emailIt );
162 ++emailIt; 162 ++emailIt;
163 } else { 163 } else {
164 dynamicPart += QString( 164 dynamicPart += QString(
165 "<tr><td align=\"right\"><b>%1</b></td>" 165 "<tr><td align=\"right\"><b>%1</b></td>"
166 "<td align=\"left\">%2</td></tr>" ) 166 "<td align=\"left\">%2</td></tr>" )
167 .arg( type ) 167 .arg( type )
168 .arg( *emailIt ); 168 .arg( *emailIt );
169 ++emailIt; 169 ++emailIt;
170 } 170 }
171 } 171 }
172 if ( mAddressee.birthday().date().isValid() ) { 172 if ( mAddressee.birthday().date().isValid() ) {
173 dynamicPart += QString( 173 dynamicPart += QString(
174 "<tr><td align=\"right\"><b>%1</b></td>" 174 "<tr><td align=\"right\"><b>%1</b></td>"
175 "<td align=\"left\">%2</td></tr>" ) 175 "<td align=\"left\">%2</td></tr>" )
176 .arg( i18n ("Birthday") ) 176 .arg( i18n ("Birthday") )
177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
178 } 178 }
179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); 179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
180 180
181 for ( ; emailIt != emails.end(); ++emailIt ) { 181 for ( ; emailIt != emails.end(); ++emailIt ) {
182 if ( kemailAvail ) { 182 if ( kemailAvail ) {
183 dynamicPart += QString( 183 dynamicPart += QString(
184 "<tr><td align=\"right\"><b>%1</b></td>" 184 "<tr><td align=\"right\"><b>%1</b></td>"
185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
186 .arg( type ) 186 .arg( type )
187 .arg( name ) 187 .arg( name )
188 .arg( *emailIt ) 188 .arg( *emailIt )
189 .arg( *emailIt ); 189 .arg( *emailIt );
190 } else { 190 } else {
191 dynamicPart += QString( 191 dynamicPart += QString(
192 "<tr><td align=\"right\"><b>%1</b></td>" 192 "<tr><td align=\"right\"><b>%1</b></td>"
193 "<td align=\"left\">%2</td></tr>" ) 193 "<td align=\"left\">%2</td></tr>" )
194 .arg( type ) 194 .arg( type )
195 .arg( *emailIt ); 195 .arg( *emailIt );
196 } 196 }
197 } 197 }
198 198
199 199
200 200
201 KABC::Address::List addresses = mAddressee.addresses(); 201 KABC::Address::List addresses = mAddressee.addresses();
202 KABC::Address::List::ConstIterator addrIt; 202 KABC::Address::List::ConstIterator addrIt;
203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
204 if ( true /*(*addrIt).label().isEmpty()*/ ) { 204 if ( true /*(*addrIt).label().isEmpty()*/ ) {
205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
206//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 206//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
207 //qDebug("adresss %s ",formattedAddress.latin1() ); 207 //qDebug("adresss %s ",formattedAddress.latin1() );
208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
209 //qDebug("AddresseeView::setAddressee has to be verified."); 209 //qDebug("AddresseeView::setAddressee has to be verified.");
210 210
211 dynamicPart += QString( 211 dynamicPart += QString(
212 "<tr><td align=\"right\"><b>%1</b></td>" 212 "<tr><td align=\"right\"><b>%1</b></td>"
213 "<td align=\"left\">%2</td></tr>" ) 213 "<td align=\"left\">%2</td></tr>" )
214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
215 .arg( formattedAddress ); 215 .arg( formattedAddress );
216 } else { 216 } else {
217 217
218 dynamicPart += QString( 218 dynamicPart += QString(
219 "<tr><td align=\"right\"><b>%1</b></td>" 219 "<tr><td align=\"right\"><b>%1</b></td>"
220 "<td align=\"left\">%2</td></tr>" ) 220 "<td align=\"left\">%2</td></tr>" )
221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
224 224
225 } 225 }
226 } 226 }
227 227
228 228
229 QString notes; 229 QString notes;
230 if ( sFullDetailsMode ) { 230 if ( sFullDetailsMode ) {
231 notes = QString( 231 notes = QString(
232 "<tr><td align=\"right\"><b>%1</b></td>" 232 "<tr><td align=\"right\"><b>%1</b></td>"
233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) 233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" )
234 .arg( i18n("Details") ) 234 .arg( i18n("Details") )
235 .arg( i18n("Hide!") ); 235 .arg( i18n("Hide!") );
236 236
237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
238 if ( !tempX.isEmpty() ) { 238 if ( !tempX.isEmpty() ) {
239 if ( tempX == "male" || tempX == "female" ) { 239 if ( tempX == "male" || tempX == "female" ) {
240 notes += QString( 240 notes += QString(
241 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
242 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
243 .arg( i18n( "" ) ) 243 .arg( i18n( "" ) )
244 .arg( i18n(tempX) ); 244 .arg( i18n(tempX) );
245 } 245 }
246 } 246 }
247 247
248 248
249 tempX = mAddressee.secrecy().asString(); 249 tempX = mAddressee.secrecy().asString();
250 250
251 notes += QString( 251 notes += QString(
252 "<tr><td align=\"right\"><b>%1</b></td>" 252 "<tr><td align=\"right\"><b>%1</b></td>"
253 "<td align=\"left\">%2</td></tr>" ) 253 "<td align=\"left\">%2</td></tr>" )
254 .arg( "" ) 254 .arg( "" )
255 .arg( tempX ); 255 .arg( tempX );
256 256
257 257
258 tempX = mAddressee.categories().join(" - "); 258 tempX = mAddressee.categories().join(" - ");
259 if ( !tempX.isEmpty() ) { 259 if ( !tempX.isEmpty() ) {
260 notes += QString( 260 notes += QString(
261 "<tr><td align=\"right\"><b>%1</b></td>" 261 "<tr><td align=\"right\"><b>%1</b></td>"
262 "<td align=\"left\">%2</td></tr>" ) 262 "<td align=\"left\">%2</td></tr>" )
263 .arg( i18n( "Category" ) ) 263 .arg( i18n( "Category" ) )
264 .arg( tempX ); 264 .arg( tempX );
265 } 265 }
266 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" ); 266 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" );
267 if ( !tempX.isEmpty() ) { 267 if ( !tempX.isEmpty() ) {
268 notes += QString( 268 notes += QString(
269 "<tr><td align=\"right\"><b>%1</b></td>" 269 "<tr><td align=\"right\"><b>%1</b></td>"
270 "<td align=\"left\">%2</td></tr>" ) 270 "<td align=\"left\">%2</td></tr>" )
271 .arg( i18n( "Profession" ) ) 271 .arg( i18n( "Profession" ) )
272 .arg( tempX ); 272 .arg( tempX );
273 } 273 }
274 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" ); 274 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" );
275 if ( !tempX.isEmpty() ) { 275 if ( !tempX.isEmpty() ) {
276 notes += QString( 276 notes += QString(
277 "<tr><td align=\"right\"><b>%1</b></td>" 277 "<tr><td align=\"right\"><b>%1</b></td>"
278 "<td align=\"left\">%2</td></tr>" ) 278 "<td align=\"left\">%2</td></tr>" )
279 .arg( i18n( "Office" ) ) 279 .arg( i18n( "Office" ) )
280 .arg( tempX ); 280 .arg( tempX );
281 } 281 }
282 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" ); 282 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" );
283 if ( !tempX.isEmpty() ) { 283 if ( !tempX.isEmpty() ) {
284 notes += QString( 284 notes += QString(
285 "<tr><td align=\"right\"><b>%1</b></td>" 285 "<tr><td align=\"right\"><b>%1</b></td>"
286 "<td align=\"left\">%2</td></tr>" ) 286 "<td align=\"left\">%2</td></tr>" )
287 .arg( i18n( "Department" ) ) 287 .arg( i18n( "Department" ) )
288 .arg( tempX ); 288 .arg( tempX );
289 } 289 }
290 290
291 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ); 291 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" );
292 if ( !tempX.isEmpty() ) { 292 if ( !tempX.isEmpty() ) {
293 notes += QString( 293 notes += QString(
294 "<tr><td align=\"right\"><b>%1</b></td>" 294 "<tr><td align=\"right\"><b>%1</b></td>"
295 "<td align=\"left\">%2</td></tr>" ) 295 "<td align=\"left\">%2</td></tr>" )
296 .arg( i18n( "Manager" ) ) 296 .arg( i18n( "Manager" ) )
297 .arg( tempX ); 297 .arg( tempX );
298 } 298 }
299 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); 299 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" );
300 if ( !tempX.isEmpty() ) { 300 if ( !tempX.isEmpty() ) {
301 notes += QString( 301 notes += QString(
302 "<tr><td align=\"right\"><b>%1</b></td>" 302 "<tr><td align=\"right\"><b>%1</b></td>"
303 "<td align=\"left\">%2</td></tr>" ) 303 "<td align=\"left\">%2</td></tr>" )
304 .arg( i18n( "Assistant" ) ) 304 .arg( i18n( "Assistant" ) )
305 .arg( tempX ); 305 .arg( tempX );
306 } 306 }
307 if ( !mAddressee.url().url().isEmpty() ) { 307 if ( !mAddressee.url().url().isEmpty() ) {
308 notes += QString( 308 notes += QString(
309 "<tr><td align=\"right\"><b>%1</b></td>" 309 "<tr><td align=\"right\"><b>%1</b></td>"
310 "<td align=\"left\">%2</td></tr>" ) 310 "<td align=\"left\">%2</td></tr>" )
311 .arg( i18n( "Homepage" ) ) 311 .arg( i18n( "Homepage" ) )
312 .arg( mAddressee.url().url() ); 312 .arg( mAddressee.url().url() );
313 } 313 }
314 tempX = mAddressee.nickName(); 314 tempX = mAddressee.nickName();
315 if ( !tempX.isEmpty() ) { 315 if ( !tempX.isEmpty() ) {
316 notes += QString( 316 notes += QString(
317 "<tr><td align=\"right\"><b>%1</b></td>" 317 "<tr><td align=\"right\"><b>%1</b></td>"
318 "<td align=\"left\">%2</td></tr>" ) 318 "<td align=\"left\">%2</td></tr>" )
319 .arg( i18n( "Nickname" ) ) 319 .arg( i18n( "Nickname" ) )
320 .arg( tempX ); 320 .arg( tempX );
321 } 321 }
322 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); 322 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" );
323 if ( !tempX.isEmpty() ) { 323 if ( !tempX.isEmpty() ) {
324 notes += QString( 324 notes += QString(
325 "<tr><td align=\"right\"><b>%1</b></td>" 325 "<tr><td align=\"right\"><b>%1</b></td>"
326 "<td align=\"left\">%2</td></tr>" ) 326 "<td align=\"left\">%2</td></tr>" )
327 .arg( i18n( "Messanger" ) ) 327 .arg( i18n( "Messanger" ) )
328 .arg( tempX ); 328 .arg( tempX );
329 } 329 }
330 330
331 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); 331 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" );
332 if ( !tempX.isEmpty() ) { 332 if ( !tempX.isEmpty() ) {
333 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); 333 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d");
334 if ( dt.isValid () ) { 334 if ( dt.isValid () ) {
335 tempX = KGlobal::locale()->formatDate(dt, true); 335 tempX = KGlobal::locale()->formatDate(dt, true);
336 notes += QString( 336 notes += QString(
337 "<tr><td align=\"right\"><b>%1</b></td>" 337 "<tr><td align=\"right\"><b>%1</b></td>"
338 "<td align=\"left\">%2</td></tr>" ) 338 "<td align=\"left\">%2</td></tr>" )
339 .arg( i18n( "Anniversary" ) ) 339 .arg( i18n( "Anniversary" ) )
340 .arg( tempX ); 340 .arg( tempX );
341 } 341 }
342 } 342 }
343 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); 343 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" );
344 if ( !tempX.isEmpty() ) { 344 if ( !tempX.isEmpty() ) {
345 notes += QString( 345 notes += QString(
346 "<tr><td align=\"right\"><b>%1</b></td>" 346 "<tr><td align=\"right\"><b>%1</b></td>"
347 "<td align=\"left\">%2</td></tr>" ) 347 "<td align=\"left\">%2</td></tr>" )
348 .arg( i18n( "Spouse" ) ) 348 .arg( i18n( "Spouse" ) )
349 .arg( tempX ); 349 .arg( tempX );
350 } 350 }
351 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); 351 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" );
352 if ( !tempX.isEmpty() ) { 352 if ( !tempX.isEmpty() ) {
353 notes += QString( 353 notes += QString(
354 "<tr><td align=\"right\"><b>%1</b></td>" 354 "<tr><td align=\"right\"><b>%1</b></td>"
355 "<td align=\"left\">%2</td></tr>" ) 355 "<td align=\"left\">%2</td></tr>" )
356 .arg( i18n( "Children" ) ) 356 .arg( i18n( "Children" ) )
357 .arg( tempX ); 357 .arg( tempX );
358 } 358 }
359 359
360 if ( !mAddressee.note().isEmpty() ) { 360 if ( !mAddressee.note().isEmpty() ) {
361 notes += QString( 361 notes += QString(
362 "<tr>" 362 "<tr>"
363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
364 "<td align=\"left\">%2</td>" // note 364 "<td align=\"left\">%2</td>" // note
365 "</tr>" ).arg( i18n( "Notes" ) ) 365 "</tr>" ).arg( i18n( "Notes" ) )
366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) );
367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
368 //qDebug("AddresseeView::setAddressee has to be verified."); 368 //qDebug("AddresseeView::setAddressee has to be verified.");
369 } 369 }
370 } else { 370 } else {
371 notes = QString( 371 notes = QString(
372 "<tr><td align=\"right\"><b>%1</b></td>" 372 "<tr><td align=\"right\"><b>%1</b></td>"
373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) 373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" )
374 .arg( i18n("Details") ) 374 .arg( i18n("Details") )
375 .arg( i18n("Show!") ); 375 .arg( i18n("Show!") );
376 376
377 377
378 } 378 }
379 379
380 QString aRole = ""; 380 QString aRole = "";
381 QString aOrga = ""; 381 QString aOrga = "";
382 if ( true /*!mAddressee.role().isEmpty()*/ ) { 382 if ( true /*!mAddressee.role().isEmpty()*/ ) {
383 aRole = "<tr>" 383 aRole = "<tr>"
384 "<td align=\"left\">" + mAddressee.role() + "</td>" 384 "<td align=\"left\">" + mAddressee.role() + "</td>"
385 "</tr>"; 385 "</tr>";
386 } 386 }
387 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 387 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
388 aOrga = "<tr>" 388 aOrga = "<tr>"
389 "<td align=\"left\">" + mAddressee.organization() + "</td>" 389 "<td align=\"left\">" + mAddressee.organization() + "</td>"
390 "</tr>"; 390 "</tr>";
391 } 391 }
392 mText = ""; 392 mText = "";
393 QString picString = ""; 393 QString picString = "";
394 KABC::Picture picture = mAddressee.photo(); 394 KABC::Picture picture = mAddressee.photo();
395 if (picture.undefined() ) picture = mAddressee.logo(); 395 if (picture.undefined() ) picture = mAddressee.logo();
396 bool picAvailintern = false; 396 bool picAvailintern = false;
397 bool picAvailUrl = false; 397 bool picAvailUrl = false;
398 if (! picture.undefined() ) { 398 if (! picture.undefined() ) {
399 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 399 picAvailintern = (picture.isIntern() && !picture.data().isNull());
400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
401 } 401 }
402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
404 if ( picAvailintern ) { 404 if ( picAvailintern ) {
405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
406 int wid = picture.data().width(); 406 int wid = picture.data().width();
407 int hei = picture.data().height(); 407 int hei = picture.data().height();
408 if ( wid > 128 || hei > 128 ) { 408 if ( wid > 128 || hei > 128 ) {
409 if ( wid > hei ) { 409 if ( wid > hei ) {
410 hei = (hei*128)/wid; 410 hei = (hei*128)/wid;
411 wid = 128; 411 wid = 128;
412 } else { 412 } else {
413 wid = (wid*128)/hei; 413 wid = (wid*128)/hei;
414 hei = 128; 414 hei = 128;
415 } 415 }
416 } 416 }
417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
418 } else { 418 } else {
419 if ( picAvailUrl ) { 419 if ( picAvailUrl ) {
420 QPixmap picPix( picture.url() ); 420 QPixmap picPix( picture.url() );
421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); 421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix );
422 int wid = picPix.width(); 422 int wid = picPix.width();
423 int hei = picPix.height(); 423 int hei = picPix.height();
424 if ( wid > 128 || hei > 128 ) { 424 if ( wid > 128 || hei > 128 ) {
425 if ( wid > hei ) { 425 if ( wid > hei ) {
426 hei = (hei*128)/wid; 426 hei = (hei*128)/wid;
427 wid = 128; 427 wid = 128;
428 } else { 428 } else {
429 wid = (wid*128)/hei; 429 wid = (wid*128)/hei;
430 hei = 128; 430 hei = 128;
431 } 431 }
432 } 432 }
433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
434 } else { 434 } else {
435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { 435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
436 static bool setDefaultImageChildren = false; 436 static bool setDefaultImageChildren = false;
437 if ( !setDefaultImageChildren ) { 437 if ( !setDefaultImageChildren ) {
438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); 438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
439 setDefaultImageChildren = true; 439 setDefaultImageChildren = true;
440 } 440 }
441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; 441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
442 442
443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { 443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
444 static bool setDefaultImagepouses = false; 444 static bool setDefaultImagepouses = false;
445 if ( !setDefaultImagepouses ) { 445 if ( !setDefaultImagepouses ) {
446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); 446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
447 setDefaultImagepouses = true; 447 setDefaultImagepouses = true;
448 } 448 }
449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; 449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
450 } else { 450 } else {
451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
452 if ( gen == "male" ) { 452 if ( gen == "male" ) {
453 static bool setDefaultImageMale = false; 453 static bool setDefaultImageMale = false;
454 if ( !setDefaultImageMale ) { 454 if ( !setDefaultImageMale ) {
455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); 455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
456 setDefaultImageMale = true; 456 setDefaultImageMale = true;
457 } 457 }
458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; 458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
459 459
460 } else if ( gen == "female" ) { 460 } else if ( gen == "female" ) {
461 static bool setDefaultImageFemale = false; 461 static bool setDefaultImageFemale = false;
462 if ( !setDefaultImageFemale ) { 462 if ( !setDefaultImageFemale ) {
463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); 463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
464 setDefaultImageFemale = true; 464 setDefaultImageFemale = true;
465 } 465 }
466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; 466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
467 467
468 } else { 468 } else {
469 static bool setDefaultImage = false; 469 static bool setDefaultImage = false;
470 if ( !setDefaultImage ) { 470 if ( !setDefaultImage ) {
471 //qDebug("Setting default pixmap "); 471 //qDebug("Setting default pixmap ");
472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); 472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
473 setDefaultImage = true; 473 setDefaultImage = true;
474 } 474 }
475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; 475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
476 } 476 }
477 } 477 }
478 } 478 }
479 } 479 }
480 mText = QString::fromLatin1( 480 mText = QString::fromLatin1(
481 "<html>" 481 "<html>"
482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
483 "<table>" 483 "<table>"
484 "<tr>" 484 "<tr>"
485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
486 "%3" 486 "%3"
487 "</td>" 487 "</td>"
488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
489 "</tr>" 489 "</tr>"
490 "%5" // role 490 "%5" // role
491 "%6" // organization 491 "%6" // organization
492 "<td colspan=\"2\">&nbsp;</td>" 492 "<td colspan=\"2\">&nbsp;</td>"
493 "%7" // dynamic part 493 "%7" // dynamic part
494 "%8" // notes 494 "%8" // notes
495 "</table>" 495 "</table>"
496 "</body>" 496 "</body>"
497 "</html>") 497 "</html>")
498//US 498//US
499 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 499 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
500//US 500//US
501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
502 .arg( picString ) 502 .arg( picString )
503 .arg( name ) 503 .arg( name )
504 .arg( aRole ) 504 .arg( aRole )
505 .arg( aOrga ) 505 .arg( aOrga )
506 .arg( dynamicPart ) 506 .arg( dynamicPart )
507 .arg( notes ); 507 .arg( notes );
508 508
509 } else { // no picture! 509 } else { // no picture!
510 510
511mText = "<table width=\"100%\">\n"; 511mText = "<table width=\"100%\">\n";
512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
513#ifdef DESKTOP_VERSION 513#ifdef DESKTOP_VERSION
514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; 515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
516#else 516#else
517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; 517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; 518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
519#endif 519#endif
520 520
521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
522 522
523 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 523 mText += "<table><td colspan=\"2\">&nbsp;</td>";
524 /* 524 /*
525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
526 "<td align=\"left\"><b>%2</b></td></tr>" ) 526 "<td align=\"left\"><b>%2</b></td></tr>" )
527 .arg( i18n(" ") ) 527 .arg( i18n(" ") )
528 .arg( name ); 528 .arg( name );
529 */ 529 */
530 if ( ! mAddressee.role().isEmpty() ) 530 if ( ! mAddressee.role().isEmpty() )
531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
532 "<td align=\"left\">%2</td></tr>" ) 532 "<td align=\"left\">%2</td></tr>" )
533 .arg( i18n(" ") ) 533 .arg( i18n(" ") )
534 .arg( mAddressee.role()); 534 .arg( mAddressee.role());
535 if ( ! mAddressee.organization().isEmpty() ) 535 if ( ! mAddressee.organization().isEmpty() )
536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
537 "<td align=\"left\">%2</td></tr>" ) 537 "<td align=\"left\">%2</td></tr>" )
538 .arg( i18n(" ") ) 538 .arg( i18n(" ") )
539 .arg( mAddressee.organization()); 539 .arg( mAddressee.organization());
540 mText += dynamicPart; 540 mText += dynamicPart;
541 mText += notes; 541 mText += notes;
542 mText += "</table>"; 542 mText += "</table>";
543 543
544 } 544 }
545 545
546 // at last display it... 546 // at last display it...
547 setText( mText ); 547 setText( mText );
548 548
549} 549}
550 550
551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) 551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones_unsorted ,bool preferred )
552{ 552{
553 ExternalAppHandler* eah = ExternalAppHandler::instance(); 553 ExternalAppHandler* eah = ExternalAppHandler::instance();
554 bool kphoneAvail = eah->isPhoneAppAvailable(); 554 bool kphoneAvail = eah->isPhoneAppAvailable();
555 bool kfaxAvail = eah->isFaxAppAvailable(); 555 bool kfaxAvail = eah->isFaxAppAvailable();
556 bool ksmsAvail = eah->isSMSAppAvailable(); 556 bool ksmsAvail = eah->isSMSAppAvailable();
557 bool kpagerAvail = eah->isPagerAppAvailable(); 557 bool kpagerAvail = eah->isPagerAppAvailable();
558 bool ksipAvail = eah->isSIPAppAvailable(); 558 bool ksipAvail = eah->isSIPAppAvailable();
559 QString dynamicPart; 559 QString dynamicPart;
560 KABC::PhoneNumber::List::ConstIterator phoneIt; 560 KABC::PhoneNumber::List::ConstIterator phoneIt;
561 QString extension; 561 QString extension;
562 int phonetype; 562 int phonetype;
563 QString sms; 563 QString sms;
564
565 KABC::PhoneNumber::List::Iterator it;
566 KABC::PhoneNumber::List phones ;
567
568 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
569 int i = 0;
570 int max = tList.count();
571 while ( i < max-1 ) {
572 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
573 if ( (*it).type() == tList[i] ) {
574 phones.append( (*it ) );
575 break;
576 }
577 }
578 ++i;
579 }
580 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
581 if ( (*it).type() == tList[ max-1 ] )
582 phones.append( (*it ) );
583 }
584
564 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 585 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
565 phonetype = (*phoneIt).type(); 586 phonetype = (*phoneIt).type();
566 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 587 bool con = false;
588 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) con = true;
589 if ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell ) con = !preferred;;
590 if ( con )
567 continue; 591 continue;
592
568 if (ksmsAvail && 593 if (ksmsAvail &&
569 ( 594 (
570 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 595 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
571 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 596 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
572 ) 597 )
573 ) 598 )
574 { 599 {
575 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 600 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
576 .arg( (*phoneIt).number() ); 601 .arg( (*phoneIt).number() );
577 602
578 } 603 }
579 else 604 else
580 sms = ""; 605 sms = "";
581 606
582 extension = QString::null; 607 extension = QString::null;
583 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 608 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
584 if (kfaxAvail) extension = "faxto:"; 609 if (kfaxAvail) extension = "faxto:";
585 } 610 }
586 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 611 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
587 if (kpagerAvail) extension = "pagerto:"; 612 if (kpagerAvail) extension = "pagerto:";
588 } 613 }
589#if 0 614#if 0
590 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 615 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
591 if (ksipAvail) extension = "sipto:"; 616 if (ksipAvail) extension = "sipto:";
592 } 617 }
593#endif 618#endif
594 else if (kphoneAvail) { 619 else if (kphoneAvail) {
595 extension = "phoneto:"; 620 extension = "phoneto:";
596 } 621 }
597 else 622 else
598 extension = QString::null; 623 extension = QString::null;
599 624
600 if ( !extension.isEmpty() ) { 625 if ( !extension.isEmpty() ) {
601 dynamicPart += QString( 626 dynamicPart += QString(
602 "<tr><td align=\"right\"><b>%1</b></td>" 627 "<tr><td align=\"right\"><b>%1</b></td>"
603 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 628 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
604 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 629 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
605 .arg( extension ) 630 .arg( extension )
606 .arg( (*phoneIt).number() ) 631 .arg( (*phoneIt).number() )
607 .arg( (*phoneIt).number() ) 632 .arg( (*phoneIt).number() )
608 .arg( sms ); 633 .arg( sms );
609 634
610 } else { 635 } else {
611 dynamicPart += QString( 636 dynamicPart += QString(
612 "<tr><td align=\"right\"><b>%1</b></td>" 637 "<tr><td align=\"right\"><b>%1</b></td>"
613 "<td align=\"left\">%2 %3</td></tr>" ) 638 "<td align=\"left\">%2 %3</td></tr>" )
614 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 639 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
615 .arg( (*phoneIt).number() ) 640 .arg( (*phoneIt).number() )
616 .arg( sms ); 641 .arg( sms );
617 } 642 }
618 } 643 }
619 return dynamicPart; 644 return dynamicPart;
620} 645}
621/* 646/*
622KABC::Addressee AddresseeView::addressee() const 647KABC::Addressee AddresseeView::addressee() const
623{ 648{
624 return mAddressee; 649 return mAddressee;
625} 650}
626*/ 651*/
627void AddresseeView::addTag(const QString & tag,const QString & text) 652void AddresseeView::addTag(const QString & tag,const QString & text)
628{ 653{
629 if ( text.isEmpty() ) 654 if ( text.isEmpty() )
630 return; 655 return;
631 int number=text.contains("\n"); 656 int number=text.contains("\n");
632 QString str = "<" + tag + ">"; 657 QString str = "<" + tag + ">";
633 QString tmpText=text; 658 QString tmpText=text;
634 QString tmpStr=str; 659 QString tmpStr=str;
635 if(number !=-1) 660 if(number !=-1)
636 { 661 {
637 if (number > 0) { 662 if (number > 0) {
638 int pos=0; 663 int pos=0;
639 QString tmp; 664 QString tmp;
640 for(int i=0;i<=number;i++) { 665 for(int i=0;i<=number;i++) {
641 pos=tmpText.find("\n"); 666 pos=tmpText.find("\n");
642 tmp=tmpText.left(pos); 667 tmp=tmpText.left(pos);
643 tmpText=tmpText.right(tmpText.length()-pos-1); 668 tmpText=tmpText.right(tmpText.length()-pos-1);
644 tmpStr+=tmp+"<br>"; 669 tmpStr+=tmp+"<br>";
645 } 670 }
646 } 671 }
647 else tmpStr += tmpText; 672 else tmpStr += tmpText;
648 tmpStr+="</" + tag + ">"; 673 tmpStr+="</" + tag + ">";
649 mText.append(tmpStr); 674 mText.append(tmpStr);
650 } 675 }
651 else 676 else
652 { 677 {
653 str += text + "</" + tag + ">"; 678 str += text + "</" + tag + ">";
654 mText.append(str); 679 mText.append(str);
655 } 680 }
656} 681}
657 682
658AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 683AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
659 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 684 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
660{ 685{
661 findButton( Close )->setText( i18n("Cancel Sync")); 686 findButton( Close )->setText( i18n("Cancel Sync"));
662 findButton( Ok )->setText( i18n("Remote")); 687 findButton( Ok )->setText( i18n("Remote"));
663 findButton( User1 )->setText( i18n("Local")); 688 findButton( User1 )->setText( i18n("Local"));
664 QWidget* topframe = new QWidget( this ); 689 QWidget* topframe = new QWidget( this );
665 setMainWidget( topframe ); 690 setMainWidget( topframe );
666 QBoxLayout* bl; 691 QBoxLayout* bl;
667 if ( QApplication::desktop()->width() < 640 ) { 692 if ( QApplication::desktop()->width() < 640 ) {
668 bl = new QVBoxLayout( topframe ); 693 bl = new QVBoxLayout( topframe );
669 } else { 694 } else {
670 bl = new QHBoxLayout( topframe ); 695 bl = new QHBoxLayout( topframe );
671 } 696 }
672 QVBox* subframe = new QVBox( topframe ); 697 QVBox* subframe = new QVBox( topframe );
673 bl->addWidget(subframe ); 698 bl->addWidget(subframe );
674 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 699 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
675 if ( takeloc ) 700 if ( takeloc )
676 lab->setBackgroundColor(Qt::green.light() ); 701 lab->setBackgroundColor(Qt::green.light() );
677 AddresseeView * av = new AddresseeView( subframe ); 702 AddresseeView * av = new AddresseeView( subframe );
678 av->setAddressee( loc ); 703 av->setAddressee( loc );
679 subframe = new QVBox( topframe ); 704 subframe = new QVBox( topframe );
680 bl->addWidget(subframe ); 705 bl->addWidget(subframe );
681 lab = new QLabel( i18n("Remote Addressee"), subframe ); 706 lab = new QLabel( i18n("Remote Addressee"), subframe );
682 if ( !takeloc ) 707 if ( !takeloc )
683 lab->setBackgroundColor(Qt::green.light() ); 708 lab->setBackgroundColor(Qt::green.light() );
684 av = new AddresseeView( subframe ); 709 av = new AddresseeView( subframe );
685 av->setAddressee( rem ); 710 av->setAddressee( rem );
686 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 711 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
687 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 712 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
688#ifndef DESKTOP_VERSION 713#ifndef DESKTOP_VERSION
689 showMaximized(); 714 showMaximized();
690#else 715#else
691 resize ( 640, 400 ); 716 resize ( 640, 400 );
692#endif 717#endif
693} 718}
694 719
695int AddresseeChooser::executeD( bool local ) 720int AddresseeChooser::executeD( bool local )
696{ 721{
697 mSyncResult = 3; 722 mSyncResult = 3;
698 if ( local ) 723 if ( local )
699 findButton( User1 )->setFocus(); 724 findButton( User1 )->setFocus();
700 else 725 else
701 findButton( Ok )->setFocus(); 726 findButton( Ok )->setFocus();
702 exec(); 727 exec();
703 return mSyncResult; 728 return mSyncResult;
704} 729}
705void AddresseeChooser::slot_remote() 730void AddresseeChooser::slot_remote()
706{ 731{
707 mSyncResult = 2; 732 mSyncResult = 2;
708 accept(); 733 accept();
709} 734}
710void AddresseeChooser::slot_local() 735void AddresseeChooser::slot_local()
711{ 736{
712 mSyncResult = 1; 737 mSyncResult = 1;
713 accept(); 738 accept();
714} 739}
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 6db1bcf..897c56d 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,369 +1,374 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68void PhoneNumber::makeCompat() 68void PhoneNumber::makeCompat()
69{ 69{
70 mType = getCompatType( mType ); 70 mType = getCompatType( mType );
71} 71}
72int PhoneNumber::getCompatType( int type ) 72int PhoneNumber::getCompatType( int type )
73{ 73{
74 74
75 if ((type & Cell) == Cell) { 75 if ((type & Cell) == Cell) {
76 if ((type & Work) == Work) 76 if ((type & Work) == Work)
77 return Car; 77 return Car;
78 return Cell; 78 return Cell;
79 } 79 }
80 if ((type & Home) == Home) { 80 if ((type & Home) == Home) {
81 if ((type & Pref) == Pref) 81 if ((type & Pref) == Pref)
82 return (Home | Pref); 82 return (Home | Pref);
83 if ((type & Fax) == Fax) 83 if ((type & Fax) == Fax)
84 return (Home | Fax); 84 return (Home | Fax);
85 return (Home); 85 return (Home);
86 } 86 }
87 if ((type & Work) == Work) { 87 if ((type & Work) == Work) {
88 if ((type & Pref) == Pref) 88 if ((type & Pref) == Pref)
89 return (Work| Pref); 89 return (Work| Pref);
90 if ((type & Fax) == Fax) 90 if ((type & Fax) == Fax)
91 return (Fax |Work); 91 return (Fax |Work);
92 if ((type & Msg) == Msg) { 92 if ((type & Msg) == Msg) {
93 if ((type & Voice) == Voice) 93 if ((type & Voice) == Voice)
94 return ( Msg | Voice |Work); 94 return ( Msg | Voice |Work);
95 return ( Msg | Work); 95 return ( Msg | Work);
96 } 96 }
97 return Work; 97 return Work;
98 } 98 }
99 if ((type & Pcs) == Pcs) { 99 if ((type & Pcs) == Pcs) {
100 if ((type & Pref) == Pref) 100 if ((type & Pref) == Pref)
101 return Pcs | Pref; 101 return Pcs | Pref;
102 if ((type & Voice) == Voice)
103 return Pcs | Voice;
102 return Pcs; 104 return Pcs;
103 } 105 }
104 if ((type & Car) == Car) 106 if ((type & Car) == Car)
105 return Car; 107 return Car;
106 if ((type & Pager) == Pager) 108 if ((type & Pager) == Pager)
107 return Pager; 109 return Pager;
108 if ((type & Isdn) == Isdn) 110 if ((type & Isdn) == Isdn)
109 return Isdn; 111 return Isdn;
112#if 0
110 if ((type & Video) == Video) 113 if ((type & Video) == Video)
111 return Video; 114 return Video;
112 115#endif
113 if ((type & Msg) == Msg) 116 if ((type & Msg) == Msg)
114 return Msg; 117 return Msg;
115 if ((type & Fax) == Fax) 118 if ((type & Fax) == Fax)
116 return Fax; 119 return Fax;
117 120
118 if ((type & Pref) == Pref) 121 if ((type & Pref) == Pref)
119 return Pref; 122 return Pref;
120 123
121 return Voice; 124 return Voice;
122 125
123} 126}
124bool PhoneNumber::simplifyNumber() 127bool PhoneNumber::simplifyNumber()
125{ 128{
126 QString Number; 129 QString Number;
127 int i; 130 int i;
128 Number = mNumber.stripWhiteSpace (); 131 Number = mNumber.stripWhiteSpace ();
129 mNumber = ""; 132 mNumber = "";
130 for ( i = 0; i < Number.length(); ++i) { 133 for ( i = 0; i < Number.length(); ++i) {
131 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
132 mNumber += Number.at(i); 135 mNumber += Number.at(i);
133 } 136 }
134 return ( mNumber.length() > 0 ); 137 return ( mNumber.length() > 0 );
135} 138}
136// make cellphone compatible 139// make cellphone compatible
137void PhoneNumber::simplifyType() 140void PhoneNumber::simplifyType()
138{ 141{
139 if ( mType & Fax ) mType = Fax; 142 if ( mType & Fax ) mType = Fax;
140 else if ( mType & Cell ) mType = Cell; 143 else if ( mType & Cell ) mType = Cell;
141 else if ( mType & Work ) mType = Work ; 144 else if ( mType & Work ) mType = Work ;
142 else if ( mType & Home ) mType = Home; 145 else if ( mType & Home ) mType = Home;
143 else mType = Pref; 146 else mType = Pref;
144} 147}
145bool PhoneNumber::contains( const PhoneNumber &p ) 148bool PhoneNumber::contains( const PhoneNumber &p )
146{ 149{
147 PhoneNumber myself; 150 PhoneNumber myself;
148 PhoneNumber other; 151 PhoneNumber other;
149 myself = *this; 152 myself = *this;
150 other = p; 153 other = p;
151 myself.simplifyNumber(); 154 myself.simplifyNumber();
152 other.simplifyNumber(); 155 other.simplifyNumber();
153 if ( myself.number() != other.number ()) 156 if ( myself.number() != other.number ())
154 return false; 157 return false;
155 myself.simplifyType(); 158 myself.simplifyType();
156 other.simplifyType(); 159 other.simplifyType();
157 if ( myself.type() == other.type()) 160 if ( myself.type() == other.type())
158 return true; 161 return true;
159 return false; 162 return false;
160} 163}
161 164
162void PhoneNumber::setId( const QString &id ) 165void PhoneNumber::setId( const QString &id )
163{ 166{
164 mId = id; 167 mId = id;
165} 168}
166 169
167QString PhoneNumber::id() const 170QString PhoneNumber::id() const
168{ 171{
169 return mId; 172 return mId;
170} 173}
171 174
172void PhoneNumber::setNumber( const QString &number ) 175void PhoneNumber::setNumber( const QString &number )
173{ 176{
174 mNumber = number; 177 mNumber = number;
175} 178}
176 179
177QString PhoneNumber::number() const 180QString PhoneNumber::number() const
178{ 181{
179 return mNumber; 182 return mNumber;
180} 183}
181 184
182void PhoneNumber::setType( int type ) 185void PhoneNumber::setType( int type )
183{ 186{
184 mType = type; 187 mType = type;
185} 188}
186 189
187int PhoneNumber::type() const 190int PhoneNumber::type() const
188{ 191{
189 return mType; 192 return mType;
190} 193}
191 194
192QString PhoneNumber::typeLabel() const 195QString PhoneNumber::typeLabel() const
193{ 196{
194 QString label; 197 QString label;
195 bool first = true; 198 bool first = true;
196 199
197 TypeList list = typeList(); 200 TypeList list = typeList();
198 201
199 TypeList::Iterator it; 202 TypeList::Iterator it;
200 for ( it = list.begin(); it != list.end(); ++it ) { 203 for ( it = list.begin(); it != list.end(); ++it ) {
201 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
202 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
203 if ( first ) 206 if ( first )
204 first = false; 207 first = false;
205 } 208 }
206 } 209 }
207 210
208 return label; 211 return label;
209} 212}
210 213
211QString PhoneNumber::label() const 214QString PhoneNumber::label() const
212{ 215{
213 return typeLabel( type() ); 216 return typeLabel( type() );
214} 217}
215 218
216PhoneNumber::TypeList PhoneNumber::typeList() 219PhoneNumber::TypeList PhoneNumber::typeList()
217{ 220{
218 TypeList list; 221 TypeList list;
219 222
220 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
221 << Bbs << Modem << Car << Isdn << Pcs << Pager; 224 << Bbs << Modem << Car << Isdn << Pcs << Pager;
222 225
223 return list; 226 return list;
224} 227}
225PhoneNumber::TypeList PhoneNumber::supportedTypeList() 228PhoneNumber::TypeList PhoneNumber::supportedTypeList()
226{ 229{
227 static TypeList list; 230 static TypeList list;
228 if ( list.count() == 0 ) 231 if ( list.count() == 0 )
229 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< Pcs<< Home << Work << Car << (Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Video << Msg << Pref << Voice; 232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
230 return list; 233 return list;
231} 234}
232QStringList PhoneNumber::supportedTypeListNames() 235QStringList PhoneNumber::supportedTypeListNames()
233{ 236{
234 static QStringList list; 237 static QStringList list;
235 if ( list.count() == 0 ) 238 if ( list.count() == 0 )
236 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SIP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Video") << i18n("Callback") << i18n("Primary")<< i18n("Other"); 239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SIP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SIP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other");
237 return list; 240 return list;
238} 241}
239 242
240int PhoneNumber::typeListIndex4Type(int type ) 243int PhoneNumber::typeListIndex4Type(int type )
241{ 244{
242 TypeList list = supportedTypeList(); 245 TypeList list = supportedTypeList();
243 int i = 0; 246 int i = 0;
244 while ( i < list.count() ) { 247 while ( i < list.count() ) {
245 if ( list [i] == type ) 248 if ( list [i] == type )
246 return i; 249 return i;
247 ++i; 250 ++i;
248 } 251 }
249 return list.count()-1; 252 return list.count()-1;
250} 253}
251 254
252QString PhoneNumber::label( int type ) 255QString PhoneNumber::label( int type )
253{ 256{
254 return typeLabel( type ); 257 return typeLabel( type );
255} 258}
256 259
257QString PhoneNumber::typeLabel( int type ) 260QString PhoneNumber::typeLabel( int type )
258{ 261{
259 if ((type & Cell) == Cell) 262 if ((type & Cell) == Cell)
260 return i18n("Mobile"); 263 return i18n("Mobile");
261 if ((type & Home) == Home) { 264 if ((type & Home) == Home) {
262 if ((type & Pref) == Pref) 265 if ((type & Pref) == Pref)
263 return i18n("Home"); 266 return i18n("Home");
264 if ((type & Fax) == Fax) 267 if ((type & Fax) == Fax)
265 return i18n("Fax (Home)"); 268 return i18n("Fax (Home)");
266 return i18n("Home2"); 269 return i18n("Home2");
267 } 270 }
268 271
269 if ((type & Work) == Work) { 272 if ((type & Work) == Work) {
270 if ((type & Pref) == Pref) 273 if ((type & Pref) == Pref)
271 return i18n("Work"); 274 return i18n("Work");
272 if ((type & Fax) == Fax) 275 if ((type & Fax) == Fax)
273 return i18n("Fax (Work)"); 276 return i18n("Fax (Work)");
274 if ((type & Msg) == Msg) { 277 if ((type & Msg) == Msg) {
275 if ((type & Voice) == Voice) 278 if ((type & Voice) == Voice)
276 return i18n("Assistent"); 279 return i18n("Assistent");
277 return i18n("Company"); 280 return i18n("Company");
278 } 281 }
279 return i18n("Work2"); 282 return i18n("Work2");
280 } 283 }
281 if ((type & Pcs) == Pcs) { 284 if ((type & Pcs) == Pcs) {
282 if ((type & Pref) == Pref) 285 if ((type & Pref) == Pref)
283 return i18n("SIP"); 286 return i18n("SiP");
284 return i18n("VoIP"); 287 if ((type & Voice) == Voice)
288 return i18n("VoIP");
289 return i18n("SiP2");
285 } 290 }
286 if ((type & Car) == Car) 291 if ((type & Car) == Car)
287 return i18n("Mobile2"); 292 return i18n("Mobile2");
288 if ((type & Pager) == Pager) 293 if ((type & Pager) == Pager)
289 return i18n("Pager"); 294 return i18n("Pager");
290 if ((type & Isdn) == Isdn) 295 if ((type & Isdn) == Isdn)
291 return i18n("ISDN"); 296 return i18n("ISDN");
292 if ((type & Video) == Video) 297 if ((type & Video) == Video)
293 return i18n("Video"); 298 return i18n("Video");
294 299
295 if ((type & Msg) == Msg) 300 if ((type & Msg) == Msg)
296 return i18n("Callback"); 301 return i18n("Callback");
297 if ((type & Fax) == Fax) 302 if ((type & Fax) == Fax)
298 return i18n("Fax (Other)"); 303 return i18n("Fax (Other)");
299 304
300 if ((type & Pref) == Pref) 305 if ((type & Pref) == Pref)
301 return i18n("Primary"); 306 return i18n("Primary");
302 307
303 308
304 return i18n("Other"); 309 return i18n("Other");
305 310
306 311
307#if 0 312#if 0
308 313
309 314
310 315
311 QString typeString; 316 QString typeString;
312 317
313 318
314 if ((type & Cell) == Cell) 319 if ((type & Cell) == Cell)
315 typeString += i18n("Mobile") +" "; 320 typeString += i18n("Mobile") +" ";
316 if ((type & Home) == Home) 321 if ((type & Home) == Home)
317 typeString += i18n("Home")+" "; 322 typeString += i18n("Home")+" ";
318 else if ((type & Work) == Work) 323 else if ((type & Work) == Work)
319 typeString += i18n("Work")+" "; 324 typeString += i18n("Work")+" ";
320 325
321 if ((type & Sip) == Sip) 326 if ((type & Sip) == Sip)
322 typeString += i18n("SIP")+" "; 327 typeString += i18n("SIP")+" ";
323 if ((type & Car) == Car) 328 if ((type & Car) == Car)
324 typeString += i18n("Car")+" "; 329 typeString += i18n("Car")+" ";
325 330
326 if ((type & Fax) == Fax) 331 if ((type & Fax) == Fax)
327 typeString += i18n("Fax"); 332 typeString += i18n("Fax");
328 else if ((type & Msg) == Msg) 333 else if ((type & Msg) == Msg)
329 typeString += i18n("Messenger"); 334 typeString += i18n("Messenger");
330 else if ((type & Video) == Video) 335 else if ((type & Video) == Video)
331 typeString += i18n("Video"); 336 typeString += i18n("Video");
332 else if ((type & Bbs) == Bbs) 337 else if ((type & Bbs) == Bbs)
333 typeString += i18n("Mailbox"); 338 typeString += i18n("Mailbox");
334 else if ((type & Modem) == Modem) 339 else if ((type & Modem) == Modem)
335 typeString += i18n("Modem"); 340 typeString += i18n("Modem");
336 else if ((type & Isdn) == Isdn) 341 else if ((type & Isdn) == Isdn)
337 typeString += i18n("ISDN"); 342 typeString += i18n("ISDN");
338 else if ((type & Pcs) == Pcs) 343 else if ((type & Pcs) == Pcs)
339 typeString += i18n("PCS"); 344 typeString += i18n("PCS");
340 else if ((type & Pager) == Pager) 345 else if ((type & Pager) == Pager)
341 typeString += i18n("Pager"); 346 typeString += i18n("Pager");
342 // add the prefered flag 347 // add the prefered flag
343 /* 348 /*
344 if ((type & Pref) == Pref) 349 if ((type & Pref) == Pref)
345 typeString += i18n("(p)"); 350 typeString += i18n("(p)");
346 */ 351 */
347 //if we still have no match, return "other" 352 //if we still have no match, return "other"
348 if (typeString.isEmpty()) { 353 if (typeString.isEmpty()) {
349 if ((type & Voice) == Voice) 354 if ((type & Voice) == Voice)
350 return i18n("Voice"); 355 return i18n("Voice");
351 else 356 else
352 return i18n("Other"); 357 return i18n("Other");
353 } 358 }
354 359
355 return typeString.stripWhiteSpace(); 360 return typeString.stripWhiteSpace();
356#endif 361#endif
357} 362}
358 363
359QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 364QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
360{ 365{
361 return s << phone.mId << phone.mType << phone.mNumber; 366 return s << phone.mId << phone.mType << phone.mNumber;
362} 367}
363 368
364QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 369QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
365{ 370{
366 s >> phone.mId >> phone.mType >> phone.mNumber; 371 s >> phone.mId >> phone.mType >> phone.mNumber;
367 372
368 return s; 373 return s;
369} 374}
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index aa61fb8..f134d5b 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,734 +1,734 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "simplealarmdaemonimpl.h" 24#include "simplealarmdaemonimpl.h"
25 25
26#include "alarmdialog.h" 26#include "alarmdialog.h"
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qhbox.h> 31#include <qhbox.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qdialog.h> 38#include <qdialog.h>
39#define protected public 39#define protected public
40#include <qspinbox.h> 40#include <qspinbox.h>
41#undef protected 41#undef protected
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qtopia/qcopenvelope_qws.h> 43#include <qtopia/qcopenvelope_qws.h>
44#include <qtopia/alarmserver.h> 44#include <qtopia/alarmserver.h>
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
52 : QLabel( parent ) 52 : QLabel( parent )
53{ 53{
54 mAlarmDialog = new AlarmDialog( 0 ); 54 mAlarmDialog = new AlarmDialog( 0 );
55 mPopUp = new QPopupMenu( this ); 55 mPopUp = new QPopupMenu( this );
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
58 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); 59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) );
60 mPopUp->insertSeparator(); 60 mPopUp->insertSeparator();
61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); 61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
62 mPopUp->insertSeparator(); 62 mPopUp->insertSeparator();
63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); 66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
67 mPopUp->insertSeparator(); 67 mPopUp->insertSeparator();
68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); 68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
69 mTimerPopUp = new QPopupMenu( this ); 69 mTimerPopUp = new QPopupMenu( this );
70 70
71 mBeepPopUp = new QPopupMenu( this ); 71 mBeepPopUp = new QPopupMenu( this );
72 mSoundPopUp = new QPopupMenu( this ); 72 mSoundPopUp = new QPopupMenu( this );
73 mPausePopUp = new QPopupMenu( this ); 73 mPausePopUp = new QPopupMenu( this );
74 mFontsizePopup = new QPopupMenu( this ); 74 mFontsizePopup = new QPopupMenu( this );
75 mFontsizePopup->insertItem( "10", 10 ); 75 mFontsizePopup->insertItem( "10", 10 );
76 mFontsizePopup->insertItem( "12", 12 ); 76 mFontsizePopup->insertItem( "12", 12 );
77 mFontsizePopup->insertItem( "14", 14 ); 77 mFontsizePopup->insertItem( "14", 14 );
78 mFontsizePopup->insertItem( "16", 16 ); 78 mFontsizePopup->insertItem( "16", 16 );
79 mFontsizePopup->insertItem( "18", 18 ); 79 mFontsizePopup->insertItem( "18", 18 );
80 mFontsizePopup->insertItem( "20", 20 ); 80 mFontsizePopup->insertItem( "20", 20 );
81 mFontsizePopup->insertItem( "22", 22 ); 81 mFontsizePopup->insertItem( "22", 22 );
82 mFontsizePopup->insertItem( "24", 24 ); 82 mFontsizePopup->insertItem( "24", 24 );
83 mFontsizePopup->insertItem( "26", 26 ); 83 mFontsizePopup->insertItem( "26", 26 );
84 mFontsizePopup->insertItem( "28", 28 ); 84 mFontsizePopup->insertItem( "28", 28 );
85 mFontsizePopup->insertItem( "30", 30 ); 85 mFontsizePopup->insertItem( "30", 30 );
86 mFontsizePopup->insertItem( "32", 32 ); 86 mFontsizePopup->insertItem( "32", 32 );
87 mFontsizePopup->insertItem( "36", 36 ); 87 mFontsizePopup->insertItem( "36", 36 );
88 QPopupMenu* savePopUp = new QPopupMenu( this ); 88 QPopupMenu* savePopUp = new QPopupMenu( this );
89 savePopUp->insertItem( "Save", 0 ); 89 savePopUp->insertItem( "Save", 0 );
90 savePopUp->insertItem( "Load", 1 ); 90 savePopUp->insertItem( "Load", 1 );
91 mSoundPopUp->insertItem( "Buzzer", 0 ); 91 mSoundPopUp->insertItem( "Buzzer", 0 );
92 mSoundPopUp->insertItem( "Wav file", 1 ); 92 mSoundPopUp->insertItem( "Wav file", 1 );
93 mPausePopUp->insertItem( " 1 sec", 1 ); 93 mPausePopUp->insertItem( " 1 sec", 1 );
94 mPausePopUp->insertItem( " 2 sec", 2 ); 94 mPausePopUp->insertItem( " 2 sec", 2 );
95 mPausePopUp->insertItem( " 3 sec", 3 ); 95 mPausePopUp->insertItem( " 3 sec", 3 );
96 mPausePopUp->insertItem( " 5 sec", 5 ); 96 mPausePopUp->insertItem( " 5 sec", 5 );
97 mPausePopUp->insertItem( "10 sec", 10 ); 97 mPausePopUp->insertItem( "10 sec", 10 );
98 mPausePopUp->insertItem( "30 sec", 30 ); 98 mPausePopUp->insertItem( "30 sec", 30 );
99 mPausePopUp->insertItem( " 1 min", 60 ); 99 mPausePopUp->insertItem( " 1 min", 60 );
100 mPausePopUp->insertItem( " 5 min", 300 ); 100 mPausePopUp->insertItem( " 5 min", 300 );
101 mPausePopUp->insertItem( "10 min", 600 ); 101 mPausePopUp->insertItem( "10 min", 600 );
102 mSuspendPopUp = new QPopupMenu( this ); 102 mSuspendPopUp = new QPopupMenu( this );
103 mSuspendPopUp->insertItem( "Off", 0 ); 103 mSuspendPopUp->insertItem( "Off", 0 );
104 mSuspendPopUp->insertItem( " 1x", 1 ); 104 mSuspendPopUp->insertItem( " 1x", 1 );
105 mSuspendPopUp->insertItem( " 2x", 2 ); 105 mSuspendPopUp->insertItem( " 2x", 2 );
106 mSuspendPopUp->insertItem( " 3x", 3 ); 106 mSuspendPopUp->insertItem( " 3x", 3 );
107 mSuspendPopUp->insertItem( " 5x", 5 ); 107 mSuspendPopUp->insertItem( " 5x", 5 );
108 mSuspendPopUp->insertItem( "10x", 10 ); 108 mSuspendPopUp->insertItem( "10x", 10 );
109 mSuspendPopUp->insertItem( "20x", 20 ); 109 mSuspendPopUp->insertItem( "20x", 20 );
110 mSuspendPopUp->insertItem( "30x", 30 ); 110 mSuspendPopUp->insertItem( "30x", 30 );
111 mBeepPopUp->insertItem( "Config",savePopUp ); 111 mBeepPopUp->insertItem( "Config",savePopUp );
112 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 112 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
113 mBeepPopUp->insertItem( "Font Size",mFontsizePopup ); 113 mBeepPopUp->insertItem( "Font Size",mFontsizePopup );
114 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 114 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
115 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 115 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
116 mBeepPopUp->insertItem( "180", 180 ); 116 mBeepPopUp->insertItem( "180", 180 );
117 mBeepPopUp->insertItem( "60", 60 ); 117 mBeepPopUp->insertItem( "60", 60 );
118 mBeepPopUp->insertItem( "30", 30 ); 118 mBeepPopUp->insertItem( "30", 30 );
119 mBeepPopUp->insertItem( "18", 18 ); 119 mBeepPopUp->insertItem( "18", 18 );
120 mBeepPopUp->insertItem( "10", 10 ); 120 mBeepPopUp->insertItem( "10", 10 );
121 mBeepPopUp->insertItem( "3", 3 ); 121 mBeepPopUp->insertItem( "3", 3 );
122 mBeepPopUp->insertItem( "1", 1 ); 122 mBeepPopUp->insertItem( "1", 1 );
123 mBeepPopUp->insertItem( "Off", 0 ); 123 mBeepPopUp->insertItem( "Off", 0 );
124 mBeepPopUp->insertSeparator(); 124 mBeepPopUp->insertSeparator();
125 mBeepPopUp->insertItem( "Simulate", 1000 ); 125 mBeepPopUp->insertItem( "Simulate", 1000 );
126 mBeepPopUp->setCheckable( true ); 126 mBeepPopUp->setCheckable( true );
127 mPopUp->insertSeparator(); 127 mPopUp->insertSeparator();
128 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 128 mPopUp->insertItem( "Play beeps", mBeepPopUp );
129 mPopUp->insertSeparator(); 129 mPopUp->insertSeparator();
130 mPopUp->insertItem( "Timer", mTimerPopUp ); 130 mPopUp->insertItem( "Timer", mTimerPopUp );
131 //mPopUp->insertSeparator(); 131 //mPopUp->insertSeparator();
132 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 132 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
133 133
134 mPopUp->resize( mPopUp->sizeHint() ); 134 mPopUp->resize( mPopUp->sizeHint() );
135 mPlayBeeps = 60; 135 mPlayBeeps = 60;
136 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 136 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
137 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 137 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
138 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 138 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
139 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 139 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
140 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 140 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
141 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 141 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
142 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 142 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
143 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 143 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
144 connect ( mFontsizePopup, SIGNAL( activated ( int ) ), this, SLOT (confFontSize( int ) ) ); 144 connect ( mFontsizePopup, SIGNAL( activated ( int ) ), this, SLOT (confFontSize( int ) ) );
145 mTimerTime = 0; 145 mTimerTime = 0;
146 mCustomText = "Custom Text"; 146 mCustomText = "Custom Text";
147 mCustomMinutes = 7; 147 mCustomMinutes = 7;
148 mTimerPopupConf = 1; 148 mTimerPopupConf = 1;
149 fillTimerPopUp(); 149 fillTimerPopUp();
150 mPausePlay = 0; 150 mPausePlay = 0;
151 confPause( 1 ); 151 confPause( 1 );
152 mSuspend = 0; 152 mSuspend = 0;
153 confSuspend( 0 ); 153 confSuspend( 0 );
154 if ( QApplication::desktop()->width() < 480 ) { 154 if ( QApplication::desktop()->width() < 480 ) {
155 wavAlarm = false; 155 wavAlarm = false;
156 mSoundPopUp->setItemChecked ( 0, true ); 156 mSoundPopUp->setItemChecked ( 0, true );
157 } 157 }
158 else { 158 else {
159 wavAlarm = true; 159 wavAlarm = true;
160 mSoundPopUp->setItemChecked ( 1, true ); 160 mSoundPopUp->setItemChecked ( 1, true );
161 } 161 }
162 mTimerStartLabel = new QLabel( 0, 0, WType_Popup ); 162 mTimerStartLabel = new QLabel( 0, 0, WType_Popup );
163 //mTimerStartLabel->setCaption( "Timer started!"); 163 //mTimerStartLabel->setCaption( "Timer started!");
164 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ; 164 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ;
165 saveSlot( 1 ); 165 saveSlot( 1 );
166 166
167 167
168 168
169} 169}
170 170
171SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 171SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
172{ 172{
173 //delete mPopUp; 173 //delete mPopUp;
174 delete mAlarmDialog; 174 delete mAlarmDialog;
175 delete mTimerStartLabel; 175 delete mTimerStartLabel;
176} 176}
177 177
178void SimpleAlarmDaemonImpl::saveSlot( int load ) 178void SimpleAlarmDaemonImpl::saveSlot( int load )
179{ 179{
180 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 180 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
181 //qDebug("save %d ", load ); 181 //qDebug("save %d ", load );
182 QFile file( fileName ); 182 QFile file( fileName );
183 if ( load ) { 183 if ( load ) {
184 mPopupFontSize = mTimerPopUp->font().pointSize(); 184 mPopupFontSize = mTimerPopUp->font().pointSize();
185 confFontSize( mPopupFontSize ); 185 confFontSize( mPopupFontSize );
186 if( !QFile::exists( fileName) ) 186 if( !QFile::exists( fileName) )
187 return; 187 return;
188 if (!file.open( IO_ReadOnly ) ) { 188 if (!file.open( IO_ReadOnly ) ) {
189 return ; 189 return ;
190 } 190 }
191 QString line; 191 QString line;
192 bool ok; 192 bool ok;
193 int val; 193 int val;
194 int len; 194 int len;
195 while ( file.readLine( line, 1024 ) > 0 ) { 195 while ( file.readLine( line, 1024 ) > 0 ) {
196 //qDebug("read %s ", line.latin1()); 196 //qDebug("read %s ", line.latin1());
197 len = line.length(); 197 len = line.length();
198 if ( line.left(4 ) == "PPAU" ) { 198 if ( line.left(4 ) == "PPAU" ) {
199 val = line.mid( 4,len-5).toInt( &ok ); 199 val = line.mid( 4,len-5).toInt( &ok );
200 if ( ok ) { 200 if ( ok ) {
201 confPause( val ); 201 confPause( val );
202 } 202 }
203 } 203 }
204 if ( line.left(4 ) == "POFO" ) { 204 if ( line.left(4 ) == "POFO" ) {
205 val = line.mid( 4,len-5).toInt( &ok ); 205 val = line.mid( 4,len-5).toInt( &ok );
206 if ( ok ) { 206 if ( ok ) {
207 confFontSize( val ); 207 confFontSize( val );
208 } 208 }
209 } 209 }
210 if ( line.left(4 ) == "SUCO" ) { 210 if ( line.left(4 ) == "SUCO" ) {
211 val = line.mid( 4,len-5).toInt( &ok ); 211 val = line.mid( 4,len-5).toInt( &ok );
212 if ( ok ) 212 if ( ok )
213 confSuspend ( val ); 213 confSuspend ( val );
214 } 214 }
215 if ( line.left(4 ) == "WAAL" ) { 215 if ( line.left(4 ) == "WAAL" ) {
216 val = line.mid( 4,len-5).toInt( &ok ); 216 val = line.mid( 4,len-5).toInt( &ok );
217 if ( ok ) 217 if ( ok )
218 confSound( val ); 218 confSound( val );
219 219
220 } 220 }
221 if ( line.left(4 ) == "PLBE" ) { 221 if ( line.left(4 ) == "PLBE" ) {
222 val = line.mid( 4,len-5).toInt( &ok ); 222 val = line.mid( 4,len-5).toInt( &ok );
223 if ( ok ) 223 if ( ok )
224 slotPlayBeep( val ); 224 slotPlayBeep( val );
225 225
226 } 226 }
227 if ( line.left(4 ) == "CUTE" ) { 227 if ( line.left(4 ) == "CUTE" ) {
228 mCustomText = line.mid( 5,len-6); 228 mCustomText = line.mid( 5,len-6);
229 // qDebug("text ***%s*** ",mCustomText.latin1() ); 229 // qDebug("text ***%s*** ",mCustomText.latin1() );
230 230
231 } 231 }
232 if ( line.left(4 ) == "CUMI" ) { 232 if ( line.left(4 ) == "CUMI" ) {
233 val = line.mid( 4,len-5).toInt( &ok ); 233 val = line.mid( 4,len-5).toInt( &ok );
234 if ( ok ) 234 if ( ok )
235 mCustomMinutes = val; 235 mCustomMinutes = val;
236 236
237 } 237 }
238 if ( line.left(4 ) == "SUTI" ) { 238 if ( line.left(4 ) == "SUTI" ) {
239 val = line.mid( 4,len-5).toInt( &ok ); 239 val = line.mid( 4,len-5).toInt( &ok );
240 if ( ok ) 240 if ( ok )
241 mAlarmDialog->setSuspendTime( val );; 241 mAlarmDialog->setSuspendTime( val );;
242 242
243 } 243 }
244 } 244 }
245 file.close(); 245 file.close();
246 } else { 246 } else {
247 if (!file.open( IO_WriteOnly ) ) { 247 if (!file.open( IO_WriteOnly ) ) {
248 return; 248 return;
249 } 249 }
250 QString configString ; 250 QString configString ;
251 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 251 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
252 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 252 configString += "SUCO " + QString::number( mSuspend ) + "\n";
253 configString += "POFO " + QString::number( mPopupFontSize ) + "\n"; 253 configString += "POFO " + QString::number( mPopupFontSize ) + "\n";
254 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 254 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
255 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 255 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
256 configString += "CUTE " + mCustomText + "\n"; 256 configString += "CUTE " + mCustomText + "\n";
257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
259 QTextStream ts( &file ); 259 QTextStream ts( &file );
260 ts << configString ; 260 ts << configString ;
261 file.close(); 261 file.close();
262 } 262 }
263 263
264} 264}
265void SimpleAlarmDaemonImpl::confSuspend( int num ) 265void SimpleAlarmDaemonImpl::confSuspend( int num )
266{ 266{
267 mSuspendPopUp->setItemChecked ( mSuspend,false ); 267 mSuspendPopUp->setItemChecked ( mSuspend,false );
268 mSuspend = num; 268 mSuspend = num;
269 mSuspendPopUp->setItemChecked ( mSuspend,true ); 269 mSuspendPopUp->setItemChecked ( mSuspend,true );
270} 270}
271void SimpleAlarmDaemonImpl::confPause( int num ) 271void SimpleAlarmDaemonImpl::confPause( int num )
272{ 272{
273 mPausePopUp->setItemChecked ( mPausePlay,false ); 273 mPausePopUp->setItemChecked ( mPausePlay,false );
274 mPausePlay = num; 274 mPausePlay = num;
275 mPausePopUp->setItemChecked ( mPausePlay,true ); 275 mPausePopUp->setItemChecked ( mPausePlay,true );
276} 276}
277void SimpleAlarmDaemonImpl::confSound( int num ) 277void SimpleAlarmDaemonImpl::confSound( int num )
278{ 278{
279 if ( num == 0 ) { 279 if ( num == 0 ) {
280 wavAlarm = false; 280 wavAlarm = false;
281 mSoundPopUp->setItemChecked ( 0, true ); 281 mSoundPopUp->setItemChecked ( 0, true );
282 mSoundPopUp->setItemChecked ( 1, false ); 282 mSoundPopUp->setItemChecked ( 1, false );
283 } else { 283 } else {
284 wavAlarm = true; 284 wavAlarm = true;
285 mSoundPopUp->setItemChecked ( 0, false ); 285 mSoundPopUp->setItemChecked ( 0, false );
286 mSoundPopUp->setItemChecked ( 1, true ); 286 mSoundPopUp->setItemChecked ( 1, true );
287 } 287 }
288} 288}
289void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 289void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
290{ 290{
291 if ( num == 1000 ) { 291 if ( num == 1000 ) {
292 simulate(); 292 simulate();
293 return; 293 return;
294 } 294 }
295 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 295 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
296 mPlayBeeps = num; 296 mPlayBeeps = num;
297 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 297 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
298} 298}
299 299
300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
301{ 301{
302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
303 QString mess = QString::fromUtf8(msg.data()); 303 QString mess = QString::fromUtf8(msg.data());
304 mAlarmMessage = mess.mid( 9 ); 304 mAlarmMessage = mess.mid( 9 );
305 QString filename = getenv("QPEDIR") ; 305 QString filename = getenv("QPEDIR") ;
306 filename += "/pics/kdepim/korganizer/koalarm.wav"; 306 filename += "/pics/kdepim/korganizer/koalarm.wav";
307 QString tempfilename; 307 QString tempfilename;
308 if ( mess.left( 13 ) == "suspend_alarm") { 308 if ( mess.left( 13 ) == "suspend_alarm") {
309 bool error = false; 309 bool error = false;
310 int len = mess.mid( 13 ).find("+++"); 310 int len = mess.mid( 13 ).find("+++");
311 if ( len < 2 ) 311 if ( len < 2 )
312 error = true; 312 error = true;
313 else { 313 else {
314 tempfilename = mess.mid( 13, len ); 314 tempfilename = mess.mid( 13, len );
315 if ( !QFile::exists( tempfilename ) ) 315 if ( !QFile::exists( tempfilename ) )
316 error = true; 316 error = true;
317 } 317 }
318 if ( ! error ) { 318 if ( ! error ) {
319 filename = tempfilename; 319 filename = tempfilename;
320 } 320 }
321 mAlarmMessage = mess.mid( 13+len+3 ); 321 mAlarmMessage = mess.mid( 13+len+3 );
322 //qDebug("suspend file %s ",tempfilename.latin1() ); 322 //qDebug("suspend file %s ",tempfilename.latin1() );
323 startAlarm( mAlarmMessage, filename); 323 startAlarm( mAlarmMessage, filename);
324 return; 324 return;
325 } 325 }
326 if ( mess.left( 11 ) == "timer_alarm") { 326 if ( mess.left( 11 ) == "timer_alarm") {
327 mTimerTime = 0; 327 mTimerTime = 0;
328 startAlarm( mess.mid( 11 ), filename ); 328 startAlarm( mess.mid( 11 ), filename );
329 return; 329 return;
330 } 330 }
331 if ( mess.left( 10 ) == "proc_alarm") { 331 if ( mess.left( 10 ) == "proc_alarm") {
332 bool error = false; 332 bool error = false;
333 int len = mess.mid( 10 ).find("+++"); 333 int len = mess.mid( 10 ).find("+++");
334 if ( len < 2 ) 334 if ( len < 2 )
335 error = true; 335 error = true;
336 else { 336 else {
337 tempfilename = mess.mid( 10, len ); 337 tempfilename = mess.mid( 10, len );
338 if ( !QFile::exists( tempfilename ) ) 338 if ( !QFile::exists( tempfilename ) )
339 error = true; 339 error = true;
340 } 340 }
341 if ( error ) { 341 if ( error ) {
342 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 342 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
343 mAlarmMessage += mess.mid( 10+len+3+9 ); 343 mAlarmMessage += mess.mid( 10+len+3+9 );
344 } else { 344 } else {
345 //qDebug("-----system command %s ",tempfilename.latin1() ); 345 //qDebug("-----system command %s ",tempfilename.latin1() );
346 if ( vfork () == 0 ) { 346 if ( vfork () == 0 ) {
347 execl ( tempfilename.latin1(), 0 ); 347 execl ( tempfilename.latin1(), 0 );
348 return; 348 return;
349 } 349 }
350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
351 return; 351 return;
352 } 352 }
353 353
354 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 354 //qDebug("+++++++system command %s ",tempfilename.latin1() );
355 } 355 }
356 if ( mess.left( 11 ) == "audio_alarm") { 356 if ( mess.left( 11 ) == "audio_alarm") {
357 bool error = false; 357 bool error = false;
358 int len = mess.mid( 11 ).find("+++"); 358 int len = mess.mid( 11 ).find("+++");
359 if ( len < 2 ) 359 if ( len < 2 )
360 error = true; 360 error = true;
361 else { 361 else {
362 tempfilename = mess.mid( 11, len ); 362 tempfilename = mess.mid( 11, len );
363 if ( !QFile::exists( tempfilename ) ) 363 if ( !QFile::exists( tempfilename ) )
364 error = true; 364 error = true;
365 } 365 }
366 if ( ! error ) { 366 if ( ! error ) {
367 filename = tempfilename; 367 filename = tempfilename;
368 } 368 }
369 mAlarmMessage = mess.mid( 11+len+3+9 ); 369 mAlarmMessage = mess.mid( 11+len+3+9 );
370 //qDebug("audio file command %s ",tempfilename.latin1() ); 370 //qDebug("audio file command %s ",tempfilename.latin1() );
371 } 371 }
372 if ( mess.left( 9 ) == "cal_alarm") { 372 if ( mess.left( 9 ) == "cal_alarm") {
373 mAlarmMessage = mess.mid( 9 ) ; 373 mAlarmMessage = mess.mid( 9 ) ;
374 } 374 }
375 375
376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
377 startAlarm( mAlarmMessage, filename ); 377 startAlarm( mAlarmMessage, filename );
378 378
379} 379}
380 380
381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
382{ 382{
383 return 0; 383 return 0;
384} 384}
385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
386{ 386{
387 //mAlarmDialog->show(); 387 //mAlarmDialog->show();
388 //mAlarmDialog->raise(); 388 //mAlarmDialog->raise();
389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
390} 390}
391 391
392 392
393void SimpleAlarmDaemonImpl::fillTimerPopUp() 393void SimpleAlarmDaemonImpl::fillTimerPopUp()
394{ 394{
395 395
396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
397 if ( mTimerPopupConf == mTimerTime ) { 397 if ( mTimerPopupConf == mTimerTime ) {
398 if ( mTimerTime ) { 398 if ( mTimerTime ) {
399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
400 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 400 QTime t ( secs/3600, (secs/60)%60, secs%60 );
401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
402 } 402 }
403 else { 403 else {
404 QString text = mCustomText.stripWhiteSpace (); 404 QString text = mCustomText.stripWhiteSpace ();
405 int in = text.find( " " ); 405 int in = text.find( " " );
406 text = text.left ( in ); 406 text = text.left ( in );
407 mTimerPopUp->changeItem ( 3, text ); 407 mTimerPopUp->changeItem ( 3, text );
408 } 408 }
409 return; 409 return;
410 } 410 }
411 mTimerPopupConf = mTimerTime; 411 mTimerPopupConf = mTimerTime;
412 mTimerPopUp->clear(); 412 mTimerPopUp->clear();
413 if ( mTimerTime ) { 413 if ( mTimerTime ) {
414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
415 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 415 QTime t ( secs/3600, (secs/60)%60, secs%60 );
416 416
417 417
418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
421 } else { 421 } else {
422 422
423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
424 QFile file( fileName ); 424 QFile file( fileName );
425 if( !QFile::exists( fileName) ) { 425 if( !QFile::exists( fileName) ) {
426 // write defaults 426 // write defaults
427 if (!file.open( IO_WriteOnly ) ) { 427 if (!file.open( IO_WriteOnly ) ) {
428 return; 428 return;
429 } 429 }
430 QString configString ; 430 QString configString ;
431 configString += "#config file for kopi alarm timer\n"; 431 configString += "#config file for kopi alarm timer\n";
432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
433 configString += "24 hours; 1440\n"; 433 configString += "24 hours; 1440\n";
434 configString += "9 hours; 540\n"; 434 configString += "9 hours; 540\n";
435 configString += "8 hours; 480\n"; 435 configString += "8 hours; 480\n";
436 configString += "1 hour; 60\n"; 436 configString += "1 hour; 60\n";
437 configString += "30 min; 30\n"; 437 configString += "30 min; 30\n";
438 configString += "15 min; 15\n"; 438 configString += "15 min; 15\n";
439 configString += "SEPARATOR\n"; 439 configString += "SEPARATOR\n";
440 configString += "Pizza; 22\n"; 440 configString += "Pizza; 22\n";
441 configString += "Nap; 45\n"; 441 configString += "Nap; 45\n";
442 configString += "Tea; 5\n"; 442 configString += "Tea; 5\n";
443 QTextStream ts( &file ); 443 QTextStream ts( &file );
444 ts << configString ; 444 ts << configString ;
445 file.close(); 445 file.close();
446 } 446 }
447 447
448 if (!file.open( IO_ReadOnly ) ) { 448 if (!file.open( IO_ReadOnly ) ) {
449 return ; 449 return ;
450 } 450 }
451 QString line; 451 QString line;
452 bool ok; 452 bool ok;
453 while ( file.readLine( line, 1024 ) > 0 ) { 453 while ( file.readLine( line, 1024 ) > 0 ) {
454 //qDebug("read %s ", line.latin1()); 454 //qDebug("read %s ", line.latin1());
455 if ( line.left(1 ) != "#" ) { 455 if ( line.left(1 ) != "#" ) {
456 // no comment 456 // no comment
457 if ( line.left(9 ) == "SEPARATOR" ) { 457 if ( line.left(9 ) == "SEPARATOR" ) {
458 mTimerPopUp->insertSeparator(); 458 mTimerPopUp->insertSeparator();
459 } else { 459 } else {
460 QStringList li = QStringList::split(";",line); 460 QStringList li = QStringList::split(";",line);
461 ok = false; 461 ok = false;
462 if ( li.count() == 2 ) { 462 if ( li.count() == 2 ) {
463 int val = li[1].toInt( &ok ); 463 int val = li[1].toInt( &ok );
464 if ( ok && val > 0 ) { 464 if ( ok && val > 0 ) {
465 mTimerPopUp->insertItem( li[0], val+10); 465 mTimerPopUp->insertItem( li[0], val+10);
466 } 466 }
467 } 467 }
468 } 468 }
469 } 469 }
470 } 470 }
471 file.close(); 471 file.close();
472#if 0 472#if 0
473 mTimerPopUp->insertItem( "24 hours", 1440 ); 473 mTimerPopUp->insertItem( "24 hours", 1440 );
474 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 474 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
475 mTimerPopUp->insertItem( " 8 hours", 480 ); 475 mTimerPopUp->insertItem( " 8 hours", 480 );
476 mTimerPopUp->insertItem( " 5 hours", 300 ); 476 mTimerPopUp->insertItem( " 5 hours", 300 );
477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
478 mTimerPopUp->insertItem( " 1 hour", 60 ); 478 mTimerPopUp->insertItem( " 1 hour", 60 );
479 mTimerPopUp->insertItem( "30 min", 30 ); 479 mTimerPopUp->insertItem( "30 min", 30 );
480 mTimerPopUp->insertItem( "15 min", 15 ); 480 mTimerPopUp->insertItem( "15 min", 15 );
481 mTimerPopUp->insertItem( "10 min", 10 ); 481 mTimerPopUp->insertItem( "10 min", 10 );
482 //mTimerPopUp->insertItem( " 5 min", 5 ); 482 //mTimerPopUp->insertItem( " 5 min", 5 );
483 mTimerPopUp->insertSeparator(); 483 mTimerPopUp->insertSeparator();
484 mTimerPopUp->insertItem( "Pizza", 22 ); 484 mTimerPopUp->insertItem( "Pizza", 22 );
485 mTimerPopUp->insertItem( "Nap", 45 ); 485 mTimerPopUp->insertItem( "Nap", 45 );
486 mTimerPopUp->insertItem( "Tea", 5 ); 486 mTimerPopUp->insertItem( "Tea", 5 );
487#endif 487#endif
488 QString text = mCustomText.stripWhiteSpace (); 488 QString text = mCustomText.stripWhiteSpace ();
489 int in = text.find( " " ); 489 int in = text.find( " " );
490 text = text.left ( in ); 490 text = text.left ( in );
491 mTimerPopUp->insertItem( text, 3 ); 491 mTimerPopUp->insertItem( text, 3 );
492 mTimerPopUp->insertSeparator(); 492 mTimerPopUp->insertSeparator();
493 mTimerPopUp->insertItem( "Customize", 2 ); 493 mTimerPopUp->insertItem( "Customize", 2 );
494 } 494 }
495 495
496} 496}
497 497
498void SimpleAlarmDaemonImpl::showTimer() 498void SimpleAlarmDaemonImpl::showTimer()
499{ 499{
500 fillTimerPopUp(); 500 fillTimerPopUp();
501} 501}
502 502
503void SimpleAlarmDaemonImpl::confTimer( int time ) 503void SimpleAlarmDaemonImpl::confTimer( int time )
504{ 504{
505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
506 int minutes = time; 506 int minutes = time;
507 if ( minutes == 0 ) { 507 if ( minutes == 0 ) {
508 if ( ! mTimerTime ) 508 if ( ! mTimerTime )
509 return; 509 return;
510 510
511 QDialog dia ( 0, ("Stop Timer" ), true ); 511 QDialog dia ( 0, ("Stop Timer" ), true );
512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
513 lab.setAlignment( AlignCenter ); 513 lab.setAlignment( AlignCenter );
514 dia.setCaption(("KO/Pi Timer Stop" )); 514 dia.setCaption(("KO/Pi Timer Stop" ));
515 QVBoxLayout lay( &dia ); 515 QVBoxLayout lay( &dia );
516 lay.addWidget( &lab); 516 lay.addWidget( &lab);
517 QPushButton ok ( "Stop timer!", &dia); 517 QPushButton ok ( "Stop timer!", &dia);
518 QFont fo = dia.font(); 518 QFont fo = dia.font();
519 fo.setPointSize( 36 ); 519 fo.setPointSize( 36 );
520 ok.setFont( fo ); 520 ok.setFont( fo );
521 lay.addWidget( &ok); 521 lay.addWidget( &ok);
522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
523 QPushButton con ( "Continue timer!", &dia); 523 QPushButton con ( "Continue timer!", &dia);
524 fo.setPointSize( 36 ); 524 fo.setPointSize( 36 );
525 con.setFont( fo ); 525 con.setFont( fo );
526 lay.addWidget( &con); 526 lay.addWidget( &con);
527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
528 lay.setMargin(5); 528 lay.setMargin(5);
529 lay.setSpacing(5); 529 lay.setSpacing(5);
530 dia.resize(dia.sizeHint() ); 530 dia.resize(dia.sizeHint() );
531 531
532 if ( !dia.exec() ) 532 if ( !dia.exec() )
533 return; 533 return;
534 534
535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
536 mTimerTime = 0; 536 mTimerTime = 0;
537 return; 537 return;
538 } 538 }
539 if ( mTimerTime ) 539 if ( mTimerTime )
540 return; 540 return;
541 if ( minutes == 1 ) { 541 if ( minutes == 1 ) {
542 return; 542 return;
543 } 543 }
544 QString mess = "timer_alarm"; 544 QString mess = "timer_alarm";
545 QString disp; 545 QString disp;
546 mess += ("Timer Alarm!\n"); 546 mess += ("Timer Alarm!\n");
547 if ( minutes == 3 ) { 547 if ( minutes == 3 ) {
548 mess += mCustomText; 548 mess += mCustomText;
549 minutes = mCustomMinutes ; 549 minutes = mCustomMinutes ;
550 mRunningTimerText = mCustomText.stripWhiteSpace (); 550 mRunningTimerText = mCustomText.stripWhiteSpace ();
551 int in = mRunningTimerText.find( " " ); 551 int in = mRunningTimerText.find( " " );
552 mRunningTimerText = mRunningTimerText.left ( in ); 552 mRunningTimerText = mRunningTimerText.left ( in );
553 disp = mCustomText; 553 disp = mCustomText;
554 } 554 }
555 else { 555 else {
556 if ( minutes == 2 ) { 556 if ( minutes == 2 ) {
557 // ask time 557 // ask time
558 QDialog dia ( 0, ("Customize Timer" ), true ); 558 QDialog dia ( 0, ("Customize Timer" ), true );
559 QLabel lab (("Message Text:"), &dia ); 559 QLabel lab (("Message Text:"), &dia );
560 dia.setCaption(("KO/Pi Timer" )); 560 dia.setCaption(("KO/Pi Timer" ));
561 QVBoxLayout lay( &dia ); 561 QVBoxLayout lay( &dia );
562 lay.setMargin(5); 562 lay.setMargin(5);
563 lay.setSpacing(5); 563 lay.setSpacing(5);
564 lay.addWidget( &lab); 564 lay.addWidget( &lab);
565 QLineEdit lEdit( mCustomText, &dia ); 565 QLineEdit lEdit( mCustomText, &dia );
566 lay.addWidget( &lEdit); 566 lay.addWidget( &lEdit);
567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
568 lay.addWidget( &lab2); 568 lay.addWidget( &lab2);
569 QHBox hbox1 ( &dia ); 569 QHBox hbox1 ( &dia );
570 lay.addWidget( &hbox1); 570 lay.addWidget( &hbox1);
571 QLabel lab3 (("Hours"), &hbox1 ); 571 QLabel lab3 (("Hours"), &hbox1 );
572 QLabel lab4 (("Minutes"), &hbox1 ); 572 QLabel lab4 (("Minutes"), &hbox1 );
573 QHBox hbox ( &dia ); 573 QHBox hbox ( &dia );
574 QSpinBox spinh( 0, 24, 1,& hbox ); 574 QSpinBox spinh( 0, 24, 1,& hbox );
575 QFont fo = dia.font(); 575 QFont fo = dia.font();
576 fo.setPointSize( 36 ); 576 fo.setPointSize( 36 );
577 QSpinBox spinm( 0, 59, 1,&hbox ); 577 QSpinBox spinm( 0, 59, 1,&hbox );
578 spinm.setFont( fo ); 578 spinm.setFont( fo );
579 spinh.setFont( fo ); 579 spinh.setFont( fo );
580 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 580 spinh.setButtonSymbols( QSpinBox::PlusMinus );
581 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 581 spinm.setButtonSymbols( QSpinBox::PlusMinus );
582 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 582 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
583 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 583 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
584 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 584 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
585 spinh.setFixedSize( 100,62 ); 585 spinh.setFixedSize( 100,62 );
586 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 586 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
587 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 587 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
588 spinm.downButton ()->setGeometry( 50,50,50,50); 588 spinm.downButton ()->setGeometry( 50,50,50,50);
589 // spinm.setSuffix( " m" ); 589 // spinm.setSuffix( " m" );
590 //spinh.setSuffix( " h" ); 590 //spinh.setSuffix( " h" );
591 spinm.setWrapping ( true ); 591 spinm.setWrapping ( true );
592 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 592 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
593 spinm.setLineStep( 1 ); 593 spinm.setLineStep( 1 );
594 spinm.setFixedSize( 110,62 ); 594 spinm.setFixedSize( 110,62 );
595 lay.addWidget( &hbox); 595 lay.addWidget( &hbox);
596 QLabel lab5 ("Timer fires at:", &dia ); 596 QLabel lab5 ("Timer fires at:", &dia );
597 lab5.setAlignment( AlignCenter ); 597 lab5.setAlignment( AlignCenter );
598 lay.addWidget( &lab5); 598 lay.addWidget( &lab5);
599 KODateLabel dl ( &dia ); 599 KODateLabel dl ( &dia );
600 dl.setAlignment( AlignCenter ); 600 dl.setAlignment( AlignCenter );
601 dl.setFont( fo ); 601 dl.setFont( fo );
602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
604 lay.addWidget( &dl); 604 lay.addWidget( &dl);
605 spinh.setValue( mCustomMinutes/60 ); 605 spinh.setValue( mCustomMinutes/60 );
606 spinm.setValue( mCustomMinutes%60 ); 606 spinm.setValue( mCustomMinutes%60 );
607 QPushButton ok ( "Start timer", &dia); 607 QPushButton ok ( "Start timer", &dia);
608 ok.setDefault( true ); 608 ok.setDefault( true );
609 ok.setFont( fo ); 609 ok.setFont( fo );
610 spinh.setFocus(); 610 spinh.setFocus();
611 lay.addWidget( &ok); 611 lay.addWidget( &ok);
612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
614 614
615 if ( !dia.exec() ) 615 if ( !dia.exec() )
616 return; 616 return;
617 mCustomText = lEdit.text(); 617 mCustomText = lEdit.text();
618 mCustomMinutes = spinh.value()*60+spinm.value(); 618 mCustomMinutes = spinh.value()*60+spinm.value();
619 if ( mCustomMinutes == 0 ) 619 if ( mCustomMinutes == 0 )
620 mCustomMinutes = 1; 620 mCustomMinutes = 1;
621 if ( mCustomMinutes > 1440 ) 621 if ( mCustomMinutes > 1440 )
622 mCustomMinutes = 1440; 622 mCustomMinutes = 1440;
623 mess += mCustomText; 623 mess += mCustomText;
624 disp = mCustomText; 624 disp = mCustomText;
625 minutes = mCustomMinutes; 625 minutes = mCustomMinutes;
626 mRunningTimerText = mCustomText.stripWhiteSpace (); 626 mRunningTimerText = mCustomText.stripWhiteSpace ();
627 int in = mRunningTimerText.find( " " ); 627 int in = mRunningTimerText.find( " " );
628 mRunningTimerText = mRunningTimerText.left ( in ); 628 mRunningTimerText = mRunningTimerText.left ( in );
629 } 629 }
630 else { 630 else {
631 mess += mTimerPopUp->text( minutes ); 631 mess += mTimerPopUp->text( minutes );
632 disp = mTimerPopUp->text( minutes ); 632 disp = mTimerPopUp->text( minutes );
633 mRunningTimerText = mTimerPopUp->text( minutes ); 633 mRunningTimerText = mTimerPopUp->text( minutes );
634 minutes -= 10; 634 minutes -= 10;
635 } 635 }
636 } 636 }
637 //minutes = 1; 637 //minutes = 1;
638 638
639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
640 timerMesssage = mess; 640 timerMesssage = mess;
641 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 641 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
642 mTimerStartLabel->setText( disp + "\n\nTimer started!" ); 642 mTimerStartLabel->setText( disp + "\n\nTimer started!" );
643 int w = mTimerStartLabel->sizeHint().width()+20; 643 int w = mTimerStartLabel->sizeHint().width()+20;
644 int h = mTimerStartLabel->sizeHint().height()+40 ; 644 int h = mTimerStartLabel->sizeHint().height()+40 ;
645 int dw = QApplication::desktop()->width(); 645 int dw = QApplication::desktop()->width();
646 int dh = QApplication::desktop()->height(); 646 int dh = QApplication::desktop()->height();
647 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 647 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
648 mTimerStartLabel->show(); 648 mTimerStartLabel->show();
649 QTimer::singleShot( 5000, mTimerStartLabel, SLOT ( hide() ) ); 649 QTimer::singleShot( 4000, mTimerStartLabel, SLOT ( hide() ) );
650 mTimerTime = 1; 650 mTimerTime = 1;
651} 651}
652 652
653void SimpleAlarmDaemonImpl::confFontSize( int size ) 653void SimpleAlarmDaemonImpl::confFontSize( int size )
654{ 654{
655 655
656 mFontsizePopup->setItemChecked( mPopupFontSize, false ); 656 mFontsizePopup->setItemChecked( mPopupFontSize, false );
657 mPopupFontSize = size; 657 mPopupFontSize = size;
658 mFontsizePopup->setItemChecked( mPopupFontSize, true ); 658 mFontsizePopup->setItemChecked( mPopupFontSize, true );
659 QFont fon = mTimerPopUp->font(); 659 QFont fon = mTimerPopUp->font();
660 fon.setPointSize( mPopupFontSize ); 660 fon.setPointSize( mPopupFontSize );
661 mTimerPopUp->setFont( fon ); 661 mTimerPopUp->setFont( fon );
662 mPopUp->setFont( fon ); 662 mPopUp->setFont( fon );
663 fon.setBold( true ); 663 fon.setBold( true );
664 fon.setPointSize( mPopupFontSize * 2 ); 664 fon.setPointSize( mPopupFontSize * 2 );
665 mTimerStartLabel->setFont( fon ); 665 mTimerStartLabel->setFont( fon );
666} 666}
667void SimpleAlarmDaemonImpl::writeFile() 667void SimpleAlarmDaemonImpl::writeFile()
668{ 668{
669 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 669 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
670 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 670 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
671} 671}
672void SimpleAlarmDaemonImpl::showWN() 672void SimpleAlarmDaemonImpl::showWN()
673{ 673{
674 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 674 QCopEnvelope e("QPE/Application/kopi", "-showWN");
675} 675}
676void SimpleAlarmDaemonImpl::newTodo() 676void SimpleAlarmDaemonImpl::newTodo()
677{ 677{
678 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 678 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
679} 679}
680 680
681void SimpleAlarmDaemonImpl::newEvent() 681void SimpleAlarmDaemonImpl::newEvent()
682{ 682{
683 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 683 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
684 684
685} 685}
686void SimpleAlarmDaemonImpl::newMail() 686void SimpleAlarmDaemonImpl::newMail()
687{ 687{
688 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 688 QCopEnvelope e("QPE/Application/ompi", "newMail()");
689} 689}
690void SimpleAlarmDaemonImpl::showAdd() 690void SimpleAlarmDaemonImpl::showAdd()
691{ 691{
692 QCopEnvelope e("QPE/Application/kapi", "raise()"); 692 QCopEnvelope e("QPE/Application/kapi", "raise()");
693} 693}
694void SimpleAlarmDaemonImpl::ringSync() 694void SimpleAlarmDaemonImpl::ringSync()
695{ 695{
696 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 696 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
697 697
698} 698}
699void SimpleAlarmDaemonImpl::newCountdown() 699void SimpleAlarmDaemonImpl::newCountdown()
700{ 700{
701 //recieve("cal_alarm", 10 ); 701 //recieve("cal_alarm", 10 );
702} 702}
703void SimpleAlarmDaemonImpl::simulate() 703void SimpleAlarmDaemonImpl::simulate()
704{ 704{
705 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 705 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
706 QString filename = getenv("QPEDIR") ; 706 QString filename = getenv("QPEDIR") ;
707 filename += "/pics/kdepim/korganizer/koalarm.wav"; 707 filename += "/pics/kdepim/korganizer/koalarm.wav";
708 startAlarm("Alarm simulation", filename ); 708 startAlarm("Alarm simulation", filename );
709} 709}
710void SimpleAlarmDaemonImpl::showKO() 710void SimpleAlarmDaemonImpl::showKO()
711{ 711{
712 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 712 QCopEnvelope e("QPE/Application/kopi", "-showKO");
713 // testing only 713 // testing only
714 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 714 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
715 715
716} 716}
717void SimpleAlarmDaemonImpl::showTodo() 717void SimpleAlarmDaemonImpl::showTodo()
718{ 718{
719 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 719 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
720 720
721} 721}
722void SimpleAlarmDaemonImpl::writeJournal() 722void SimpleAlarmDaemonImpl::writeJournal()
723{ 723{
724 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 724 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
725 725
726} 726}
727 727
728void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 728void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
729{ 729{
730 730
731 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 731 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
732 732
733} 733}
734 734