-rw-r--r-- | kabc/addressee.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 0d8e8e8..2f4a9af 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -546,1054 +546,1044 @@ void Addressee::simplifyAddresses() | |||
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 |
581 | void Addressee::simplifyEmails() | 581 | void 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 | } |
589 | void Addressee::makePhoneNumbersOLcompatible() | 589 | void 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 | } |
642 | void Addressee::simplifyPhoneNumbers() | 642 | void 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 | } |
691 | void Addressee::simplifyPhoneNumberTypes() | 691 | void 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 | } |
698 | void Addressee::removeID(const QString &prof) | 698 | void 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 | } |
707 | void Addressee::setID( const QString & prof , const QString & id ) | 707 | void 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 | } |
713 | void Addressee::setTempSyncStat( int id ) | 713 | void 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 | } |
719 | int Addressee::tempSyncStat() const | 719 | int Addressee::tempSyncStat() const |
720 | { | 720 | { |
721 | return mData->mTempSyncStat; | 721 | return mData->mTempSyncStat; |
722 | } | 722 | } |
723 | 723 | ||
724 | const QString Addressee::getID( const QString & prof) const | 724 | const 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 | ||
729 | void Addressee::setCsum( const QString & prof , const QString & id ) | 729 | void 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 | ||
737 | const QString Addressee::getCsum( const QString & prof) const | 737 | const 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 | ||
742 | void Addressee::setIDStr( const QString & s ) | 742 | void Addressee::setIDStr( const QString & s ) |
743 | { | 743 | { |
744 | detach(); | 744 | detach(); |
745 | mData->mExternalId = s; | 745 | mData->mExternalId = s; |
746 | } | 746 | } |
747 | 747 | ||
748 | const QString Addressee::IDStr() const | 748 | const QString Addressee::IDStr() const |
749 | { | 749 | { |
750 | return mData->mExternalId; | 750 | return mData->mExternalId; |
751 | } | 751 | } |
752 | 752 | ||
753 | void Addressee::setExternalUID( const QString &id ) | 753 | void 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 | ||
761 | const QString Addressee::externalUID() const | 761 | const QString Addressee::externalUID() const |
762 | { | 762 | { |
763 | return mData->externalUID; | 763 | return mData->externalUID; |
764 | } | 764 | } |
765 | void Addressee::setOriginalExternalUID( const QString &id ) | 765 | void 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 | ||
774 | QString Addressee::originalExternalUID() const | 774 | QString Addressee::originalExternalUID() const |
775 | { | 775 | { |
776 | return mData->originalExternalUID; | 776 | return mData->originalExternalUID; |
777 | } | 777 | } |
778 | 778 | ||
779 | void Addressee::setUid( const QString &id ) | 779 | void 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 | ||
788 | const QString Addressee::uid() const | 788 | const 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 | ||
796 | QString Addressee::uidLabel() | 796 | QString Addressee::uidLabel() |
797 | { | 797 | { |
798 | return i18n("Unique Identifier"); | 798 | return i18n("Unique Identifier"); |
799 | } | 799 | } |
800 | 800 | ||
801 | void Addressee::setName( const QString &name ) | 801 | void 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 | ||
809 | QString Addressee::name() const | 809 | QString Addressee::name() const |
810 | { | 810 | { |
811 | return mData->name; | 811 | return mData->name; |
812 | } | 812 | } |
813 | 813 | ||
814 | QString Addressee::nameLabel() | 814 | QString Addressee::nameLabel() |
815 | { | 815 | { |
816 | return i18n("Name"); | 816 | return i18n("Name"); |
817 | } | 817 | } |
818 | 818 | ||
819 | 819 | ||
820 | void Addressee::setFormattedName( const QString &formattedName ) | 820 | void 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 | ||
828 | QString Addressee::formattedName() const | 828 | QString Addressee::formattedName() const |
829 | { | 829 | { |
830 | return mData->formattedName; | 830 | return mData->formattedName; |
831 | } | 831 | } |
832 | 832 | ||
833 | QString Addressee::formattedNameLabel() | 833 | QString Addressee::formattedNameLabel() |
834 | { | 834 | { |
835 | return i18n("Formatted Name"); | 835 | return i18n("Formatted Name"); |
836 | } | 836 | } |
837 | 837 | ||
838 | 838 | ||
839 | void Addressee::setFamilyName( const QString &familyName ) | 839 | void 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 | ||
847 | QString Addressee::familyName() const | 847 | QString Addressee::familyName() const |
848 | { | 848 | { |
849 | return mData->familyName; | 849 | return mData->familyName; |
850 | } | 850 | } |
851 | 851 | ||
852 | QString Addressee::familyNameLabel() | 852 | QString Addressee::familyNameLabel() |
853 | { | 853 | { |
854 | return i18n("Family Name"); | 854 | return i18n("Family Name"); |
855 | } | 855 | } |
856 | 856 | ||
857 | 857 | ||
858 | void Addressee::setGivenName( const QString &givenName ) | 858 | void 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 | ||
866 | QString Addressee::givenName() const | 866 | QString Addressee::givenName() const |
867 | { | 867 | { |
868 | return mData->givenName; | 868 | return mData->givenName; |
869 | } | 869 | } |
870 | 870 | ||
871 | QString Addressee::givenNameLabel() | 871 | QString Addressee::givenNameLabel() |
872 | { | 872 | { |
873 | return i18n("Given Name"); | 873 | return i18n("Given Name"); |
874 | } | 874 | } |
875 | 875 | ||
876 | 876 | ||
877 | void Addressee::setAdditionalName( const QString &additionalName ) | 877 | void 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 | ||
885 | QString Addressee::additionalName() const | 885 | QString Addressee::additionalName() const |
886 | { | 886 | { |
887 | return mData->additionalName; | 887 | return mData->additionalName; |
888 | } | 888 | } |
889 | 889 | ||
890 | QString Addressee::additionalNameLabel() | 890 | QString Addressee::additionalNameLabel() |
891 | { | 891 | { |
892 | return i18n("Additional Names"); | 892 | return i18n("Additional Names"); |
893 | } | 893 | } |
894 | 894 | ||
895 | 895 | ||
896 | void Addressee::setPrefix( const QString &prefix ) | 896 | void 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 | ||
904 | QString Addressee::prefix() const | 904 | QString Addressee::prefix() const |
905 | { | 905 | { |
906 | return mData->prefix; | 906 | return mData->prefix; |
907 | } | 907 | } |
908 | 908 | ||
909 | QString Addressee::prefixLabel() | 909 | QString Addressee::prefixLabel() |
910 | { | 910 | { |
911 | return i18n("Honorific Prefixes"); | 911 | return i18n("Honorific Prefixes"); |
912 | } | 912 | } |
913 | 913 | ||
914 | 914 | ||
915 | void Addressee::setSuffix( const QString &suffix ) | 915 | void 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 | ||
923 | QString Addressee::suffix() const | 923 | QString Addressee::suffix() const |
924 | { | 924 | { |
925 | return mData->suffix; | 925 | return mData->suffix; |
926 | } | 926 | } |
927 | 927 | ||
928 | QString Addressee::suffixLabel() | 928 | QString Addressee::suffixLabel() |
929 | { | 929 | { |
930 | return i18n("Honorific Suffixes"); | 930 | return i18n("Honorific Suffixes"); |
931 | } | 931 | } |
932 | 932 | ||
933 | 933 | ||
934 | void Addressee::setNickName( const QString &nickName ) | 934 | void 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 | ||
942 | QString Addressee::nickName() const | 942 | QString Addressee::nickName() const |
943 | { | 943 | { |
944 | return mData->nickName; | 944 | return mData->nickName; |
945 | } | 945 | } |
946 | 946 | ||
947 | QString Addressee::nickNameLabel() | 947 | QString Addressee::nickNameLabel() |
948 | { | 948 | { |
949 | return i18n("Nick Name"); | 949 | return i18n("Nick Name"); |
950 | } | 950 | } |
951 | 951 | ||
952 | 952 | ||
953 | void Addressee::setBirthday( const QDateTime &birthday ) | 953 | void 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 | ||
961 | QDateTime Addressee::birthday() const | 961 | QDateTime Addressee::birthday() const |
962 | { | 962 | { |
963 | return mData->birthday; | 963 | return mData->birthday; |
964 | } | 964 | } |
965 | 965 | ||
966 | QString Addressee::birthdayLabel() | 966 | QString Addressee::birthdayLabel() |
967 | { | 967 | { |
968 | return i18n("Birthday"); | 968 | return i18n("Birthday"); |
969 | } | 969 | } |
970 | 970 | ||
971 | 971 | ||
972 | QString Addressee::homeAddressStreetLabel() | 972 | QString Addressee::homeAddressStreetLabel() |
973 | { | 973 | { |
974 | return i18n("Home Address Street"); | 974 | return i18n("Home Address Street"); |
975 | } | 975 | } |
976 | 976 | ||
977 | 977 | ||
978 | QString Addressee::homeAddressLocalityLabel() | 978 | QString Addressee::homeAddressLocalityLabel() |
979 | { | 979 | { |
980 | return i18n("Home Address Locality"); | 980 | return i18n("Home Address Locality"); |
981 | } | 981 | } |
982 | 982 | ||
983 | 983 | ||
984 | QString Addressee::homeAddressRegionLabel() | 984 | QString Addressee::homeAddressRegionLabel() |
985 | { | 985 | { |
986 | return i18n("Home Address Region"); | 986 | return i18n("Home Address Region"); |
987 | } | 987 | } |
988 | 988 | ||
989 | 989 | ||
990 | QString Addressee::homeAddressPostalCodeLabel() | 990 | QString Addressee::homeAddressPostalCodeLabel() |
991 | { | 991 | { |
992 | return i18n("Home Address Postal Code"); | 992 | return i18n("Home Address Postal Code"); |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | QString Addressee::homeAddressCountryLabel() | 996 | QString Addressee::homeAddressCountryLabel() |
997 | { | 997 | { |
998 | return i18n("Home Address Country"); | 998 | return i18n("Home Address Country"); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | 1001 | ||
1002 | QString Addressee::homeAddressLabelLabel() | 1002 | QString Addressee::homeAddressLabelLabel() |
1003 | { | 1003 | { |
1004 | return i18n("Home Address Label"); | 1004 | return i18n("Home Address Label"); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | 1007 | ||
1008 | QString Addressee::businessAddressStreetLabel() | 1008 | QString Addressee::businessAddressStreetLabel() |
1009 | { | 1009 | { |
1010 | return i18n("Business Address Street"); | 1010 | return i18n("Business Address Street"); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | 1013 | ||
1014 | QString Addressee::businessAddressLocalityLabel() | 1014 | QString Addressee::businessAddressLocalityLabel() |
1015 | { | 1015 | { |
1016 | return i18n("Business Address Locality"); | 1016 | return i18n("Business Address Locality"); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | 1019 | ||
1020 | QString Addressee::businessAddressRegionLabel() | 1020 | QString Addressee::businessAddressRegionLabel() |
1021 | { | 1021 | { |
1022 | return i18n("Business Address Region"); | 1022 | return i18n("Business Address Region"); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | 1025 | ||
1026 | QString Addressee::businessAddressPostalCodeLabel() | 1026 | QString Addressee::businessAddressPostalCodeLabel() |
1027 | { | 1027 | { |
1028 | return i18n("Business Address Postal Code"); | 1028 | return i18n("Business Address Postal Code"); |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | 1031 | ||
1032 | QString Addressee::businessAddressCountryLabel() | 1032 | QString Addressee::businessAddressCountryLabel() |
1033 | { | 1033 | { |
1034 | return i18n("Business Address Country"); | 1034 | return i18n("Business Address Country"); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | 1037 | ||
1038 | QString Addressee::businessAddressLabelLabel() | 1038 | QString Addressee::businessAddressLabelLabel() |
1039 | { | 1039 | { |
1040 | return i18n("Business Address Label"); | 1040 | return i18n("Business Address Label"); |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | 1043 | ||
1044 | QString Addressee::homePhoneLabel() | 1044 | QString Addressee::homePhoneLabel() |
1045 | { | 1045 | { |
1046 | return i18n("Home Phone"); | 1046 | return i18n("Home Phone"); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | 1049 | ||
1050 | QString Addressee::businessPhoneLabel() | 1050 | QString Addressee::businessPhoneLabel() |
1051 | { | 1051 | { |
1052 | return i18n("Work Phone"); | 1052 | return i18n("Work Phone"); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | 1055 | ||
1056 | QString Addressee::mobilePhoneLabel() | 1056 | QString Addressee::mobilePhoneLabel() |
1057 | { | 1057 | { |
1058 | return i18n("Mobile Phone"); | 1058 | return i18n("Mobile"); |
1059 | } | 1059 | } |
1060 | QString Addressee::mobileWorkPhoneLabel() | 1060 | QString Addressee::mobileWorkPhoneLabel() |
1061 | { | 1061 | { |
1062 | return i18n("Mobile2 (Work)"); | 1062 | return i18n("Mobile2"); |
1063 | } | ||
1064 | QString Addressee::mobileHomePhoneLabel() | ||
1065 | { | ||
1066 | return i18n("Mobile (Home)"); | ||
1067 | } | 1063 | } |
1068 | 1064 | ||
1069 | 1065 | ||
1070 | QString Addressee::homeFaxLabel() | 1066 | QString Addressee::homeFaxLabel() |
1071 | { | 1067 | { |
1072 | return i18n("Fax (Home)"); | 1068 | return i18n("Fax (Home)"); |
1073 | } | 1069 | } |
1074 | 1070 | ||
1075 | 1071 | ||
1076 | QString Addressee::businessFaxLabel() | 1072 | QString Addressee::businessFaxLabel() |
1077 | { | 1073 | { |
1078 | return i18n("Fax (Work)"); | 1074 | return i18n("Fax (Work)"); |
1079 | } | 1075 | } |
1080 | 1076 | ||
1081 | 1077 | ||
1082 | QString Addressee::carPhoneLabel() | ||
1083 | { | ||
1084 | return i18n("Mobile2 (Car)"); | ||
1085 | } | ||
1086 | |||
1087 | |||
1088 | QString Addressee::isdnLabel() | 1078 | QString Addressee::isdnLabel() |
1089 | { | 1079 | { |
1090 | return i18n("ISDN"); | 1080 | return i18n("ISDN"); |
1091 | } | 1081 | } |
1092 | 1082 | ||
1093 | 1083 | ||
1094 | QString Addressee::pagerLabel() | 1084 | QString Addressee::pagerLabel() |
1095 | { | 1085 | { |
1096 | return i18n("Pager"); | 1086 | return i18n("Pager"); |
1097 | } | 1087 | } |
1098 | QString Addressee::otherPhoneLabel() | 1088 | QString Addressee::otherPhoneLabel() |
1099 | { | 1089 | { |
1100 | return i18n("Other Phone"); | 1090 | return i18n("Other Phone"); |
1101 | } | 1091 | } |
1102 | 1092 | ||
1103 | QString Addressee::sipLabel() | 1093 | QString Addressee::sipLabel() |
1104 | { | 1094 | { |
1105 | return i18n("SIP"); | 1095 | return i18n("SIP"); |
1106 | } | 1096 | } |
1107 | 1097 | ||
1108 | QString Addressee::emailLabel() | 1098 | QString Addressee::emailLabel() |
1109 | { | 1099 | { |
1110 | return i18n("Email Address"); | 1100 | return i18n("Email Address"); |
1111 | } | 1101 | } |
1112 | 1102 | ||
1113 | 1103 | ||
1114 | void Addressee::setMailer( const QString &mailer ) | 1104 | void Addressee::setMailer( const QString &mailer ) |
1115 | { | 1105 | { |
1116 | if ( mailer == mData->mailer ) return; | 1106 | if ( mailer == mData->mailer ) return; |
1117 | detach(); | 1107 | detach(); |
1118 | mData->empty = false; | 1108 | mData->empty = false; |
1119 | mData->mailer = mailer; | 1109 | mData->mailer = mailer; |
1120 | } | 1110 | } |
1121 | 1111 | ||
1122 | QString Addressee::mailer() const | 1112 | QString Addressee::mailer() const |
1123 | { | 1113 | { |
1124 | return mData->mailer; | 1114 | return mData->mailer; |
1125 | } | 1115 | } |
1126 | 1116 | ||
1127 | QString Addressee::mailerLabel() | 1117 | QString Addressee::mailerLabel() |
1128 | { | 1118 | { |
1129 | return i18n("Mail Client"); | 1119 | return i18n("Mail Client"); |
1130 | } | 1120 | } |
1131 | 1121 | ||
1132 | 1122 | ||
1133 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 1123 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
1134 | { | 1124 | { |
1135 | if ( timeZone == mData->timeZone ) return; | 1125 | if ( timeZone == mData->timeZone ) return; |
1136 | detach(); | 1126 | detach(); |
1137 | mData->empty = false; | 1127 | mData->empty = false; |
1138 | mData->timeZone = timeZone; | 1128 | mData->timeZone = timeZone; |
1139 | } | 1129 | } |
1140 | 1130 | ||
1141 | TimeZone Addressee::timeZone() const | 1131 | TimeZone Addressee::timeZone() const |
1142 | { | 1132 | { |
1143 | return mData->timeZone; | 1133 | return mData->timeZone; |
1144 | } | 1134 | } |
1145 | 1135 | ||
1146 | QString Addressee::timeZoneLabel() | 1136 | QString Addressee::timeZoneLabel() |
1147 | { | 1137 | { |
1148 | return i18n("Time Zone"); | 1138 | return i18n("Time Zone"); |
1149 | } | 1139 | } |
1150 | 1140 | ||
1151 | 1141 | ||
1152 | void Addressee::setGeo( const Geo &geo ) | 1142 | void Addressee::setGeo( const Geo &geo ) |
1153 | { | 1143 | { |
1154 | if ( geo == mData->geo ) return; | 1144 | if ( geo == mData->geo ) return; |
1155 | detach(); | 1145 | detach(); |
1156 | mData->empty = false; | 1146 | mData->empty = false; |
1157 | mData->geo = geo; | 1147 | mData->geo = geo; |
1158 | } | 1148 | } |
1159 | 1149 | ||
1160 | Geo Addressee::geo() const | 1150 | Geo Addressee::geo() const |
1161 | { | 1151 | { |
1162 | return mData->geo; | 1152 | return mData->geo; |
1163 | } | 1153 | } |
1164 | 1154 | ||
1165 | QString Addressee::geoLabel() | 1155 | QString Addressee::geoLabel() |
1166 | { | 1156 | { |
1167 | return i18n("Geographic Position"); | 1157 | return i18n("Geographic Position"); |
1168 | } | 1158 | } |
1169 | 1159 | ||
1170 | 1160 | ||
1171 | void Addressee::setTitle( const QString &title ) | 1161 | void Addressee::setTitle( const QString &title ) |
1172 | { | 1162 | { |
1173 | if ( title == mData->title ) return; | 1163 | if ( title == mData->title ) return; |
1174 | detach(); | 1164 | detach(); |
1175 | mData->empty = false; | 1165 | mData->empty = false; |
1176 | mData->title = title; | 1166 | mData->title = title; |
1177 | } | 1167 | } |
1178 | 1168 | ||
1179 | QString Addressee::title() const | 1169 | QString Addressee::title() const |
1180 | { | 1170 | { |
1181 | return mData->title; | 1171 | return mData->title; |
1182 | } | 1172 | } |
1183 | 1173 | ||
1184 | QString Addressee::titleLabel() | 1174 | QString Addressee::titleLabel() |
1185 | { | 1175 | { |
1186 | return i18n("Title"); | 1176 | return i18n("Title"); |
1187 | } | 1177 | } |
1188 | 1178 | ||
1189 | 1179 | ||
1190 | void Addressee::setRole( const QString &role ) | 1180 | void Addressee::setRole( const QString &role ) |
1191 | { | 1181 | { |
1192 | if ( role == mData->role ) return; | 1182 | if ( role == mData->role ) return; |
1193 | detach(); | 1183 | detach(); |
1194 | mData->empty = false; | 1184 | mData->empty = false; |
1195 | mData->role = role; | 1185 | mData->role = role; |
1196 | } | 1186 | } |
1197 | 1187 | ||
1198 | QString Addressee::role() const | 1188 | QString Addressee::role() const |
1199 | { | 1189 | { |
1200 | return mData->role; | 1190 | return mData->role; |
1201 | } | 1191 | } |
1202 | 1192 | ||
1203 | QString Addressee::roleLabel() | 1193 | QString Addressee::roleLabel() |
1204 | { | 1194 | { |
1205 | return i18n("Role"); | 1195 | return i18n("Role"); |
1206 | } | 1196 | } |
1207 | 1197 | ||
1208 | 1198 | ||
1209 | void Addressee::setOrganization( const QString &organization ) | 1199 | void Addressee::setOrganization( const QString &organization ) |
1210 | { | 1200 | { |
1211 | if ( organization == mData->organization ) return; | 1201 | if ( organization == mData->organization ) return; |
1212 | detach(); | 1202 | detach(); |
1213 | mData->empty = false; | 1203 | mData->empty = false; |
1214 | mData->organization = organization; | 1204 | mData->organization = organization; |
1215 | } | 1205 | } |
1216 | 1206 | ||
1217 | QString Addressee::organization() const | 1207 | QString Addressee::organization() const |
1218 | { | 1208 | { |
1219 | return mData->organization; | 1209 | return mData->organization; |
1220 | } | 1210 | } |
1221 | 1211 | ||
1222 | QString Addressee::organizationLabel() | 1212 | QString Addressee::organizationLabel() |
1223 | { | 1213 | { |
1224 | return i18n("Organization"); | 1214 | return i18n("Organization"); |
1225 | } | 1215 | } |
1226 | 1216 | ||
1227 | 1217 | ||
1228 | void Addressee::setNote( const QString ¬e ) | 1218 | void Addressee::setNote( const QString ¬e ) |
1229 | { | 1219 | { |
1230 | if ( note == mData->note ) return; | 1220 | if ( note == mData->note ) return; |
1231 | detach(); | 1221 | detach(); |
1232 | mData->empty = false; | 1222 | mData->empty = false; |
1233 | mData->note = note; | 1223 | mData->note = note; |
1234 | } | 1224 | } |
1235 | 1225 | ||
1236 | QString Addressee::note() const | 1226 | QString Addressee::note() const |
1237 | { | 1227 | { |
1238 | return mData->note; | 1228 | return mData->note; |
1239 | } | 1229 | } |
1240 | 1230 | ||
1241 | QString Addressee::noteLabel() | 1231 | QString Addressee::noteLabel() |
1242 | { | 1232 | { |
1243 | return i18n("Note"); | 1233 | return i18n("Note"); |
1244 | } | 1234 | } |
1245 | 1235 | ||
1246 | 1236 | ||
1247 | void Addressee::setProductId( const QString &productId ) | 1237 | void Addressee::setProductId( const QString &productId ) |
1248 | { | 1238 | { |
1249 | if ( productId == mData->productId ) return; | 1239 | if ( productId == mData->productId ) return; |
1250 | detach(); | 1240 | detach(); |
1251 | mData->empty = false; | 1241 | mData->empty = false; |
1252 | mData->productId = productId; | 1242 | mData->productId = productId; |
1253 | } | 1243 | } |
1254 | 1244 | ||
1255 | QString Addressee::productId() const | 1245 | QString Addressee::productId() const |
1256 | { | 1246 | { |
1257 | return mData->productId; | 1247 | return mData->productId; |
1258 | } | 1248 | } |
1259 | 1249 | ||
1260 | QString Addressee::productIdLabel() | 1250 | QString Addressee::productIdLabel() |
1261 | { | 1251 | { |
1262 | return i18n("Product Identifier"); | 1252 | return i18n("Product Identifier"); |
1263 | } | 1253 | } |
1264 | 1254 | ||
1265 | 1255 | ||
1266 | void Addressee::setRevision( const QDateTime &revision ) | 1256 | void Addressee::setRevision( const QDateTime &revision ) |
1267 | { | 1257 | { |
1268 | if ( revision == mData->revision ) return; | 1258 | if ( revision == mData->revision ) return; |
1269 | detach(); | 1259 | detach(); |
1270 | mData->empty = false; | 1260 | mData->empty = false; |
1271 | mData->revision = QDateTime( revision.date(), | 1261 | mData->revision = QDateTime( revision.date(), |
1272 | QTime (revision.time().hour(), | 1262 | QTime (revision.time().hour(), |
1273 | revision.time().minute(), | 1263 | revision.time().minute(), |
1274 | revision.time().second())); | 1264 | revision.time().second())); |
1275 | } | 1265 | } |
1276 | 1266 | ||
1277 | QDateTime Addressee::revision() const | 1267 | QDateTime Addressee::revision() const |
1278 | { | 1268 | { |
1279 | return mData->revision; | 1269 | return mData->revision; |
1280 | } | 1270 | } |
1281 | 1271 | ||
1282 | QString Addressee::revisionLabel() | 1272 | QString Addressee::revisionLabel() |
1283 | { | 1273 | { |
1284 | return i18n("Revision Date"); | 1274 | return i18n("Revision Date"); |
1285 | } | 1275 | } |
1286 | 1276 | ||
1287 | 1277 | ||
1288 | void Addressee::setSortString( const QString &sortString ) | 1278 | void Addressee::setSortString( const QString &sortString ) |
1289 | { | 1279 | { |
1290 | if ( sortString == mData->sortString ) return; | 1280 | if ( sortString == mData->sortString ) return; |
1291 | detach(); | 1281 | detach(); |
1292 | mData->empty = false; | 1282 | mData->empty = false; |
1293 | mData->sortString = sortString; | 1283 | mData->sortString = sortString; |
1294 | } | 1284 | } |
1295 | 1285 | ||
1296 | QString Addressee::sortString() const | 1286 | QString Addressee::sortString() const |
1297 | { | 1287 | { |
1298 | return mData->sortString; | 1288 | return mData->sortString; |
1299 | } | 1289 | } |
1300 | 1290 | ||
1301 | QString Addressee::sortStringLabel() | 1291 | QString Addressee::sortStringLabel() |
1302 | { | 1292 | { |
1303 | return i18n("Sort String"); | 1293 | return i18n("Sort String"); |
1304 | } | 1294 | } |
1305 | 1295 | ||
1306 | 1296 | ||
1307 | void Addressee::setUrl( const KURL &url ) | 1297 | void Addressee::setUrl( const KURL &url ) |
1308 | { | 1298 | { |
1309 | if ( url == mData->url ) return; | 1299 | if ( url == mData->url ) return; |
1310 | detach(); | 1300 | detach(); |
1311 | mData->empty = false; | 1301 | mData->empty = false; |
1312 | mData->url = url; | 1302 | mData->url = url; |
1313 | } | 1303 | } |
1314 | 1304 | ||
1315 | KURL Addressee::url() const | 1305 | KURL Addressee::url() const |
1316 | { | 1306 | { |
1317 | return mData->url; | 1307 | return mData->url; |
1318 | } | 1308 | } |
1319 | 1309 | ||
1320 | QString Addressee::urlLabel() | 1310 | QString Addressee::urlLabel() |
1321 | { | 1311 | { |
1322 | return i18n("URL"); | 1312 | return i18n("URL"); |
1323 | } | 1313 | } |
1324 | 1314 | ||
1325 | 1315 | ||
1326 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1316 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1327 | { | 1317 | { |
1328 | if ( secrecy == mData->secrecy ) return; | 1318 | if ( secrecy == mData->secrecy ) return; |
1329 | detach(); | 1319 | detach(); |
1330 | mData->empty = false; | 1320 | mData->empty = false; |
1331 | mData->secrecy = secrecy; | 1321 | mData->secrecy = secrecy; |
1332 | } | 1322 | } |
1333 | 1323 | ||
1334 | Secrecy Addressee::secrecy() const | 1324 | Secrecy Addressee::secrecy() const |
1335 | { | 1325 | { |
1336 | return mData->secrecy; | 1326 | return mData->secrecy; |
1337 | } | 1327 | } |
1338 | 1328 | ||
1339 | QString Addressee::secrecyLabel() | 1329 | QString Addressee::secrecyLabel() |
1340 | { | 1330 | { |
1341 | return i18n("Security Class"); | 1331 | return i18n("Security Class"); |
1342 | } | 1332 | } |
1343 | 1333 | ||
1344 | 1334 | ||
1345 | void Addressee::setLogo( const Picture &logo ) | 1335 | void Addressee::setLogo( const Picture &logo ) |
1346 | { | 1336 | { |
1347 | if ( logo == mData->logo ) return; | 1337 | if ( logo == mData->logo ) return; |
1348 | detach(); | 1338 | detach(); |
1349 | mData->empty = false; | 1339 | mData->empty = false; |
1350 | mData->logo = logo; | 1340 | mData->logo = logo; |
1351 | } | 1341 | } |
1352 | 1342 | ||
1353 | Picture Addressee::logo() const | 1343 | Picture Addressee::logo() const |
1354 | { | 1344 | { |
1355 | return mData->logo; | 1345 | return mData->logo; |
1356 | } | 1346 | } |
1357 | 1347 | ||
1358 | QString Addressee::logoLabel() | 1348 | QString Addressee::logoLabel() |
1359 | { | 1349 | { |
1360 | return i18n("Logo"); | 1350 | return i18n("Logo"); |
1361 | } | 1351 | } |
1362 | 1352 | ||
1363 | 1353 | ||
1364 | void Addressee::setPhoto( const Picture &photo ) | 1354 | void Addressee::setPhoto( const Picture &photo ) |
1365 | { | 1355 | { |
1366 | if ( photo == mData->photo ) return; | 1356 | if ( photo == mData->photo ) return; |
1367 | detach(); | 1357 | detach(); |
1368 | mData->empty = false; | 1358 | mData->empty = false; |
1369 | mData->photo = photo; | 1359 | mData->photo = photo; |
1370 | } | 1360 | } |
1371 | 1361 | ||
1372 | Picture Addressee::photo() const | 1362 | Picture Addressee::photo() const |
1373 | { | 1363 | { |
1374 | return mData->photo; | 1364 | return mData->photo; |
1375 | } | 1365 | } |
1376 | 1366 | ||
1377 | QString Addressee::photoLabel() | 1367 | QString Addressee::photoLabel() |
1378 | { | 1368 | { |
1379 | return i18n("Photo"); | 1369 | return i18n("Photo"); |
1380 | } | 1370 | } |
1381 | 1371 | ||
1382 | 1372 | ||
1383 | void Addressee::setSound( const Sound &sound ) | 1373 | void Addressee::setSound( const Sound &sound ) |
1384 | { | 1374 | { |
1385 | if ( sound == mData->sound ) return; | 1375 | if ( sound == mData->sound ) return; |
1386 | detach(); | 1376 | detach(); |
1387 | mData->empty = false; | 1377 | mData->empty = false; |
1388 | mData->sound = sound; | 1378 | mData->sound = sound; |
1389 | } | 1379 | } |
1390 | 1380 | ||
1391 | Sound Addressee::sound() const | 1381 | Sound Addressee::sound() const |
1392 | { | 1382 | { |
1393 | return mData->sound; | 1383 | return mData->sound; |
1394 | } | 1384 | } |
1395 | 1385 | ||
1396 | QString Addressee::soundLabel() | 1386 | QString Addressee::soundLabel() |
1397 | { | 1387 | { |
1398 | return i18n("Sound"); | 1388 | return i18n("Sound"); |
1399 | } | 1389 | } |
1400 | 1390 | ||
1401 | 1391 | ||
1402 | void Addressee::setAgent( const Agent &agent ) | 1392 | void Addressee::setAgent( const Agent &agent ) |
1403 | { | 1393 | { |
1404 | if ( agent == mData->agent ) return; | 1394 | if ( agent == mData->agent ) return; |
1405 | detach(); | 1395 | detach(); |
1406 | mData->empty = false; | 1396 | mData->empty = false; |
1407 | mData->agent = agent; | 1397 | mData->agent = agent; |
1408 | } | 1398 | } |
1409 | 1399 | ||
1410 | Agent Addressee::agent() const | 1400 | Agent Addressee::agent() const |
1411 | { | 1401 | { |
1412 | return mData->agent; | 1402 | return mData->agent; |
1413 | } | 1403 | } |
1414 | 1404 | ||
1415 | QString Addressee::agentLabel() | 1405 | QString Addressee::agentLabel() |
1416 | { | 1406 | { |
1417 | return i18n("Agent"); | 1407 | return i18n("Agent"); |
1418 | } | 1408 | } |
1419 | 1409 | ||
1420 | 1410 | ||
1421 | 1411 | ||
1422 | void Addressee::setNameFromString( const QString &str ) | 1412 | void Addressee::setNameFromString( const QString &str ) |
1423 | { | 1413 | { |
1424 | setFormattedName( str ); | 1414 | setFormattedName( str ); |
1425 | setName( str ); | 1415 | setName( str ); |
1426 | 1416 | ||
1427 | static bool first = true; | 1417 | static bool first = true; |
1428 | static QStringList titles; | 1418 | static QStringList titles; |
1429 | static QStringList suffixes; | 1419 | static QStringList suffixes; |
1430 | static QStringList prefixes; | 1420 | static QStringList prefixes; |
1431 | 1421 | ||
1432 | if ( first ) { | 1422 | if ( first ) { |
1433 | first = false; | 1423 | first = false; |
1434 | titles += i18n( "Dr." ); | 1424 | titles += i18n( "Dr." ); |
1435 | titles += i18n( "Miss" ); | 1425 | titles += i18n( "Miss" ); |
1436 | titles += i18n( "Mr." ); | 1426 | titles += i18n( "Mr." ); |
1437 | titles += i18n( "Mrs." ); | 1427 | titles += i18n( "Mrs." ); |
1438 | titles += i18n( "Ms." ); | 1428 | titles += i18n( "Ms." ); |
1439 | titles += i18n( "Prof." ); | 1429 | titles += i18n( "Prof." ); |
1440 | 1430 | ||
1441 | suffixes += i18n( "I" ); | 1431 | suffixes += i18n( "I" ); |
1442 | suffixes += i18n( "II" ); | 1432 | suffixes += i18n( "II" ); |
1443 | suffixes += i18n( "III" ); | 1433 | suffixes += i18n( "III" ); |
1444 | suffixes += i18n( "Jr." ); | 1434 | suffixes += i18n( "Jr." ); |
1445 | suffixes += i18n( "Sr." ); | 1435 | suffixes += i18n( "Sr." ); |
1446 | 1436 | ||
1447 | prefixes += "van"; | 1437 | prefixes += "van"; |
1448 | prefixes += "von"; | 1438 | prefixes += "von"; |
1449 | prefixes += "de"; | 1439 | prefixes += "de"; |
1450 | 1440 | ||
1451 | KConfig config( locateLocal( "config", "kabcrc") ); | 1441 | KConfig config( locateLocal( "config", "kabcrc") ); |
1452 | config.setGroup( "General" ); | 1442 | config.setGroup( "General" ); |
1453 | titles += config.readListEntry( "Prefixes" ); | 1443 | titles += config.readListEntry( "Prefixes" ); |
1454 | titles.remove( "" ); | 1444 | titles.remove( "" ); |
1455 | prefixes += config.readListEntry( "Inclusions" ); | 1445 | prefixes += config.readListEntry( "Inclusions" ); |
1456 | prefixes.remove( "" ); | 1446 | prefixes.remove( "" ); |
1457 | suffixes += config.readListEntry( "Suffixes" ); | 1447 | suffixes += config.readListEntry( "Suffixes" ); |
1458 | suffixes.remove( "" ); | 1448 | suffixes.remove( "" ); |
1459 | } | 1449 | } |
1460 | 1450 | ||
1461 | // clear all name parts | 1451 | // clear all name parts |
1462 | setPrefix( "" ); | 1452 | setPrefix( "" ); |
1463 | setGivenName( "" ); | 1453 | setGivenName( "" ); |
1464 | setAdditionalName( "" ); | 1454 | setAdditionalName( "" ); |
1465 | setFamilyName( "" ); | 1455 | setFamilyName( "" ); |
1466 | setSuffix( "" ); | 1456 | setSuffix( "" ); |
1467 | 1457 | ||
1468 | if ( str.isEmpty() ) | 1458 | if ( str.isEmpty() ) |
1469 | return; | 1459 | return; |
1470 | 1460 | ||
1471 | int i = str.find(','); | 1461 | int i = str.find(','); |
1472 | if( i < 0 ) { | 1462 | if( i < 0 ) { |
1473 | QStringList parts = QStringList::split( " ", str ); | 1463 | QStringList parts = QStringList::split( " ", str ); |
1474 | int leftOffset = 0; | 1464 | int leftOffset = 0; |
1475 | int rightOffset = parts.count() - 1; | 1465 | int rightOffset = parts.count() - 1; |
1476 | 1466 | ||
1477 | QString suffix; | 1467 | QString suffix; |
1478 | while ( rightOffset >= 0 ) { | 1468 | while ( rightOffset >= 0 ) { |
1479 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1469 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1480 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1470 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1481 | rightOffset--; | 1471 | rightOffset--; |
1482 | } else | 1472 | } else |
1483 | break; | 1473 | break; |
1484 | } | 1474 | } |
1485 | setSuffix( suffix ); | 1475 | setSuffix( suffix ); |
1486 | 1476 | ||
1487 | if ( rightOffset < 0 ) | 1477 | if ( rightOffset < 0 ) |
1488 | return; | 1478 | return; |
1489 | 1479 | ||
1490 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1480 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1491 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1481 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1492 | rightOffset--; | 1482 | rightOffset--; |
1493 | } else | 1483 | } else |
1494 | setFamilyName( parts[ rightOffset ] ); | 1484 | setFamilyName( parts[ rightOffset ] ); |
1495 | 1485 | ||
1496 | QString prefix; | 1486 | QString prefix; |
1497 | while ( leftOffset < rightOffset ) { | 1487 | while ( leftOffset < rightOffset ) { |
1498 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1488 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1499 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1489 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1500 | leftOffset++; | 1490 | leftOffset++; |
1501 | } else | 1491 | } else |
1502 | break; | 1492 | break; |
1503 | } | 1493 | } |
1504 | setPrefix( prefix ); | 1494 | setPrefix( prefix ); |
1505 | 1495 | ||
1506 | if ( leftOffset < rightOffset ) { | 1496 | if ( leftOffset < rightOffset ) { |
1507 | setGivenName( parts[ leftOffset ] ); | 1497 | setGivenName( parts[ leftOffset ] ); |
1508 | leftOffset++; | 1498 | leftOffset++; |
1509 | } | 1499 | } |
1510 | 1500 | ||
1511 | QString additionalName; | 1501 | QString additionalName; |
1512 | while ( leftOffset < rightOffset ) { | 1502 | while ( leftOffset < rightOffset ) { |
1513 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1503 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1514 | leftOffset++; | 1504 | leftOffset++; |
1515 | } | 1505 | } |
1516 | setAdditionalName( additionalName ); | 1506 | setAdditionalName( additionalName ); |
1517 | } else { | 1507 | } else { |
1518 | QString part1 = str.left( i ); | 1508 | QString part1 = str.left( i ); |
1519 | QString part2 = str.mid( i + 1 ); | 1509 | QString part2 = str.mid( i + 1 ); |
1520 | 1510 | ||
1521 | QStringList parts = QStringList::split( " ", part1 ); | 1511 | QStringList parts = QStringList::split( " ", part1 ); |
1522 | int leftOffset = 0; | 1512 | int leftOffset = 0; |
1523 | int rightOffset = parts.count() - 1; | 1513 | int rightOffset = parts.count() - 1; |
1524 | 1514 | ||
1525 | QString suffix; | 1515 | QString suffix; |
1526 | while ( rightOffset >= 0 ) { | 1516 | while ( rightOffset >= 0 ) { |
1527 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1517 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1528 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1518 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1529 | rightOffset--; | 1519 | rightOffset--; |
1530 | } else | 1520 | } else |
1531 | break; | 1521 | break; |
1532 | } | 1522 | } |
1533 | setSuffix( suffix ); | 1523 | setSuffix( suffix ); |
1534 | 1524 | ||
1535 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1525 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1536 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1526 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1537 | rightOffset--; | 1527 | rightOffset--; |
1538 | } else | 1528 | } else |
1539 | setFamilyName( parts[ rightOffset ] ); | 1529 | setFamilyName( parts[ rightOffset ] ); |
1540 | 1530 | ||
1541 | QString prefix; | 1531 | QString prefix; |
1542 | while ( leftOffset < rightOffset ) { | 1532 | while ( leftOffset < rightOffset ) { |
1543 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1533 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1544 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1534 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1545 | leftOffset++; | 1535 | leftOffset++; |
1546 | } else | 1536 | } else |
1547 | break; | 1537 | break; |
1548 | } | 1538 | } |
1549 | 1539 | ||
1550 | parts = QStringList::split( " ", part2 ); | 1540 | parts = QStringList::split( " ", part2 ); |
1551 | 1541 | ||
1552 | leftOffset = 0; | 1542 | leftOffset = 0; |
1553 | rightOffset = parts.count(); | 1543 | rightOffset = parts.count(); |
1554 | 1544 | ||
1555 | while ( leftOffset < rightOffset ) { | 1545 | while ( leftOffset < rightOffset ) { |
1556 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1546 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1557 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1547 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1558 | leftOffset++; | 1548 | leftOffset++; |
1559 | } else | 1549 | } else |
1560 | break; | 1550 | break; |
1561 | } | 1551 | } |
1562 | setPrefix( prefix ); | 1552 | setPrefix( prefix ); |
1563 | 1553 | ||
1564 | if ( leftOffset < rightOffset ) { | 1554 | if ( leftOffset < rightOffset ) { |
1565 | setGivenName( parts[ leftOffset ] ); | 1555 | setGivenName( parts[ leftOffset ] ); |
1566 | leftOffset++; | 1556 | leftOffset++; |
1567 | } | 1557 | } |
1568 | 1558 | ||
1569 | QString additionalName; | 1559 | QString additionalName; |
1570 | while ( leftOffset < rightOffset ) { | 1560 | while ( leftOffset < rightOffset ) { |
1571 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1561 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1572 | leftOffset++; | 1562 | leftOffset++; |
1573 | } | 1563 | } |
1574 | setAdditionalName( additionalName ); | 1564 | setAdditionalName( additionalName ); |
1575 | } | 1565 | } |
1576 | } | 1566 | } |
1577 | 1567 | ||
1578 | QString Addressee::realName() const | 1568 | QString Addressee::realName() const |
1579 | { | 1569 | { |
1580 | if ( !formattedName().isEmpty() ) | 1570 | if ( !formattedName().isEmpty() ) |
1581 | return formattedName(); | 1571 | return formattedName(); |
1582 | 1572 | ||
1583 | QString n = assembledName(); | 1573 | QString n = assembledName(); |
1584 | 1574 | ||
1585 | if ( n.isEmpty() ) | 1575 | if ( n.isEmpty() ) |
1586 | n = name(); | 1576 | n = name(); |
1587 | if ( n.isEmpty() ) | 1577 | if ( n.isEmpty() ) |
1588 | n = organization(); | 1578 | n = organization(); |
1589 | return n; | 1579 | return n; |
1590 | } | 1580 | } |
1591 | 1581 | ||
1592 | QString Addressee::assembledName() const | 1582 | QString Addressee::assembledName() const |
1593 | { | 1583 | { |
1594 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1584 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1595 | familyName() + " " + suffix(); | 1585 | familyName() + " " + suffix(); |
1596 | 1586 | ||
1597 | return name.simplifyWhiteSpace(); | 1587 | return name.simplifyWhiteSpace(); |
1598 | } | 1588 | } |
1599 | 1589 | ||