summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 18b4d58..39d14bb 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -474,1723 +474,1724 @@ bool Addressee::removeVoice()
474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
476 if ((*phoneIt).type() - PhoneNumber::Voice ) { 476 if ((*phoneIt).type() - PhoneNumber::Voice ) {
477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
478 insertPhoneNumber( (*phoneIt) ); 478 insertPhoneNumber( (*phoneIt) );
479 found = true; 479 found = true;
480 } 480 }
481 } 481 }
482 482
483 } 483 }
484 return found; 484 return found;
485} 485}
486 486
487bool Addressee::containsAdr(const Addressee& ad ) 487bool Addressee::containsAdr(const Addressee& ad )
488{ 488{
489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
496 496
497 // compare phone numbers 497 // compare phone numbers
498 PhoneNumber::List phoneN = ad.phoneNumbers(); 498 PhoneNumber::List phoneN = ad.phoneNumbers();
499 PhoneNumber::List::Iterator phoneIt; 499 PhoneNumber::List::Iterator phoneIt;
500 bool found = false; 500 bool found = false;
501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
502 bool found = false; 502 bool found = false;
503 PhoneNumber::List phoneL = ad.phoneNumbers(); 503 PhoneNumber::List phoneL = ad.phoneNumbers();
504 PhoneNumber::List::Iterator phoneItL; 504 PhoneNumber::List::Iterator phoneItL;
505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
507 found = true; 507 found = true;
508 break; 508 break;
509 } 509 }
510 } 510 }
511 if ( ! found ) 511 if ( ! found )
512 return false; 512 return false;
513 } 513 }
514 return true; 514 return true;
515 515
516} 516}
517void Addressee::simplifyAddresses() 517void Addressee::simplifyAddresses()
518{ 518{
519 519
520 520
521 Address::List list; 521 Address::List list;
522 Address::List::Iterator it; 522 Address::List::Iterator it;
523 Address::List::Iterator it2; 523 Address::List::Iterator it2;
524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
525 it2 = it; 525 it2 = it;
526 ++it2; 526 ++it2;
527 for( ; it2 != mData->addresses.end(); ++it2 ) { 527 for( ; it2 != mData->addresses.end(); ++it2 ) {
528 if ( (*it) == (*it2) ) { 528 if ( (*it) == (*it2) ) {
529 list.append( *it ); 529 list.append( *it );
530 break; 530 break;
531 } 531 }
532 } 532 }
533 } 533 }
534 for( it = list.begin(); it != list.end(); ++it ) { 534 for( it = list.begin(); it != list.end(); ++it ) {
535 removeAddress( (*it) ); 535 removeAddress( (*it) );
536 } 536 }
537 537
538 list.clear(); 538 list.clear();
539 int max = 2; 539 int max = 2;
540 if ( mData->url.isValid() ) 540 if ( mData->url.isValid() )
541 max = 1; 541 max = 1;
542 if ( mData->addresses.count() <= max ) return ; 542 if ( mData->addresses.count() <= max ) return ;
543 int count = 0; 543 int count = 0;
544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
545 if ( count >= max ) 545 if ( count >= max )
546 list.append( *it ); 546 list.append( *it );
547 ++count; 547 ++count;
548 } 548 }
549 for( it = list.begin(); it != list.end(); ++it ) { 549 for( it = list.begin(); it != list.end(); ++it ) {
550 removeAddress( (*it) ); 550 removeAddress( (*it) );
551 } 551 }
552} 552}
553 553
554// removes all emails but the first 554// removes all emails but the first
555// needed by phone sync 555// needed by phone sync
556void Addressee::simplifyEmails() 556void Addressee::simplifyEmails()
557{ 557{
558 if ( mData->emails.count() == 0 ) return ; 558 if ( mData->emails.count() == 0 ) return ;
559 QString email = mData->emails.first(); 559 QString email = mData->emails.first();
560 detach(); 560 detach();
561 mData->emails.clear(); 561 mData->emails.clear();
562 mData->emails.append( email ); 562 mData->emails.append( email );
563} 563}
564 564
565void Addressee::simplifyPhoneNumbers() 565void Addressee::simplifyPhoneNumbers()
566{ 566{
567 int max = 4; 567 int max = 4;
568 int inList = mData->phoneNumbers.count(); 568 int inList = mData->phoneNumbers.count();
569 KABC::PhoneNumber::List removeNumbers; 569 KABC::PhoneNumber::List removeNumbers;
570 KABC::PhoneNumber::List::Iterator phoneIter; 570 KABC::PhoneNumber::List::Iterator phoneIter;
571 if ( inList > max ) { 571 if ( inList > max ) {
572 // delete non-preferred numbers 572 // delete non-preferred numbers
573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
574 ++phoneIter ) { 574 ++phoneIter ) {
575 if ( inList > max ) { 575 if ( inList > max ) {
576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
577 removeNumbers.append( ( *phoneIter ) ); 577 removeNumbers.append( ( *phoneIter ) );
578 --inList; 578 --inList;
579 } 579 }
580 } else 580 } else
581 break; 581 break;
582 } 582 }
583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
584 ++phoneIter ) { 584 ++phoneIter ) {
585 removePhoneNumber(( *phoneIter )); 585 removePhoneNumber(( *phoneIter ));
586 } 586 }
587 // delete preferred numbers 587 // delete preferred numbers
588 if ( inList > max ) { 588 if ( inList > max ) {
589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
590 ++phoneIter ) { 590 ++phoneIter ) {
591 if ( inList > max ) { 591 if ( inList > max ) {
592 removeNumbers.append( ( *phoneIter ) ); 592 removeNumbers.append( ( *phoneIter ) );
593 --inList; 593 --inList;
594 } else 594 } else
595 break; 595 break;
596 } 596 }
597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
598 ++phoneIter ) { 598 ++phoneIter ) {
599 removePhoneNumber(( *phoneIter )); 599 removePhoneNumber(( *phoneIter ));
600 } 600 }
601 } 601 }
602 } 602 }
603 // remove non-numeric characters 603 // remove non-numeric characters
604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
605 ++phoneIter ) { 605 ++phoneIter ) {
606 if ( ! ( *phoneIter ).simplifyNumber() ) 606 if ( ! ( *phoneIter ).simplifyNumber() )
607 removeNumbers.append( ( *phoneIter ) ); 607 removeNumbers.append( ( *phoneIter ) );
608 } 608 }
609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
610 ++phoneIter ) { 610 ++phoneIter ) {
611 removePhoneNumber(( *phoneIter )); 611 removePhoneNumber(( *phoneIter ));
612 } 612 }
613} 613}
614void Addressee::simplifyPhoneNumberTypes() 614void Addressee::simplifyPhoneNumberTypes()
615{ 615{
616 KABC::PhoneNumber::List::Iterator phoneIter; 616 KABC::PhoneNumber::List::Iterator phoneIter;
617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
618 ++phoneIter ) 618 ++phoneIter )
619 ( *phoneIter ).simplifyType(); 619 ( *phoneIter ).simplifyType();
620} 620}
621void Addressee::removeID(const QString &prof) 621void Addressee::removeID(const QString &prof)
622{ 622{
623 detach(); 623 detach();
624 if ( prof.isEmpty() ) 624 if ( prof.isEmpty() )
625 mData->mExternalId = ":"; 625 mData->mExternalId = ":";
626 else 626 else
627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
628 628
629} 629}
630void Addressee::setID( const QString & prof , const QString & id ) 630void Addressee::setID( const QString & prof , const QString & id )
631{ 631{
632 detach(); 632 detach();
633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
635} 635}
636void Addressee::setTempSyncStat( int id ) 636void Addressee::setTempSyncStat( int id )
637{ 637{
638 if ( mData->mTempSyncStat == id ) return; 638 if ( mData->mTempSyncStat == id ) return;
639 detach(); 639 detach();
640 mData->mTempSyncStat = id; 640 mData->mTempSyncStat = id;
641} 641}
642int Addressee::tempSyncStat() const 642int Addressee::tempSyncStat() const
643{ 643{
644 return mData->mTempSyncStat; 644 return mData->mTempSyncStat;
645} 645}
646 646
647const QString Addressee::getID( const QString & prof) const 647const QString Addressee::getID( const QString & prof) const
648{ 648{
649 return KIdManager::getId ( mData->mExternalId, prof ); 649 return KIdManager::getId ( mData->mExternalId, prof );
650} 650}
651 651
652void Addressee::setCsum( const QString & prof , const QString & id ) 652void Addressee::setCsum( const QString & prof , const QString & id )
653{ 653{
654 detach(); 654 detach();
655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
658} 658}
659 659
660const QString Addressee::getCsum( const QString & prof) const 660const QString Addressee::getCsum( const QString & prof) const
661{ 661{
662 return KIdManager::getCsum ( mData->mExternalId, prof ); 662 return KIdManager::getCsum ( mData->mExternalId, prof );
663} 663}
664 664
665void Addressee::setIDStr( const QString & s ) 665void Addressee::setIDStr( const QString & s )
666{ 666{
667 detach(); 667 detach();
668 mData->mExternalId = s; 668 mData->mExternalId = s;
669} 669}
670 670
671const QString Addressee::IDStr() const 671const QString Addressee::IDStr() const
672{ 672{
673 return mData->mExternalId; 673 return mData->mExternalId;
674} 674}
675 675
676void Addressee::setExternalUID( const QString &id ) 676void Addressee::setExternalUID( const QString &id )
677{ 677{
678 if ( id == mData->externalUID ) return; 678 if ( id == mData->externalUID ) return;
679 detach(); 679 detach();
680 mData->empty = false; 680 mData->empty = false;
681 mData->externalUID = id; 681 mData->externalUID = id;
682} 682}
683 683
684const QString Addressee::externalUID() const 684const QString Addressee::externalUID() const
685{ 685{
686 return mData->externalUID; 686 return mData->externalUID;
687} 687}
688void Addressee::setOriginalExternalUID( const QString &id ) 688void Addressee::setOriginalExternalUID( const QString &id )
689{ 689{
690 if ( id == mData->originalExternalUID ) return; 690 if ( id == mData->originalExternalUID ) return;
691 detach(); 691 detach();
692 mData->empty = false; 692 mData->empty = false;
693 //qDebug("*******Set orig uid %s ", id.latin1()); 693 //qDebug("*******Set orig uid %s ", id.latin1());
694 mData->originalExternalUID = id; 694 mData->originalExternalUID = id;
695} 695}
696 696
697QString Addressee::originalExternalUID() const 697QString Addressee::originalExternalUID() const
698{ 698{
699 return mData->originalExternalUID; 699 return mData->originalExternalUID;
700} 700}
701 701
702void Addressee::setUid( const QString &id ) 702void Addressee::setUid( const QString &id )
703{ 703{
704 if ( id == mData->uid ) return; 704 if ( id == mData->uid ) return;
705 detach(); 705 detach();
706 //qDebug("****setuid %s ", id.latin1()); 706 //qDebug("****setuid %s ", id.latin1());
707 mData->empty = false; 707 mData->empty = false;
708 mData->uid = id; 708 mData->uid = id;
709} 709}
710 710
711const QString Addressee::uid() const 711const QString Addressee::uid() const
712{ 712{
713 if ( mData->uid.isEmpty() ) 713 if ( mData->uid.isEmpty() )
714 mData->uid = KApplication::randomString( 10 ); 714 mData->uid = KApplication::randomString( 10 );
715 715
716 return mData->uid; 716 return mData->uid;
717} 717}
718 718
719QString Addressee::uidLabel() 719QString Addressee::uidLabel()
720{ 720{
721 return i18n("Unique Identifier"); 721 return i18n("Unique Identifier");
722} 722}
723 723
724void Addressee::setName( const QString &name ) 724void Addressee::setName( const QString &name )
725{ 725{
726 if ( name == mData->name ) return; 726 if ( name == mData->name ) return;
727 detach(); 727 detach();
728 mData->empty = false; 728 mData->empty = false;
729 mData->name = name; 729 mData->name = name;
730} 730}
731 731
732QString Addressee::name() const 732QString Addressee::name() const
733{ 733{
734 return mData->name; 734 return mData->name;
735} 735}
736 736
737QString Addressee::nameLabel() 737QString Addressee::nameLabel()
738{ 738{
739 return i18n("Name"); 739 return i18n("Name");
740} 740}
741 741
742 742
743void Addressee::setFormattedName( const QString &formattedName ) 743void Addressee::setFormattedName( const QString &formattedName )
744{ 744{
745 if ( formattedName == mData->formattedName ) return; 745 if ( formattedName == mData->formattedName ) return;
746 detach(); 746 detach();
747 mData->empty = false; 747 mData->empty = false;
748 mData->formattedName = formattedName; 748 mData->formattedName = formattedName;
749} 749}
750 750
751QString Addressee::formattedName() const 751QString Addressee::formattedName() const
752{ 752{
753 return mData->formattedName; 753 return mData->formattedName;
754} 754}
755 755
756QString Addressee::formattedNameLabel() 756QString Addressee::formattedNameLabel()
757{ 757{
758 return i18n("Formatted Name"); 758 return i18n("Formatted Name");
759} 759}
760 760
761 761
762void Addressee::setFamilyName( const QString &familyName ) 762void Addressee::setFamilyName( const QString &familyName )
763{ 763{
764 if ( familyName == mData->familyName ) return; 764 if ( familyName == mData->familyName ) return;
765 detach(); 765 detach();
766 mData->empty = false; 766 mData->empty = false;
767 mData->familyName = familyName; 767 mData->familyName = familyName;
768} 768}
769 769
770QString Addressee::familyName() const 770QString Addressee::familyName() const
771{ 771{
772 return mData->familyName; 772 return mData->familyName;
773} 773}
774 774
775QString Addressee::familyNameLabel() 775QString Addressee::familyNameLabel()
776{ 776{
777 return i18n("Family Name"); 777 return i18n("Family Name");
778} 778}
779 779
780 780
781void Addressee::setGivenName( const QString &givenName ) 781void Addressee::setGivenName( const QString &givenName )
782{ 782{
783 if ( givenName == mData->givenName ) return; 783 if ( givenName == mData->givenName ) return;
784 detach(); 784 detach();
785 mData->empty = false; 785 mData->empty = false;
786 mData->givenName = givenName; 786 mData->givenName = givenName;
787} 787}
788 788
789QString Addressee::givenName() const 789QString Addressee::givenName() const
790{ 790{
791 return mData->givenName; 791 return mData->givenName;
792} 792}
793 793
794QString Addressee::givenNameLabel() 794QString Addressee::givenNameLabel()
795{ 795{
796 return i18n("Given Name"); 796 return i18n("Given Name");
797} 797}
798 798
799 799
800void Addressee::setAdditionalName( const QString &additionalName ) 800void Addressee::setAdditionalName( const QString &additionalName )
801{ 801{
802 if ( additionalName == mData->additionalName ) return; 802 if ( additionalName == mData->additionalName ) return;
803 detach(); 803 detach();
804 mData->empty = false; 804 mData->empty = false;
805 mData->additionalName = additionalName; 805 mData->additionalName = additionalName;
806} 806}
807 807
808QString Addressee::additionalName() const 808QString Addressee::additionalName() const
809{ 809{
810 return mData->additionalName; 810 return mData->additionalName;
811} 811}
812 812
813QString Addressee::additionalNameLabel() 813QString Addressee::additionalNameLabel()
814{ 814{
815 return i18n("Additional Names"); 815 return i18n("Additional Names");
816} 816}
817 817
818 818
819void Addressee::setPrefix( const QString &prefix ) 819void Addressee::setPrefix( const QString &prefix )
820{ 820{
821 if ( prefix == mData->prefix ) return; 821 if ( prefix == mData->prefix ) return;
822 detach(); 822 detach();
823 mData->empty = false; 823 mData->empty = false;
824 mData->prefix = prefix; 824 mData->prefix = prefix;
825} 825}
826 826
827QString Addressee::prefix() const 827QString Addressee::prefix() const
828{ 828{
829 return mData->prefix; 829 return mData->prefix;
830} 830}
831 831
832QString Addressee::prefixLabel() 832QString Addressee::prefixLabel()
833{ 833{
834 return i18n("Honorific Prefixes"); 834 return i18n("Honorific Prefixes");
835} 835}
836 836
837 837
838void Addressee::setSuffix( const QString &suffix ) 838void Addressee::setSuffix( const QString &suffix )
839{ 839{
840 if ( suffix == mData->suffix ) return; 840 if ( suffix == mData->suffix ) return;
841 detach(); 841 detach();
842 mData->empty = false; 842 mData->empty = false;
843 mData->suffix = suffix; 843 mData->suffix = suffix;
844} 844}
845 845
846QString Addressee::suffix() const 846QString Addressee::suffix() const
847{ 847{
848 return mData->suffix; 848 return mData->suffix;
849} 849}
850 850
851QString Addressee::suffixLabel() 851QString Addressee::suffixLabel()
852{ 852{
853 return i18n("Honorific Suffixes"); 853 return i18n("Honorific Suffixes");
854} 854}
855 855
856 856
857void Addressee::setNickName( const QString &nickName ) 857void Addressee::setNickName( const QString &nickName )
858{ 858{
859 if ( nickName == mData->nickName ) return; 859 if ( nickName == mData->nickName ) return;
860 detach(); 860 detach();
861 mData->empty = false; 861 mData->empty = false;
862 mData->nickName = nickName; 862 mData->nickName = nickName;
863} 863}
864 864
865QString Addressee::nickName() const 865QString Addressee::nickName() const
866{ 866{
867 return mData->nickName; 867 return mData->nickName;
868} 868}
869 869
870QString Addressee::nickNameLabel() 870QString Addressee::nickNameLabel()
871{ 871{
872 return i18n("Nick Name"); 872 return i18n("Nick Name");
873} 873}
874 874
875 875
876void Addressee::setBirthday( const QDateTime &birthday ) 876void Addressee::setBirthday( const QDateTime &birthday )
877{ 877{
878 if ( birthday == mData->birthday ) return; 878 if ( birthday == mData->birthday ) return;
879 detach(); 879 detach();
880 mData->empty = false; 880 mData->empty = false;
881 mData->birthday = birthday; 881 mData->birthday = birthday;
882} 882}
883 883
884QDateTime Addressee::birthday() const 884QDateTime Addressee::birthday() const
885{ 885{
886 return mData->birthday; 886 return mData->birthday;
887} 887}
888 888
889QString Addressee::birthdayLabel() 889QString Addressee::birthdayLabel()
890{ 890{
891 return i18n("Birthday"); 891 return i18n("Birthday");
892} 892}
893 893
894 894
895QString Addressee::homeAddressStreetLabel() 895QString Addressee::homeAddressStreetLabel()
896{ 896{
897 return i18n("Home Address Street"); 897 return i18n("Home Address Street");
898} 898}
899 899
900 900
901QString Addressee::homeAddressLocalityLabel() 901QString Addressee::homeAddressLocalityLabel()
902{ 902{
903 return i18n("Home Address Locality"); 903 return i18n("Home Address Locality");
904} 904}
905 905
906 906
907QString Addressee::homeAddressRegionLabel() 907QString Addressee::homeAddressRegionLabel()
908{ 908{
909 return i18n("Home Address Region"); 909 return i18n("Home Address Region");
910} 910}
911 911
912 912
913QString Addressee::homeAddressPostalCodeLabel() 913QString Addressee::homeAddressPostalCodeLabel()
914{ 914{
915 return i18n("Home Address Postal Code"); 915 return i18n("Home Address Postal Code");
916} 916}
917 917
918 918
919QString Addressee::homeAddressCountryLabel() 919QString Addressee::homeAddressCountryLabel()
920{ 920{
921 return i18n("Home Address Country"); 921 return i18n("Home Address Country");
922} 922}
923 923
924 924
925QString Addressee::homeAddressLabelLabel() 925QString Addressee::homeAddressLabelLabel()
926{ 926{
927 return i18n("Home Address Label"); 927 return i18n("Home Address Label");
928} 928}
929 929
930 930
931QString Addressee::businessAddressStreetLabel() 931QString Addressee::businessAddressStreetLabel()
932{ 932{
933 return i18n("Business Address Street"); 933 return i18n("Business Address Street");
934} 934}
935 935
936 936
937QString Addressee::businessAddressLocalityLabel() 937QString Addressee::businessAddressLocalityLabel()
938{ 938{
939 return i18n("Business Address Locality"); 939 return i18n("Business Address Locality");
940} 940}
941 941
942 942
943QString Addressee::businessAddressRegionLabel() 943QString Addressee::businessAddressRegionLabel()
944{ 944{
945 return i18n("Business Address Region"); 945 return i18n("Business Address Region");
946} 946}
947 947
948 948
949QString Addressee::businessAddressPostalCodeLabel() 949QString Addressee::businessAddressPostalCodeLabel()
950{ 950{
951 return i18n("Business Address Postal Code"); 951 return i18n("Business Address Postal Code");
952} 952}
953 953
954 954
955QString Addressee::businessAddressCountryLabel() 955QString Addressee::businessAddressCountryLabel()
956{ 956{
957 return i18n("Business Address Country"); 957 return i18n("Business Address Country");
958} 958}
959 959
960 960
961QString Addressee::businessAddressLabelLabel() 961QString Addressee::businessAddressLabelLabel()
962{ 962{
963 return i18n("Business Address Label"); 963 return i18n("Business Address Label");
964} 964}
965 965
966 966
967QString Addressee::homePhoneLabel() 967QString Addressee::homePhoneLabel()
968{ 968{
969 return i18n("Home Phone"); 969 return i18n("Home Phone");
970} 970}
971 971
972 972
973QString Addressee::businessPhoneLabel() 973QString Addressee::businessPhoneLabel()
974{ 974{
975 return i18n("Business Phone"); 975 return i18n("Business Phone");
976} 976}
977 977
978 978
979QString Addressee::mobilePhoneLabel() 979QString Addressee::mobilePhoneLabel()
980{ 980{
981 return i18n("Mobile Phone"); 981 return i18n("Mobile Phone");
982} 982}
983 983
984 984
985QString Addressee::homeFaxLabel() 985QString Addressee::homeFaxLabel()
986{ 986{
987 return i18n("Home Fax"); 987 return i18n("Home Fax");
988} 988}
989 989
990 990
991QString Addressee::businessFaxLabel() 991QString Addressee::businessFaxLabel()
992{ 992{
993 return i18n("Business Fax"); 993 return i18n("Business Fax");
994} 994}
995 995
996 996
997QString Addressee::carPhoneLabel() 997QString Addressee::carPhoneLabel()
998{ 998{
999 return i18n("Car Phone"); 999 return i18n("Car Phone");
1000} 1000}
1001 1001
1002 1002
1003QString Addressee::isdnLabel() 1003QString Addressee::isdnLabel()
1004{ 1004{
1005 return i18n("ISDN"); 1005 return i18n("ISDN");
1006} 1006}
1007 1007
1008 1008
1009QString Addressee::pagerLabel() 1009QString Addressee::pagerLabel()
1010{ 1010{
1011 return i18n("Pager"); 1011 return i18n("Pager");
1012} 1012}
1013 1013
1014QString Addressee::sipLabel() 1014QString Addressee::sipLabel()
1015{ 1015{
1016 return i18n("SIP"); 1016 return i18n("SIP");
1017} 1017}
1018 1018
1019QString Addressee::emailLabel() 1019QString Addressee::emailLabel()
1020{ 1020{
1021 return i18n("Email Address"); 1021 return i18n("Email Address");
1022} 1022}
1023 1023
1024 1024
1025void Addressee::setMailer( const QString &mailer ) 1025void Addressee::setMailer( const QString &mailer )
1026{ 1026{
1027 if ( mailer == mData->mailer ) return; 1027 if ( mailer == mData->mailer ) return;
1028 detach(); 1028 detach();
1029 mData->empty = false; 1029 mData->empty = false;
1030 mData->mailer = mailer; 1030 mData->mailer = mailer;
1031} 1031}
1032 1032
1033QString Addressee::mailer() const 1033QString Addressee::mailer() const
1034{ 1034{
1035 return mData->mailer; 1035 return mData->mailer;
1036} 1036}
1037 1037
1038QString Addressee::mailerLabel() 1038QString Addressee::mailerLabel()
1039{ 1039{
1040 return i18n("Mail Client"); 1040 return i18n("Mail Client");
1041} 1041}
1042 1042
1043 1043
1044void Addressee::setTimeZone( const TimeZone &timeZone ) 1044void Addressee::setTimeZone( const TimeZone &timeZone )
1045{ 1045{
1046 if ( timeZone == mData->timeZone ) return; 1046 if ( timeZone == mData->timeZone ) return;
1047 detach(); 1047 detach();
1048 mData->empty = false; 1048 mData->empty = false;
1049 mData->timeZone = timeZone; 1049 mData->timeZone = timeZone;
1050} 1050}
1051 1051
1052TimeZone Addressee::timeZone() const 1052TimeZone Addressee::timeZone() const
1053{ 1053{
1054 return mData->timeZone; 1054 return mData->timeZone;
1055} 1055}
1056 1056
1057QString Addressee::timeZoneLabel() 1057QString Addressee::timeZoneLabel()
1058{ 1058{
1059 return i18n("Time Zone"); 1059 return i18n("Time Zone");
1060} 1060}
1061 1061
1062 1062
1063void Addressee::setGeo( const Geo &geo ) 1063void Addressee::setGeo( const Geo &geo )
1064{ 1064{
1065 if ( geo == mData->geo ) return; 1065 if ( geo == mData->geo ) return;
1066 detach(); 1066 detach();
1067 mData->empty = false; 1067 mData->empty = false;
1068 mData->geo = geo; 1068 mData->geo = geo;
1069} 1069}
1070 1070
1071Geo Addressee::geo() const 1071Geo Addressee::geo() const
1072{ 1072{
1073 return mData->geo; 1073 return mData->geo;
1074} 1074}
1075 1075
1076QString Addressee::geoLabel() 1076QString Addressee::geoLabel()
1077{ 1077{
1078 return i18n("Geographic Position"); 1078 return i18n("Geographic Position");
1079} 1079}
1080 1080
1081 1081
1082void Addressee::setTitle( const QString &title ) 1082void Addressee::setTitle( const QString &title )
1083{ 1083{
1084 if ( title == mData->title ) return; 1084 if ( title == mData->title ) return;
1085 detach(); 1085 detach();
1086 mData->empty = false; 1086 mData->empty = false;
1087 mData->title = title; 1087 mData->title = title;
1088} 1088}
1089 1089
1090QString Addressee::title() const 1090QString Addressee::title() const
1091{ 1091{
1092 return mData->title; 1092 return mData->title;
1093} 1093}
1094 1094
1095QString Addressee::titleLabel() 1095QString Addressee::titleLabel()
1096{ 1096{
1097 return i18n("Title"); 1097 return i18n("Title");
1098} 1098}
1099 1099
1100 1100
1101void Addressee::setRole( const QString &role ) 1101void Addressee::setRole( const QString &role )
1102{ 1102{
1103 if ( role == mData->role ) return; 1103 if ( role == mData->role ) return;
1104 detach(); 1104 detach();
1105 mData->empty = false; 1105 mData->empty = false;
1106 mData->role = role; 1106 mData->role = role;
1107} 1107}
1108 1108
1109QString Addressee::role() const 1109QString Addressee::role() const
1110{ 1110{
1111 return mData->role; 1111 return mData->role;
1112} 1112}
1113 1113
1114QString Addressee::roleLabel() 1114QString Addressee::roleLabel()
1115{ 1115{
1116 return i18n("Role"); 1116 return i18n("Role");
1117} 1117}
1118 1118
1119 1119
1120void Addressee::setOrganization( const QString &organization ) 1120void Addressee::setOrganization( const QString &organization )
1121{ 1121{
1122 if ( organization == mData->organization ) return; 1122 if ( organization == mData->organization ) return;
1123 detach(); 1123 detach();
1124 mData->empty = false; 1124 mData->empty = false;
1125 mData->organization = organization; 1125 mData->organization = organization;
1126} 1126}
1127 1127
1128QString Addressee::organization() const 1128QString Addressee::organization() const
1129{ 1129{
1130 return mData->organization; 1130 return mData->organization;
1131} 1131}
1132 1132
1133QString Addressee::organizationLabel() 1133QString Addressee::organizationLabel()
1134{ 1134{
1135 return i18n("Organization"); 1135 return i18n("Organization");
1136} 1136}
1137 1137
1138 1138
1139void Addressee::setNote( const QString &note ) 1139void Addressee::setNote( const QString &note )
1140{ 1140{
1141 if ( note == mData->note ) return; 1141 if ( note == mData->note ) return;
1142 detach(); 1142 detach();
1143 mData->empty = false; 1143 mData->empty = false;
1144 mData->note = note; 1144 mData->note = note;
1145} 1145}
1146 1146
1147QString Addressee::note() const 1147QString Addressee::note() const
1148{ 1148{
1149 return mData->note; 1149 return mData->note;
1150} 1150}
1151 1151
1152QString Addressee::noteLabel() 1152QString Addressee::noteLabel()
1153{ 1153{
1154 return i18n("Note"); 1154 return i18n("Note");
1155} 1155}
1156 1156
1157 1157
1158void Addressee::setProductId( const QString &productId ) 1158void Addressee::setProductId( const QString &productId )
1159{ 1159{
1160 if ( productId == mData->productId ) return; 1160 if ( productId == mData->productId ) return;
1161 detach(); 1161 detach();
1162 mData->empty = false; 1162 mData->empty = false;
1163 mData->productId = productId; 1163 mData->productId = productId;
1164} 1164}
1165 1165
1166QString Addressee::productId() const 1166QString Addressee::productId() const
1167{ 1167{
1168 return mData->productId; 1168 return mData->productId;
1169} 1169}
1170 1170
1171QString Addressee::productIdLabel() 1171QString Addressee::productIdLabel()
1172{ 1172{
1173 return i18n("Product Identifier"); 1173 return i18n("Product Identifier");
1174} 1174}
1175 1175
1176 1176
1177void Addressee::setRevision( const QDateTime &revision ) 1177void Addressee::setRevision( const QDateTime &revision )
1178{ 1178{
1179 if ( revision == mData->revision ) return; 1179 if ( revision == mData->revision ) return;
1180 detach(); 1180 detach();
1181 mData->empty = false; 1181 mData->empty = false;
1182 mData->revision = QDateTime( revision.date(), 1182 mData->revision = QDateTime( revision.date(),
1183 QTime (revision.time().hour(), 1183 QTime (revision.time().hour(),
1184 revision.time().minute(), 1184 revision.time().minute(),
1185 revision.time().second())); 1185 revision.time().second()));
1186} 1186}
1187 1187
1188QDateTime Addressee::revision() const 1188QDateTime Addressee::revision() const
1189{ 1189{
1190 return mData->revision; 1190 return mData->revision;
1191} 1191}
1192 1192
1193QString Addressee::revisionLabel() 1193QString Addressee::revisionLabel()
1194{ 1194{
1195 return i18n("Revision Date"); 1195 return i18n("Revision Date");
1196} 1196}
1197 1197
1198 1198
1199void Addressee::setSortString( const QString &sortString ) 1199void Addressee::setSortString( const QString &sortString )
1200{ 1200{
1201 if ( sortString == mData->sortString ) return; 1201 if ( sortString == mData->sortString ) return;
1202 detach(); 1202 detach();
1203 mData->empty = false; 1203 mData->empty = false;
1204 mData->sortString = sortString; 1204 mData->sortString = sortString;
1205} 1205}
1206 1206
1207QString Addressee::sortString() const 1207QString Addressee::sortString() const
1208{ 1208{
1209 return mData->sortString; 1209 return mData->sortString;
1210} 1210}
1211 1211
1212QString Addressee::sortStringLabel() 1212QString Addressee::sortStringLabel()
1213{ 1213{
1214 return i18n("Sort String"); 1214 return i18n("Sort String");
1215} 1215}
1216 1216
1217 1217
1218void Addressee::setUrl( const KURL &url ) 1218void Addressee::setUrl( const KURL &url )
1219{ 1219{
1220 if ( url == mData->url ) return; 1220 if ( url == mData->url ) return;
1221 detach(); 1221 detach();
1222 mData->empty = false; 1222 mData->empty = false;
1223 mData->url = url; 1223 mData->url = url;
1224} 1224}
1225 1225
1226KURL Addressee::url() const 1226KURL Addressee::url() const
1227{ 1227{
1228 return mData->url; 1228 return mData->url;
1229} 1229}
1230 1230
1231QString Addressee::urlLabel() 1231QString Addressee::urlLabel()
1232{ 1232{
1233 return i18n("URL"); 1233 return i18n("URL");
1234} 1234}
1235 1235
1236 1236
1237void Addressee::setSecrecy( const Secrecy &secrecy ) 1237void Addressee::setSecrecy( const Secrecy &secrecy )
1238{ 1238{
1239 if ( secrecy == mData->secrecy ) return; 1239 if ( secrecy == mData->secrecy ) return;
1240 detach(); 1240 detach();
1241 mData->empty = false; 1241 mData->empty = false;
1242 mData->secrecy = secrecy; 1242 mData->secrecy = secrecy;
1243} 1243}
1244 1244
1245Secrecy Addressee::secrecy() const 1245Secrecy Addressee::secrecy() const
1246{ 1246{
1247 return mData->secrecy; 1247 return mData->secrecy;
1248} 1248}
1249 1249
1250QString Addressee::secrecyLabel() 1250QString Addressee::secrecyLabel()
1251{ 1251{
1252 return i18n("Security Class"); 1252 return i18n("Security Class");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setLogo( const Picture &logo ) 1256void Addressee::setLogo( const Picture &logo )
1257{ 1257{
1258 if ( logo == mData->logo ) return; 1258 if ( logo == mData->logo ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->logo = logo; 1261 mData->logo = logo;
1262} 1262}
1263 1263
1264Picture Addressee::logo() const 1264Picture Addressee::logo() const
1265{ 1265{
1266 return mData->logo; 1266 return mData->logo;
1267} 1267}
1268 1268
1269QString Addressee::logoLabel() 1269QString Addressee::logoLabel()
1270{ 1270{
1271 return i18n("Logo"); 1271 return i18n("Logo");
1272} 1272}
1273 1273
1274 1274
1275void Addressee::setPhoto( const Picture &photo ) 1275void Addressee::setPhoto( const Picture &photo )
1276{ 1276{
1277 if ( photo == mData->photo ) return; 1277 if ( photo == mData->photo ) return;
1278 detach(); 1278 detach();
1279 mData->empty = false; 1279 mData->empty = false;
1280 mData->photo = photo; 1280 mData->photo = photo;
1281} 1281}
1282 1282
1283Picture Addressee::photo() const 1283Picture Addressee::photo() const
1284{ 1284{
1285 return mData->photo; 1285 return mData->photo;
1286} 1286}
1287 1287
1288QString Addressee::photoLabel() 1288QString Addressee::photoLabel()
1289{ 1289{
1290 return i18n("Photo"); 1290 return i18n("Photo");
1291} 1291}
1292 1292
1293 1293
1294void Addressee::setSound( const Sound &sound ) 1294void Addressee::setSound( const Sound &sound )
1295{ 1295{
1296 if ( sound == mData->sound ) return; 1296 if ( sound == mData->sound ) return;
1297 detach(); 1297 detach();
1298 mData->empty = false; 1298 mData->empty = false;
1299 mData->sound = sound; 1299 mData->sound = sound;
1300} 1300}
1301 1301
1302Sound Addressee::sound() const 1302Sound Addressee::sound() const
1303{ 1303{
1304 return mData->sound; 1304 return mData->sound;
1305} 1305}
1306 1306
1307QString Addressee::soundLabel() 1307QString Addressee::soundLabel()
1308{ 1308{
1309 return i18n("Sound"); 1309 return i18n("Sound");
1310} 1310}
1311 1311
1312 1312
1313void Addressee::setAgent( const Agent &agent ) 1313void Addressee::setAgent( const Agent &agent )
1314{ 1314{
1315 if ( agent == mData->agent ) return; 1315 if ( agent == mData->agent ) return;
1316 detach(); 1316 detach();
1317 mData->empty = false; 1317 mData->empty = false;
1318 mData->agent = agent; 1318 mData->agent = agent;
1319} 1319}
1320 1320
1321Agent Addressee::agent() const 1321Agent Addressee::agent() const
1322{ 1322{
1323 return mData->agent; 1323 return mData->agent;
1324} 1324}
1325 1325
1326QString Addressee::agentLabel() 1326QString Addressee::agentLabel()
1327{ 1327{
1328 return i18n("Agent"); 1328 return i18n("Agent");
1329} 1329}
1330 1330
1331 1331
1332 1332
1333void Addressee::setNameFromString( const QString &str ) 1333void Addressee::setNameFromString( const QString &str )
1334{ 1334{
1335 setFormattedName( str ); 1335 setFormattedName( str );
1336 setName( str ); 1336 setName( str );
1337 1337
1338 static bool first = true; 1338 static bool first = true;
1339 static QStringList titles; 1339 static QStringList titles;
1340 static QStringList suffixes; 1340 static QStringList suffixes;
1341 static QStringList prefixes; 1341 static QStringList prefixes;
1342 1342
1343 if ( first ) { 1343 if ( first ) {
1344 first = false; 1344 first = false;
1345 titles += i18n( "Dr." ); 1345 titles += i18n( "Dr." );
1346 titles += i18n( "Miss" ); 1346 titles += i18n( "Miss" );
1347 titles += i18n( "Mr." ); 1347 titles += i18n( "Mr." );
1348 titles += i18n( "Mrs." ); 1348 titles += i18n( "Mrs." );
1349 titles += i18n( "Ms." ); 1349 titles += i18n( "Ms." );
1350 titles += i18n( "Prof." ); 1350 titles += i18n( "Prof." );
1351 1351
1352 suffixes += i18n( "I" ); 1352 suffixes += i18n( "I" );
1353 suffixes += i18n( "II" ); 1353 suffixes += i18n( "II" );
1354 suffixes += i18n( "III" ); 1354 suffixes += i18n( "III" );
1355 suffixes += i18n( "Jr." ); 1355 suffixes += i18n( "Jr." );
1356 suffixes += i18n( "Sr." ); 1356 suffixes += i18n( "Sr." );
1357 1357
1358 prefixes += "van"; 1358 prefixes += "van";
1359 prefixes += "von"; 1359 prefixes += "von";
1360 prefixes += "de"; 1360 prefixes += "de";
1361 1361
1362 KConfig config( locateLocal( "config", "kabcrc") ); 1362 KConfig config( locateLocal( "config", "kabcrc") );
1363 config.setGroup( "General" ); 1363 config.setGroup( "General" );
1364 titles += config.readListEntry( "Prefixes" ); 1364 titles += config.readListEntry( "Prefixes" );
1365 titles.remove( "" ); 1365 titles.remove( "" );
1366 prefixes += config.readListEntry( "Inclusions" ); 1366 prefixes += config.readListEntry( "Inclusions" );
1367 prefixes.remove( "" ); 1367 prefixes.remove( "" );
1368 suffixes += config.readListEntry( "Suffixes" ); 1368 suffixes += config.readListEntry( "Suffixes" );
1369 suffixes.remove( "" ); 1369 suffixes.remove( "" );
1370 } 1370 }
1371 1371
1372 // clear all name parts 1372 // clear all name parts
1373 setPrefix( "" ); 1373 setPrefix( "" );
1374 setGivenName( "" ); 1374 setGivenName( "" );
1375 setAdditionalName( "" ); 1375 setAdditionalName( "" );
1376 setFamilyName( "" ); 1376 setFamilyName( "" );
1377 setSuffix( "" ); 1377 setSuffix( "" );
1378 1378
1379 if ( str.isEmpty() ) 1379 if ( str.isEmpty() )
1380 return; 1380 return;
1381 1381
1382 int i = str.find(','); 1382 int i = str.find(',');
1383 if( i < 0 ) { 1383 if( i < 0 ) {
1384 QStringList parts = QStringList::split( " ", str ); 1384 QStringList parts = QStringList::split( " ", str );
1385 int leftOffset = 0; 1385 int leftOffset = 0;
1386 int rightOffset = parts.count() - 1; 1386 int rightOffset = parts.count() - 1;
1387 1387
1388 QString suffix; 1388 QString suffix;
1389 while ( rightOffset >= 0 ) { 1389 while ( rightOffset >= 0 ) {
1390 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1390 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1392 rightOffset--; 1392 rightOffset--;
1393 } else 1393 } else
1394 break; 1394 break;
1395 } 1395 }
1396 setSuffix( suffix ); 1396 setSuffix( suffix );
1397 1397
1398 if ( rightOffset < 0 ) 1398 if ( rightOffset < 0 )
1399 return; 1399 return;
1400 1400
1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1403 rightOffset--; 1403 rightOffset--;
1404 } else 1404 } else
1405 setFamilyName( parts[ rightOffset ] ); 1405 setFamilyName( parts[ rightOffset ] );
1406 1406
1407 QString prefix; 1407 QString prefix;
1408 while ( leftOffset < rightOffset ) { 1408 while ( leftOffset < rightOffset ) {
1409 if ( titles.contains( parts[ leftOffset ] ) ) { 1409 if ( titles.contains( parts[ leftOffset ] ) ) {
1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1411 leftOffset++; 1411 leftOffset++;
1412 } else 1412 } else
1413 break; 1413 break;
1414 } 1414 }
1415 setPrefix( prefix ); 1415 setPrefix( prefix );
1416 1416
1417 if ( leftOffset < rightOffset ) { 1417 if ( leftOffset < rightOffset ) {
1418 setGivenName( parts[ leftOffset ] ); 1418 setGivenName( parts[ leftOffset ] );
1419 leftOffset++; 1419 leftOffset++;
1420 } 1420 }
1421 1421
1422 QString additionalName; 1422 QString additionalName;
1423 while ( leftOffset < rightOffset ) { 1423 while ( leftOffset < rightOffset ) {
1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1425 leftOffset++; 1425 leftOffset++;
1426 } 1426 }
1427 setAdditionalName( additionalName ); 1427 setAdditionalName( additionalName );
1428 } else { 1428 } else {
1429 QString part1 = str.left( i ); 1429 QString part1 = str.left( i );
1430 QString part2 = str.mid( i + 1 ); 1430 QString part2 = str.mid( i + 1 );
1431 1431
1432 QStringList parts = QStringList::split( " ", part1 ); 1432 QStringList parts = QStringList::split( " ", part1 );
1433 int leftOffset = 0; 1433 int leftOffset = 0;
1434 int rightOffset = parts.count() - 1; 1434 int rightOffset = parts.count() - 1;
1435 1435
1436 QString suffix; 1436 QString suffix;
1437 while ( rightOffset >= 0 ) { 1437 while ( rightOffset >= 0 ) {
1438 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1438 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1440 rightOffset--; 1440 rightOffset--;
1441 } else 1441 } else
1442 break; 1442 break;
1443 } 1443 }
1444 setSuffix( suffix ); 1444 setSuffix( suffix );
1445 1445
1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1448 rightOffset--; 1448 rightOffset--;
1449 } else 1449 } else
1450 setFamilyName( parts[ rightOffset ] ); 1450 setFamilyName( parts[ rightOffset ] );
1451 1451
1452 QString prefix; 1452 QString prefix;
1453 while ( leftOffset < rightOffset ) { 1453 while ( leftOffset < rightOffset ) {
1454 if ( titles.contains( parts[ leftOffset ] ) ) { 1454 if ( titles.contains( parts[ leftOffset ] ) ) {
1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1456 leftOffset++; 1456 leftOffset++;
1457 } else 1457 } else
1458 break; 1458 break;
1459 } 1459 }
1460 1460
1461 parts = QStringList::split( " ", part2 ); 1461 parts = QStringList::split( " ", part2 );
1462 1462
1463 leftOffset = 0; 1463 leftOffset = 0;
1464 rightOffset = parts.count(); 1464 rightOffset = parts.count();
1465 1465
1466 while ( leftOffset < rightOffset ) { 1466 while ( leftOffset < rightOffset ) {
1467 if ( titles.contains( parts[ leftOffset ] ) ) { 1467 if ( titles.contains( parts[ leftOffset ] ) ) {
1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1469 leftOffset++; 1469 leftOffset++;
1470 } else 1470 } else
1471 break; 1471 break;
1472 } 1472 }
1473 setPrefix( prefix ); 1473 setPrefix( prefix );
1474 1474
1475 if ( leftOffset < rightOffset ) { 1475 if ( leftOffset < rightOffset ) {
1476 setGivenName( parts[ leftOffset ] ); 1476 setGivenName( parts[ leftOffset ] );
1477 leftOffset++; 1477 leftOffset++;
1478 } 1478 }
1479 1479
1480 QString additionalName; 1480 QString additionalName;
1481 while ( leftOffset < rightOffset ) { 1481 while ( leftOffset < rightOffset ) {
1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1483 leftOffset++; 1483 leftOffset++;
1484 } 1484 }
1485 setAdditionalName( additionalName ); 1485 setAdditionalName( additionalName );
1486 } 1486 }
1487} 1487}
1488 1488
1489QString Addressee::realName() const 1489QString Addressee::realName() const
1490{ 1490{
1491 if ( !formattedName().isEmpty() ) 1491 if ( !formattedName().isEmpty() )
1492 return formattedName(); 1492 return formattedName();
1493 1493
1494 QString n = assembledName(); 1494 QString n = assembledName();
1495 1495
1496 if ( n.isEmpty() ) 1496 if ( n.isEmpty() )
1497 n = name(); 1497 n = name();
1498 1498 if ( n.isEmpty() )
1499 n = organization();
1499 return n; 1500 return n;
1500} 1501}
1501 1502
1502QString Addressee::assembledName() const 1503QString Addressee::assembledName() const
1503{ 1504{
1504 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1505 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1505 familyName() + " " + suffix(); 1506 familyName() + " " + suffix();
1506 1507
1507 return name.simplifyWhiteSpace(); 1508 return name.simplifyWhiteSpace();
1508} 1509}
1509 1510
1510QString Addressee::fullEmail( const QString &email ) const 1511QString Addressee::fullEmail( const QString &email ) const
1511{ 1512{
1512 QString e; 1513 QString e;
1513 if ( email.isNull() ) { 1514 if ( email.isNull() ) {
1514 e = preferredEmail(); 1515 e = preferredEmail();
1515 } else { 1516 } else {
1516 e = email; 1517 e = email;
1517 } 1518 }
1518 if ( e.isEmpty() ) return QString::null; 1519 if ( e.isEmpty() ) return QString::null;
1519 1520
1520 QString text; 1521 QString text;
1521 if ( realName().isEmpty() ) 1522 if ( realName().isEmpty() )
1522 text = e; 1523 text = e;
1523 else 1524 else
1524 text = assembledName() + " <" + e + ">"; 1525 text = assembledName() + " <" + e + ">";
1525 1526
1526 return text; 1527 return text;
1527} 1528}
1528 1529
1529void Addressee::insertEmail( const QString &email, bool preferred ) 1530void Addressee::insertEmail( const QString &email, bool preferred )
1530{ 1531{
1531 detach(); 1532 detach();
1532 1533
1533 QStringList::Iterator it = mData->emails.find( email ); 1534 QStringList::Iterator it = mData->emails.find( email );
1534 1535
1535 if ( it != mData->emails.end() ) { 1536 if ( it != mData->emails.end() ) {
1536 if ( !preferred || it == mData->emails.begin() ) return; 1537 if ( !preferred || it == mData->emails.begin() ) return;
1537 mData->emails.remove( it ); 1538 mData->emails.remove( it );
1538 mData->emails.prepend( email ); 1539 mData->emails.prepend( email );
1539 } else { 1540 } else {
1540 if ( preferred ) { 1541 if ( preferred ) {
1541 mData->emails.prepend( email ); 1542 mData->emails.prepend( email );
1542 } else { 1543 } else {
1543 mData->emails.append( email ); 1544 mData->emails.append( email );
1544 } 1545 }
1545 } 1546 }
1546} 1547}
1547 1548
1548void Addressee::removeEmail( const QString &email ) 1549void Addressee::removeEmail( const QString &email )
1549{ 1550{
1550 detach(); 1551 detach();
1551 1552
1552 QStringList::Iterator it = mData->emails.find( email ); 1553 QStringList::Iterator it = mData->emails.find( email );
1553 if ( it == mData->emails.end() ) return; 1554 if ( it == mData->emails.end() ) return;
1554 1555
1555 mData->emails.remove( it ); 1556 mData->emails.remove( it );
1556} 1557}
1557 1558
1558QString Addressee::preferredEmail() const 1559QString Addressee::preferredEmail() const
1559{ 1560{
1560 if ( mData->emails.count() == 0 ) return QString::null; 1561 if ( mData->emails.count() == 0 ) return QString::null;
1561 else return mData->emails.first(); 1562 else return mData->emails.first();
1562} 1563}
1563 1564
1564QStringList Addressee::emails() const 1565QStringList Addressee::emails() const
1565{ 1566{
1566 return mData->emails; 1567 return mData->emails;
1567} 1568}
1568void Addressee::setEmails( const QStringList& emails ) { 1569void Addressee::setEmails( const QStringList& emails ) {
1569 detach(); 1570 detach();
1570 mData->emails = emails; 1571 mData->emails = emails;
1571} 1572}
1572void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1573void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1573{ 1574{
1574 detach(); 1575 detach();
1575 mData->empty = false; 1576 mData->empty = false;
1576 1577
1577 PhoneNumber::List::Iterator it; 1578 PhoneNumber::List::Iterator it;
1578 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1579 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1579 if ( (*it).id() == phoneNumber.id() ) { 1580 if ( (*it).id() == phoneNumber.id() ) {
1580 *it = phoneNumber; 1581 *it = phoneNumber;
1581 return; 1582 return;
1582 } 1583 }
1583 } 1584 }
1584 mData->phoneNumbers.append( phoneNumber ); 1585 mData->phoneNumbers.append( phoneNumber );
1585} 1586}
1586 1587
1587void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1588void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1588{ 1589{
1589 detach(); 1590 detach();
1590 1591
1591 PhoneNumber::List::Iterator it; 1592 PhoneNumber::List::Iterator it;
1592 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1593 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1593 if ( (*it).id() == phoneNumber.id() ) { 1594 if ( (*it).id() == phoneNumber.id() ) {
1594 mData->phoneNumbers.remove( it ); 1595 mData->phoneNumbers.remove( it );
1595 return; 1596 return;
1596 } 1597 }
1597 } 1598 }
1598} 1599}
1599 1600
1600PhoneNumber Addressee::phoneNumber( int type ) const 1601PhoneNumber Addressee::phoneNumber( int type ) const
1601{ 1602{
1602 PhoneNumber phoneNumber( "", type ); 1603 PhoneNumber phoneNumber( "", type );
1603 PhoneNumber::List::ConstIterator it; 1604 PhoneNumber::List::ConstIterator it;
1604 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1605 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1605 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1606 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1606 if ( (*it).type() & PhoneNumber::Pref ) 1607 if ( (*it).type() & PhoneNumber::Pref )
1607 return (*it); 1608 return (*it);
1608 else if ( phoneNumber.number().isEmpty() ) 1609 else if ( phoneNumber.number().isEmpty() )
1609 phoneNumber = (*it); 1610 phoneNumber = (*it);
1610 } 1611 }
1611 } 1612 }
1612 1613
1613 return phoneNumber; 1614 return phoneNumber;
1614} 1615}
1615 1616
1616PhoneNumber::List Addressee::phoneNumbers() const 1617PhoneNumber::List Addressee::phoneNumbers() const
1617{ 1618{
1618 return mData->phoneNumbers; 1619 return mData->phoneNumbers;
1619} 1620}
1620 1621
1621PhoneNumber::List Addressee::phoneNumbers( int type ) const 1622PhoneNumber::List Addressee::phoneNumbers( int type ) const
1622{ 1623{
1623 PhoneNumber::List list; 1624 PhoneNumber::List list;
1624 1625
1625 PhoneNumber::List::ConstIterator it; 1626 PhoneNumber::List::ConstIterator it;
1626 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1627 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1627 if ( matchBinaryPattern( (*it).type(), type ) ) { 1628 if ( matchBinaryPattern( (*it).type(), type ) ) {
1628 list.append( *it ); 1629 list.append( *it );
1629 } 1630 }
1630 } 1631 }
1631 return list; 1632 return list;
1632} 1633}
1633 1634
1634PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1635PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1635{ 1636{
1636 PhoneNumber::List::ConstIterator it; 1637 PhoneNumber::List::ConstIterator it;
1637 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1638 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1638 if ( (*it).id() == id ) { 1639 if ( (*it).id() == id ) {
1639 return *it; 1640 return *it;
1640 } 1641 }
1641 } 1642 }
1642 return PhoneNumber(); 1643 return PhoneNumber();
1643} 1644}
1644 1645
1645void Addressee::insertKey( const Key &key ) 1646void Addressee::insertKey( const Key &key )
1646{ 1647{
1647 detach(); 1648 detach();
1648 mData->empty = false; 1649 mData->empty = false;
1649 1650
1650 Key::List::Iterator it; 1651 Key::List::Iterator it;
1651 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1652 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1652 if ( (*it).id() == key.id() ) { 1653 if ( (*it).id() == key.id() ) {
1653 *it = key; 1654 *it = key;
1654 return; 1655 return;
1655 } 1656 }
1656 } 1657 }
1657 mData->keys.append( key ); 1658 mData->keys.append( key );
1658} 1659}
1659 1660
1660void Addressee::removeKey( const Key &key ) 1661void Addressee::removeKey( const Key &key )
1661{ 1662{
1662 detach(); 1663 detach();
1663 1664
1664 Key::List::Iterator it; 1665 Key::List::Iterator it;
1665 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1666 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1666 if ( (*it).id() == key.id() ) { 1667 if ( (*it).id() == key.id() ) {
1667 mData->keys.remove( key ); 1668 mData->keys.remove( key );
1668 return; 1669 return;
1669 } 1670 }
1670 } 1671 }
1671} 1672}
1672 1673
1673Key Addressee::key( int type, QString customTypeString ) const 1674Key Addressee::key( int type, QString customTypeString ) const
1674{ 1675{
1675 Key::List::ConstIterator it; 1676 Key::List::ConstIterator it;
1676 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1677 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1677 if ( (*it).type() == type ) { 1678 if ( (*it).type() == type ) {
1678 if ( type == Key::Custom ) { 1679 if ( type == Key::Custom ) {
1679 if ( customTypeString.isEmpty() ) { 1680 if ( customTypeString.isEmpty() ) {
1680 return *it; 1681 return *it;
1681 } else { 1682 } else {
1682 if ( (*it).customTypeString() == customTypeString ) 1683 if ( (*it).customTypeString() == customTypeString )
1683 return (*it); 1684 return (*it);
1684 } 1685 }
1685 } else { 1686 } else {
1686 return *it; 1687 return *it;
1687 } 1688 }
1688 } 1689 }
1689 } 1690 }
1690 return Key( QString(), type ); 1691 return Key( QString(), type );
1691} 1692}
1692void Addressee::setKeys( const Key::List& list ) { 1693void Addressee::setKeys( const Key::List& list ) {
1693 detach(); 1694 detach();
1694 mData->keys = list; 1695 mData->keys = list;
1695} 1696}
1696 1697
1697Key::List Addressee::keys() const 1698Key::List Addressee::keys() const
1698{ 1699{
1699 return mData->keys; 1700 return mData->keys;
1700} 1701}
1701 1702
1702Key::List Addressee::keys( int type, QString customTypeString ) const 1703Key::List Addressee::keys( int type, QString customTypeString ) const
1703{ 1704{
1704 Key::List list; 1705 Key::List list;
1705 1706
1706 Key::List::ConstIterator it; 1707 Key::List::ConstIterator it;
1707 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1708 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1708 if ( (*it).type() == type ) { 1709 if ( (*it).type() == type ) {
1709 if ( type == Key::Custom ) { 1710 if ( type == Key::Custom ) {
1710 if ( customTypeString.isEmpty() ) { 1711 if ( customTypeString.isEmpty() ) {
1711 list.append(*it); 1712 list.append(*it);
1712 } else { 1713 } else {
1713 if ( (*it).customTypeString() == customTypeString ) 1714 if ( (*it).customTypeString() == customTypeString )
1714 list.append(*it); 1715 list.append(*it);
1715 } 1716 }
1716 } else { 1717 } else {
1717 list.append(*it); 1718 list.append(*it);
1718 } 1719 }
1719 } 1720 }
1720 } 1721 }
1721 return list; 1722 return list;
1722} 1723}
1723 1724
1724Key Addressee::findKey( const QString &id ) const 1725Key Addressee::findKey( const QString &id ) const
1725{ 1726{
1726 Key::List::ConstIterator it; 1727 Key::List::ConstIterator it;
1727 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1728 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1728 if ( (*it).id() == id ) { 1729 if ( (*it).id() == id ) {
1729 return *it; 1730 return *it;
1730 } 1731 }
1731 } 1732 }
1732 return Key(); 1733 return Key();
1733} 1734}
1734 1735
1735QString Addressee::asString() const 1736QString Addressee::asString() const
1736{ 1737{
1737 return "Smith, agent Smith..."; 1738 return "Smith, agent Smith...";
1738} 1739}
1739 1740
1740void Addressee::dump() const 1741void Addressee::dump() const
1741{ 1742{
1742 return; 1743 return;
1743#if 0 1744#if 0
1744 kdDebug(5700) << "Addressee {" << endl; 1745 kdDebug(5700) << "Addressee {" << endl;
1745 1746
1746 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1747 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1747 1748
1748 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1749 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1749 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1750 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1750 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1751 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1751 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1752 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1752 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1753 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1753 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1754 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1754 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1755 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1755 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1756 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1756 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1757 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1757 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1758 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1758 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1759 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1759 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1760 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1760 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1761 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1761 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1762 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1762 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1763 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1763 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1764 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1764 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1765 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1765 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1766 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1766 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1767 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1767 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1768 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1768 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1769 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1769 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1770 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1770 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1771 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1771 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1772 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1772 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1773 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1773 1774
1774 kdDebug(5700) << " Emails {" << endl; 1775 kdDebug(5700) << " Emails {" << endl;
1775 QStringList e = emails(); 1776 QStringList e = emails();
1776 QStringList::ConstIterator it; 1777 QStringList::ConstIterator it;
1777 for( it = e.begin(); it != e.end(); ++it ) { 1778 for( it = e.begin(); it != e.end(); ++it ) {
1778 kdDebug(5700) << " " << (*it) << endl; 1779 kdDebug(5700) << " " << (*it) << endl;
1779 } 1780 }
1780 kdDebug(5700) << " }" << endl; 1781 kdDebug(5700) << " }" << endl;
1781 1782
1782 kdDebug(5700) << " PhoneNumbers {" << endl; 1783 kdDebug(5700) << " PhoneNumbers {" << endl;
1783 PhoneNumber::List p = phoneNumbers(); 1784 PhoneNumber::List p = phoneNumbers();
1784 PhoneNumber::List::ConstIterator it2; 1785 PhoneNumber::List::ConstIterator it2;
1785 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1786 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1786 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1787 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1787 } 1788 }
1788 kdDebug(5700) << " }" << endl; 1789 kdDebug(5700) << " }" << endl;
1789 1790
1790 Address::List a = addresses(); 1791 Address::List a = addresses();
1791 Address::List::ConstIterator it3; 1792 Address::List::ConstIterator it3;
1792 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1793 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1793 (*it3).dump(); 1794 (*it3).dump();
1794 } 1795 }
1795 1796
1796 kdDebug(5700) << " Keys {" << endl; 1797 kdDebug(5700) << " Keys {" << endl;
1797 Key::List k = keys(); 1798 Key::List k = keys();
1798 Key::List::ConstIterator it4; 1799 Key::List::ConstIterator it4;
1799 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1800 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1800 kdDebug(5700) << " Type: " << int((*it4).type()) << 1801 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1801 " Key: " << (*it4).textData() << 1802 " Key: " << (*it4).textData() <<
1802 " CustomString: " << (*it4).customTypeString() << endl; 1803 " CustomString: " << (*it4).customTypeString() << endl;
1803 } 1804 }
1804 kdDebug(5700) << " }" << endl; 1805 kdDebug(5700) << " }" << endl;
1805 1806
1806 kdDebug(5700) << "}" << endl; 1807 kdDebug(5700) << "}" << endl;
1807#endif 1808#endif
1808} 1809}
1809 1810
1810 1811
1811void Addressee::insertAddress( const Address &address ) 1812void Addressee::insertAddress( const Address &address )
1812{ 1813{
1813 detach(); 1814 detach();
1814 mData->empty = false; 1815 mData->empty = false;
1815 1816
1816 Address::List::Iterator it; 1817 Address::List::Iterator it;
1817 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1818 if ( (*it).id() == address.id() ) { 1819 if ( (*it).id() == address.id() ) {
1819 *it = address; 1820 *it = address;
1820 return; 1821 return;
1821 } 1822 }
1822 } 1823 }
1823 mData->addresses.append( address ); 1824 mData->addresses.append( address );
1824} 1825}
1825 1826
1826void Addressee::removeAddress( const Address &address ) 1827void Addressee::removeAddress( const Address &address )
1827{ 1828{
1828 detach(); 1829 detach();
1829 1830
1830 Address::List::Iterator it; 1831 Address::List::Iterator it;
1831 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1832 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1832 if ( (*it).id() == address.id() ) { 1833 if ( (*it).id() == address.id() ) {
1833 mData->addresses.remove( it ); 1834 mData->addresses.remove( it );
1834 return; 1835 return;
1835 } 1836 }
1836 } 1837 }
1837} 1838}
1838 1839
1839Address Addressee::address( int type ) const 1840Address Addressee::address( int type ) const
1840{ 1841{
1841 Address address( type ); 1842 Address address( type );
1842 Address::List::ConstIterator it; 1843 Address::List::ConstIterator it;
1843 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1844 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1844 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1845 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1845 if ( (*it).type() & Address::Pref ) 1846 if ( (*it).type() & Address::Pref )
1846 return (*it); 1847 return (*it);
1847 else if ( address.isEmpty() ) 1848 else if ( address.isEmpty() )
1848 address = (*it); 1849 address = (*it);
1849 } 1850 }
1850 } 1851 }
1851 1852
1852 return address; 1853 return address;
1853} 1854}
1854 1855
1855Address::List Addressee::addresses() const 1856Address::List Addressee::addresses() const
1856{ 1857{
1857 return mData->addresses; 1858 return mData->addresses;
1858} 1859}
1859 1860
1860Address::List Addressee::addresses( int type ) const 1861Address::List Addressee::addresses( int type ) const
1861{ 1862{
1862 Address::List list; 1863 Address::List list;
1863 1864
1864 Address::List::ConstIterator it; 1865 Address::List::ConstIterator it;
1865 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1866 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1866 if ( matchBinaryPattern( (*it).type(), type ) ) { 1867 if ( matchBinaryPattern( (*it).type(), type ) ) {
1867 list.append( *it ); 1868 list.append( *it );
1868 } 1869 }
1869 } 1870 }
1870 1871
1871 return list; 1872 return list;
1872} 1873}
1873 1874
1874Address Addressee::findAddress( const QString &id ) const 1875Address Addressee::findAddress( const QString &id ) const
1875{ 1876{
1876 Address::List::ConstIterator it; 1877 Address::List::ConstIterator it;
1877 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1878 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1878 if ( (*it).id() == id ) { 1879 if ( (*it).id() == id ) {
1879 return *it; 1880 return *it;
1880 } 1881 }
1881 } 1882 }
1882 return Address(); 1883 return Address();
1883} 1884}
1884 1885
1885void Addressee::insertCategory( const QString &c ) 1886void Addressee::insertCategory( const QString &c )
1886{ 1887{
1887 detach(); 1888 detach();
1888 mData->empty = false; 1889 mData->empty = false;
1889 1890
1890 if ( mData->categories.contains( c ) ) return; 1891 if ( mData->categories.contains( c ) ) return;
1891 1892
1892 mData->categories.append( c ); 1893 mData->categories.append( c );
1893} 1894}
1894 1895
1895void Addressee::removeCategory( const QString &c ) 1896void Addressee::removeCategory( const QString &c )
1896{ 1897{
1897 detach(); 1898 detach();
1898 1899
1899 QStringList::Iterator it = mData->categories.find( c ); 1900 QStringList::Iterator it = mData->categories.find( c );
1900 if ( it == mData->categories.end() ) return; 1901 if ( it == mData->categories.end() ) return;
1901 1902
1902 mData->categories.remove( it ); 1903 mData->categories.remove( it );
1903} 1904}
1904 1905
1905bool Addressee::hasCategory( const QString &c ) const 1906bool Addressee::hasCategory( const QString &c ) const
1906{ 1907{
1907 return ( mData->categories.contains( c ) ); 1908 return ( mData->categories.contains( c ) );
1908} 1909}
1909 1910
1910void Addressee::setCategories( const QStringList &c ) 1911void Addressee::setCategories( const QStringList &c )
1911{ 1912{
1912 detach(); 1913 detach();
1913 mData->empty = false; 1914 mData->empty = false;
1914 1915
1915 mData->categories = c; 1916 mData->categories = c;
1916} 1917}
1917 1918
1918QStringList Addressee::categories() const 1919QStringList Addressee::categories() const
1919{ 1920{
1920 return mData->categories; 1921 return mData->categories;
1921} 1922}
1922 1923
1923void Addressee::insertCustom( const QString &app, const QString &name, 1924void Addressee::insertCustom( const QString &app, const QString &name,
1924 const QString &value ) 1925 const QString &value )
1925{ 1926{
1926 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1927 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1927 1928
1928 detach(); 1929 detach();
1929 mData->empty = false; 1930 mData->empty = false;
1930 1931
1931 QString qualifiedName = app + "-" + name + ":"; 1932 QString qualifiedName = app + "-" + name + ":";
1932 1933
1933 QStringList::Iterator it; 1934 QStringList::Iterator it;
1934 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1935 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1935 if ( (*it).startsWith( qualifiedName ) ) { 1936 if ( (*it).startsWith( qualifiedName ) ) {
1936 (*it) = qualifiedName + value; 1937 (*it) = qualifiedName + value;
1937 return; 1938 return;
1938 } 1939 }
1939 } 1940 }
1940 mData->custom.append( qualifiedName + value ); 1941 mData->custom.append( qualifiedName + value );
1941} 1942}
1942 1943
1943void Addressee::removeCustom( const QString &app, const QString &name) 1944void Addressee::removeCustom( const QString &app, const QString &name)
1944{ 1945{
1945 detach(); 1946 detach();
1946 1947
1947 QString qualifiedName = app + "-" + name + ":"; 1948 QString qualifiedName = app + "-" + name + ":";
1948 1949
1949 QStringList::Iterator it; 1950 QStringList::Iterator it;
1950 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1951 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1951 if ( (*it).startsWith( qualifiedName ) ) { 1952 if ( (*it).startsWith( qualifiedName ) ) {
1952 mData->custom.remove( it ); 1953 mData->custom.remove( it );
1953 return; 1954 return;
1954 } 1955 }
1955 } 1956 }
1956} 1957}
1957 1958
1958QString Addressee::custom( const QString &app, const QString &name ) const 1959QString Addressee::custom( const QString &app, const QString &name ) const
1959{ 1960{
1960 QString qualifiedName = app + "-" + name + ":"; 1961 QString qualifiedName = app + "-" + name + ":";
1961 QString value; 1962 QString value;
1962 1963
1963 QStringList::ConstIterator it; 1964 QStringList::ConstIterator it;
1964 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1965 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1965 if ( (*it).startsWith( qualifiedName ) ) { 1966 if ( (*it).startsWith( qualifiedName ) ) {
1966 value = (*it).mid( (*it).find( ":" ) + 1 ); 1967 value = (*it).mid( (*it).find( ":" ) + 1 );
1967 break; 1968 break;
1968 } 1969 }
1969 } 1970 }
1970 1971
1971 return value; 1972 return value;
1972} 1973}
1973 1974
1974void Addressee::setCustoms( const QStringList &l ) 1975void Addressee::setCustoms( const QStringList &l )
1975{ 1976{
1976 detach(); 1977 detach();
1977 mData->empty = false; 1978 mData->empty = false;
1978 1979
1979 mData->custom = l; 1980 mData->custom = l;
1980} 1981}
1981 1982
1982QStringList Addressee::customs() const 1983QStringList Addressee::customs() const
1983{ 1984{
1984 return mData->custom; 1985 return mData->custom;
1985} 1986}
1986 1987
1987void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1988void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1988 QString &email) 1989 QString &email)
1989{ 1990{
1990 int startPos, endPos, len; 1991 int startPos, endPos, len;
1991 QString partA, partB, result; 1992 QString partA, partB, result;
1992 char endCh = '>'; 1993 char endCh = '>';
1993 1994
1994 startPos = rawEmail.find('<'); 1995 startPos = rawEmail.find('<');
1995 if (startPos < 0) 1996 if (startPos < 0)
1996 { 1997 {
1997 startPos = rawEmail.find('('); 1998 startPos = rawEmail.find('(');
1998 endCh = ')'; 1999 endCh = ')';
1999 } 2000 }
2000 if (startPos < 0) 2001 if (startPos < 0)
2001 { 2002 {
2002 // We couldn't find any separators, so we assume the whole string 2003 // We couldn't find any separators, so we assume the whole string
2003 // is the email address 2004 // is the email address
2004 email = rawEmail; 2005 email = rawEmail;
2005 fullName = ""; 2006 fullName = "";
2006 } 2007 }
2007 else 2008 else
2008 { 2009 {
2009 // We have a start position, try to find an end 2010 // We have a start position, try to find an end
2010 endPos = rawEmail.find(endCh, startPos+1); 2011 endPos = rawEmail.find(endCh, startPos+1);
2011 2012
2012 if (endPos < 0) 2013 if (endPos < 0)
2013 { 2014 {
2014 // We couldn't find the end of the email address. We can only 2015 // We couldn't find the end of the email address. We can only
2015 // assume the entire string is the email address. 2016 // assume the entire string is the email address.
2016 email = rawEmail; 2017 email = rawEmail;
2017 fullName = ""; 2018 fullName = "";
2018 } 2019 }
2019 else 2020 else
2020 { 2021 {
2021 // We have a start and end to the email address 2022 // We have a start and end to the email address
2022 2023
2023 // Grab the name part 2024 // Grab the name part
2024 fullName = rawEmail.left(startPos).stripWhiteSpace(); 2025 fullName = rawEmail.left(startPos).stripWhiteSpace();
2025 2026
2026 // grab the email part 2027 // grab the email part
2027 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 2028 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
2028 2029
2029 // Check that we do not have any extra characters on the end of the 2030 // Check that we do not have any extra characters on the end of the
2030 // strings 2031 // strings
2031 len = fullName.length(); 2032 len = fullName.length();
2032 if (fullName[0]=='"' && fullName[len-1]=='"') 2033 if (fullName[0]=='"' && fullName[len-1]=='"')
2033 fullName = fullName.mid(1, len-2); 2034 fullName = fullName.mid(1, len-2);
2034 else if (fullName[0]=='<' && fullName[len-1]=='>') 2035 else if (fullName[0]=='<' && fullName[len-1]=='>')
2035 fullName = fullName.mid(1, len-2); 2036 fullName = fullName.mid(1, len-2);
2036 else if (fullName[0]=='(' && fullName[len-1]==')') 2037 else if (fullName[0]=='(' && fullName[len-1]==')')
2037 fullName = fullName.mid(1, len-2); 2038 fullName = fullName.mid(1, len-2);
2038 } 2039 }
2039 } 2040 }
2040} 2041}
2041 2042
2042void Addressee::setResource( Resource *resource ) 2043void Addressee::setResource( Resource *resource )
2043{ 2044{
2044 detach(); 2045 detach();
2045 mData->resource = resource; 2046 mData->resource = resource;
2046} 2047}
2047 2048
2048Resource *Addressee::resource() const 2049Resource *Addressee::resource() const
2049{ 2050{
2050 return mData->resource; 2051 return mData->resource;
2051} 2052}
2052 2053
2053//US 2054//US
2054QString Addressee::resourceLabel() 2055QString Addressee::resourceLabel()
2055{ 2056{
2056 return i18n("Resource"); 2057 return i18n("Resource");
2057} 2058}
2058QString Addressee::categoryLabel() 2059QString Addressee::categoryLabel()
2059{ 2060{
2060 return i18n("Category"); 2061 return i18n("Category");
2061} 2062}
2062 2063
2063void Addressee::setChanged( bool value ) 2064void Addressee::setChanged( bool value )
2064{ 2065{
2065 detach(); 2066 detach();
2066 mData->changed = value; 2067 mData->changed = value;
2067} 2068}
2068 2069
2069bool Addressee::changed() const 2070bool Addressee::changed() const
2070{ 2071{
2071 return mData->changed; 2072 return mData->changed;
2072} 2073}
2073 2074
2074void Addressee::setTagged( bool value ) 2075void Addressee::setTagged( bool value )
2075{ 2076{
2076 detach(); 2077 detach();
2077 mData->tagged = value; 2078 mData->tagged = value;
2078} 2079}
2079 2080
2080bool Addressee::tagged() const 2081bool Addressee::tagged() const
2081{ 2082{
2082 return mData->tagged; 2083 return mData->tagged;
2083} 2084}
2084 2085
2085QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2086QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2086{ 2087{
2087 if (!a.mData) return s; 2088 if (!a.mData) return s;
2088 2089
2089 s << a.uid(); 2090 s << a.uid();
2090 2091
2091 s << a.mData->name; 2092 s << a.mData->name;
2092 s << a.mData->formattedName; 2093 s << a.mData->formattedName;
2093 s << a.mData->familyName; 2094 s << a.mData->familyName;
2094 s << a.mData->givenName; 2095 s << a.mData->givenName;
2095 s << a.mData->additionalName; 2096 s << a.mData->additionalName;
2096 s << a.mData->prefix; 2097 s << a.mData->prefix;
2097 s << a.mData->suffix; 2098 s << a.mData->suffix;
2098 s << a.mData->nickName; 2099 s << a.mData->nickName;
2099 s << a.mData->birthday; 2100 s << a.mData->birthday;
2100 s << a.mData->mailer; 2101 s << a.mData->mailer;
2101 s << a.mData->timeZone; 2102 s << a.mData->timeZone;
2102 s << a.mData->geo; 2103 s << a.mData->geo;
2103 s << a.mData->title; 2104 s << a.mData->title;
2104 s << a.mData->role; 2105 s << a.mData->role;
2105 s << a.mData->organization; 2106 s << a.mData->organization;
2106 s << a.mData->note; 2107 s << a.mData->note;
2107 s << a.mData->productId; 2108 s << a.mData->productId;
2108 s << a.mData->revision; 2109 s << a.mData->revision;
2109 s << a.mData->sortString; 2110 s << a.mData->sortString;
2110 s << a.mData->url; 2111 s << a.mData->url;
2111 s << a.mData->secrecy; 2112 s << a.mData->secrecy;
2112 s << a.mData->logo; 2113 s << a.mData->logo;
2113 s << a.mData->photo; 2114 s << a.mData->photo;
2114 s << a.mData->sound; 2115 s << a.mData->sound;
2115 s << a.mData->agent; 2116 s << a.mData->agent;
2116 s << a.mData->phoneNumbers; 2117 s << a.mData->phoneNumbers;
2117 s << a.mData->addresses; 2118 s << a.mData->addresses;
2118 s << a.mData->emails; 2119 s << a.mData->emails;
2119 s << a.mData->categories; 2120 s << a.mData->categories;
2120 s << a.mData->custom; 2121 s << a.mData->custom;
2121 s << a.mData->keys; 2122 s << a.mData->keys;
2122 return s; 2123 return s;
2123} 2124}
2124 2125
2125QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2126QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2126{ 2127{
2127 if (!a.mData) return s; 2128 if (!a.mData) return s;
2128 2129
2129 s >> a.mData->uid; 2130 s >> a.mData->uid;
2130 2131
2131 s >> a.mData->name; 2132 s >> a.mData->name;
2132 s >> a.mData->formattedName; 2133 s >> a.mData->formattedName;
2133 s >> a.mData->familyName; 2134 s >> a.mData->familyName;
2134 s >> a.mData->givenName; 2135 s >> a.mData->givenName;
2135 s >> a.mData->additionalName; 2136 s >> a.mData->additionalName;
2136 s >> a.mData->prefix; 2137 s >> a.mData->prefix;
2137 s >> a.mData->suffix; 2138 s >> a.mData->suffix;
2138 s >> a.mData->nickName; 2139 s >> a.mData->nickName;
2139 s >> a.mData->birthday; 2140 s >> a.mData->birthday;
2140 s >> a.mData->mailer; 2141 s >> a.mData->mailer;
2141 s >> a.mData->timeZone; 2142 s >> a.mData->timeZone;
2142 s >> a.mData->geo; 2143 s >> a.mData->geo;
2143 s >> a.mData->title; 2144 s >> a.mData->title;
2144 s >> a.mData->role; 2145 s >> a.mData->role;
2145 s >> a.mData->organization; 2146 s >> a.mData->organization;
2146 s >> a.mData->note; 2147 s >> a.mData->note;
2147 s >> a.mData->productId; 2148 s >> a.mData->productId;
2148 s >> a.mData->revision; 2149 s >> a.mData->revision;
2149 s >> a.mData->sortString; 2150 s >> a.mData->sortString;
2150 s >> a.mData->url; 2151 s >> a.mData->url;
2151 s >> a.mData->secrecy; 2152 s >> a.mData->secrecy;
2152 s >> a.mData->logo; 2153 s >> a.mData->logo;
2153 s >> a.mData->photo; 2154 s >> a.mData->photo;
2154 s >> a.mData->sound; 2155 s >> a.mData->sound;
2155 s >> a.mData->agent; 2156 s >> a.mData->agent;
2156 s >> a.mData->phoneNumbers; 2157 s >> a.mData->phoneNumbers;
2157 s >> a.mData->addresses; 2158 s >> a.mData->addresses;
2158 s >> a.mData->emails; 2159 s >> a.mData->emails;
2159 s >> a.mData->categories; 2160 s >> a.mData->categories;
2160 s >> a.mData->custom; 2161 s >> a.mData->custom;
2161 s >> a.mData->keys; 2162 s >> a.mData->keys;
2162 2163
2163 a.mData->empty = false; 2164 a.mData->empty = false;
2164 2165
2165 return s; 2166 return s;
2166} 2167}
2167bool matchBinaryPattern( int value, int pattern ) 2168bool matchBinaryPattern( int value, int pattern )
2168{ 2169{
2169 /** 2170 /**
2170 We want to match all telephonnumbers/addresses which have the bits in the 2171 We want to match all telephonnumbers/addresses which have the bits in the
2171 pattern set. More are allowed. 2172 pattern set. More are allowed.
2172 if pattern == 0 we have a special handling, then we want only those with 2173 if pattern == 0 we have a special handling, then we want only those with
2173 exactly no bit set. 2174 exactly no bit set.
2174 */ 2175 */
2175 if ( pattern == 0 ) 2176 if ( pattern == 0 )
2176 return ( value == 0 ); 2177 return ( value == 0 );
2177 else 2178 else
2178 return ( pattern == ( pattern & value ) ); 2179 return ( pattern == ( pattern & value ) );
2179} 2180}
2180 2181
2181bool matchBinaryPatternP( int value, int pattern ) 2182bool matchBinaryPatternP( int value, int pattern )
2182{ 2183{
2183 2184
2184 if ( pattern == 0 ) 2185 if ( pattern == 0 )
2185 return ( value == 0 ); 2186 return ( value == 0 );
2186 else 2187 else
2187 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2188 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2188} 2189}
2189bool matchBinaryPatternA( int value, int pattern ) 2190bool matchBinaryPatternA( int value, int pattern )
2190{ 2191{
2191 2192
2192 if ( pattern == 0 ) 2193 if ( pattern == 0 )
2193 return ( value == 0 ); 2194 return ( value == 0 );
2194 else 2195 else
2195 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2196 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2196} 2197}