author | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
commit | bd6b4acb39498ffea3beea7d9b5f7620b60c14db (patch) (unidiff) | |
tree | e2d7425b7bb49fbcb7acb5ced497ac1fed06dfaf /kabc | |
parent | 06eabf6e82c0390699d11fd12580d91261829431 (diff) | |
download | kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.zip kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.gz kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.bz2 |
Many bugfixes
-rw-r--r-- | kabc/addressee.cpp | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6b282e2..4cdd5e5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -612,413 +612,417 @@ void Addressee::setNote( const QString ¬e ) | |||
612 | mData->empty = false; | 612 | mData->empty = false; |
613 | mData->note = note; | 613 | mData->note = note; |
614 | } | 614 | } |
615 | 615 | ||
616 | QString Addressee::note() const | 616 | QString Addressee::note() const |
617 | { | 617 | { |
618 | return mData->note; | 618 | return mData->note; |
619 | } | 619 | } |
620 | 620 | ||
621 | QString Addressee::noteLabel() | 621 | QString Addressee::noteLabel() |
622 | { | 622 | { |
623 | return i18n("Note"); | 623 | return i18n("Note"); |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | void Addressee::setProductId( const QString &productId ) | 627 | void Addressee::setProductId( const QString &productId ) |
628 | { | 628 | { |
629 | if ( productId == mData->productId ) return; | 629 | if ( productId == mData->productId ) return; |
630 | detach(); | 630 | detach(); |
631 | mData->empty = false; | 631 | mData->empty = false; |
632 | mData->productId = productId; | 632 | mData->productId = productId; |
633 | } | 633 | } |
634 | 634 | ||
635 | QString Addressee::productId() const | 635 | QString Addressee::productId() const |
636 | { | 636 | { |
637 | return mData->productId; | 637 | return mData->productId; |
638 | } | 638 | } |
639 | 639 | ||
640 | QString Addressee::productIdLabel() | 640 | QString Addressee::productIdLabel() |
641 | { | 641 | { |
642 | return i18n("Product Identifier"); | 642 | return i18n("Product Identifier"); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | void Addressee::setRevision( const QDateTime &revision ) | 646 | void Addressee::setRevision( const QDateTime &revision ) |
647 | { | 647 | { |
648 | if ( revision == mData->revision ) return; | 648 | if ( revision == mData->revision ) return; |
649 | detach(); | 649 | detach(); |
650 | mData->empty = false; | 650 | mData->empty = false; |
651 | mData->revision = revision; | 651 | mData->revision = revision; |
652 | } | 652 | } |
653 | 653 | ||
654 | QDateTime Addressee::revision() const | 654 | QDateTime Addressee::revision() const |
655 | { | 655 | { |
656 | return mData->revision; | 656 | return mData->revision; |
657 | } | 657 | } |
658 | 658 | ||
659 | QString Addressee::revisionLabel() | 659 | QString Addressee::revisionLabel() |
660 | { | 660 | { |
661 | return i18n("Revision Date"); | 661 | return i18n("Revision Date"); |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | void Addressee::setSortString( const QString &sortString ) | 665 | void Addressee::setSortString( const QString &sortString ) |
666 | { | 666 | { |
667 | if ( sortString == mData->sortString ) return; | 667 | if ( sortString == mData->sortString ) return; |
668 | detach(); | 668 | detach(); |
669 | mData->empty = false; | 669 | mData->empty = false; |
670 | mData->sortString = sortString; | 670 | mData->sortString = sortString; |
671 | } | 671 | } |
672 | 672 | ||
673 | QString Addressee::sortString() const | 673 | QString Addressee::sortString() const |
674 | { | 674 | { |
675 | return mData->sortString; | 675 | return mData->sortString; |
676 | } | 676 | } |
677 | 677 | ||
678 | QString Addressee::sortStringLabel() | 678 | QString Addressee::sortStringLabel() |
679 | { | 679 | { |
680 | return i18n("Sort String"); | 680 | return i18n("Sort String"); |
681 | } | 681 | } |
682 | 682 | ||
683 | 683 | ||
684 | void Addressee::setUrl( const KURL &url ) | 684 | void Addressee::setUrl( const KURL &url ) |
685 | { | 685 | { |
686 | if ( url == mData->url ) return; | 686 | if ( url == mData->url ) return; |
687 | detach(); | 687 | detach(); |
688 | mData->empty = false; | 688 | mData->empty = false; |
689 | mData->url = url; | 689 | mData->url = url; |
690 | } | 690 | } |
691 | 691 | ||
692 | KURL Addressee::url() const | 692 | KURL Addressee::url() const |
693 | { | 693 | { |
694 | return mData->url; | 694 | return mData->url; |
695 | } | 695 | } |
696 | 696 | ||
697 | QString Addressee::urlLabel() | 697 | QString Addressee::urlLabel() |
698 | { | 698 | { |
699 | return i18n("URL"); | 699 | return i18n("URL"); |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 703 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
704 | { | 704 | { |
705 | if ( secrecy == mData->secrecy ) return; | 705 | if ( secrecy == mData->secrecy ) return; |
706 | detach(); | 706 | detach(); |
707 | mData->empty = false; | 707 | mData->empty = false; |
708 | mData->secrecy = secrecy; | 708 | mData->secrecy = secrecy; |
709 | } | 709 | } |
710 | 710 | ||
711 | Secrecy Addressee::secrecy() const | 711 | Secrecy Addressee::secrecy() const |
712 | { | 712 | { |
713 | return mData->secrecy; | 713 | return mData->secrecy; |
714 | } | 714 | } |
715 | 715 | ||
716 | QString Addressee::secrecyLabel() | 716 | QString Addressee::secrecyLabel() |
717 | { | 717 | { |
718 | return i18n("Security Class"); | 718 | return i18n("Security Class"); |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
722 | void Addressee::setLogo( const Picture &logo ) | 722 | void Addressee::setLogo( const Picture &logo ) |
723 | { | 723 | { |
724 | if ( logo == mData->logo ) return; | 724 | if ( logo == mData->logo ) return; |
725 | detach(); | 725 | detach(); |
726 | mData->empty = false; | 726 | mData->empty = false; |
727 | mData->logo = logo; | 727 | mData->logo = logo; |
728 | } | 728 | } |
729 | 729 | ||
730 | Picture Addressee::logo() const | 730 | Picture Addressee::logo() const |
731 | { | 731 | { |
732 | return mData->logo; | 732 | return mData->logo; |
733 | } | 733 | } |
734 | 734 | ||
735 | QString Addressee::logoLabel() | 735 | QString Addressee::logoLabel() |
736 | { | 736 | { |
737 | return i18n("Logo"); | 737 | return i18n("Logo"); |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | void Addressee::setPhoto( const Picture &photo ) | 741 | void Addressee::setPhoto( const Picture &photo ) |
742 | { | 742 | { |
743 | if ( photo == mData->photo ) return; | 743 | if ( photo == mData->photo ) return; |
744 | detach(); | 744 | detach(); |
745 | mData->empty = false; | 745 | mData->empty = false; |
746 | mData->photo = photo; | 746 | mData->photo = photo; |
747 | } | 747 | } |
748 | 748 | ||
749 | Picture Addressee::photo() const | 749 | Picture Addressee::photo() const |
750 | { | 750 | { |
751 | return mData->photo; | 751 | return mData->photo; |
752 | } | 752 | } |
753 | 753 | ||
754 | QString Addressee::photoLabel() | 754 | QString Addressee::photoLabel() |
755 | { | 755 | { |
756 | return i18n("Photo"); | 756 | return i18n("Photo"); |
757 | } | 757 | } |
758 | 758 | ||
759 | 759 | ||
760 | void Addressee::setSound( const Sound &sound ) | 760 | void Addressee::setSound( const Sound &sound ) |
761 | { | 761 | { |
762 | if ( sound == mData->sound ) return; | 762 | if ( sound == mData->sound ) return; |
763 | detach(); | 763 | detach(); |
764 | mData->empty = false; | 764 | mData->empty = false; |
765 | mData->sound = sound; | 765 | mData->sound = sound; |
766 | } | 766 | } |
767 | 767 | ||
768 | Sound Addressee::sound() const | 768 | Sound Addressee::sound() const |
769 | { | 769 | { |
770 | return mData->sound; | 770 | return mData->sound; |
771 | } | 771 | } |
772 | 772 | ||
773 | QString Addressee::soundLabel() | 773 | QString Addressee::soundLabel() |
774 | { | 774 | { |
775 | return i18n("Sound"); | 775 | return i18n("Sound"); |
776 | } | 776 | } |
777 | 777 | ||
778 | 778 | ||
779 | void Addressee::setAgent( const Agent &agent ) | 779 | void Addressee::setAgent( const Agent &agent ) |
780 | { | 780 | { |
781 | if ( agent == mData->agent ) return; | 781 | if ( agent == mData->agent ) return; |
782 | detach(); | 782 | detach(); |
783 | mData->empty = false; | 783 | mData->empty = false; |
784 | mData->agent = agent; | 784 | mData->agent = agent; |
785 | } | 785 | } |
786 | 786 | ||
787 | Agent Addressee::agent() const | 787 | Agent Addressee::agent() const |
788 | { | 788 | { |
789 | return mData->agent; | 789 | return mData->agent; |
790 | } | 790 | } |
791 | 791 | ||
792 | QString Addressee::agentLabel() | 792 | QString Addressee::agentLabel() |
793 | { | 793 | { |
794 | return i18n("Agent"); | 794 | return i18n("Agent"); |
795 | } | 795 | } |
796 | 796 | ||
797 | 797 | ||
798 | 798 | ||
799 | void Addressee::setNameFromString( const QString &str ) | 799 | void Addressee::setNameFromString( const QString &str ) |
800 | { | 800 | { |
801 | setFormattedName( str ); | 801 | setFormattedName( str ); |
802 | setName( str ); | 802 | setName( str ); |
803 | 803 | ||
804 | QStringList titles; | 804 | static bool first = true; |
805 | titles += i18n( "Dr." ); | 805 | static QStringList titles; |
806 | titles += i18n( "Miss" ); | 806 | static QStringList suffixes; |
807 | titles += i18n( "Mr." ); | 807 | static QStringList prefixes; |
808 | titles += i18n( "Mrs." ); | 808 | |
809 | titles += i18n( "Ms." ); | 809 | if ( first ) { |
810 | titles += i18n( "Prof." ); | 810 | first = false; |
811 | 811 | titles += i18n( "Dr." ); | |
812 | QStringList suffixes; | 812 | titles += i18n( "Miss" ); |
813 | suffixes += i18n( "I" ); | 813 | titles += i18n( "Mr." ); |
814 | suffixes += i18n( "II" ); | 814 | titles += i18n( "Mrs." ); |
815 | suffixes += i18n( "III" ); | 815 | titles += i18n( "Ms." ); |
816 | suffixes += i18n( "Jr." ); | 816 | titles += i18n( "Prof." ); |
817 | suffixes += i18n( "Sr." ); | 817 | |
818 | 818 | suffixes += i18n( "I" ); | |
819 | QStringList prefixes; | 819 | suffixes += i18n( "II" ); |
820 | prefixes += "van"; | 820 | suffixes += i18n( "III" ); |
821 | prefixes += "von"; | 821 | suffixes += i18n( "Jr." ); |
822 | prefixes += "de"; | 822 | suffixes += i18n( "Sr." ); |
823 | 823 | ||
824 | //US KConfig config( "kabcrc" ); | 824 | prefixes += "van"; |
825 | KConfig config( locateLocal( "config", "kabcrc") ); | 825 | prefixes += "von"; |
826 | config.setGroup( "General" ); | 826 | prefixes += "de"; |
827 | titles += config.readListEntry( "Prefixes" ); | 827 | |
828 | titles.remove( "" ); | 828 | KConfig config( locateLocal( "config", "kabcrc") ); |
829 | prefixes += config.readListEntry( "Inclusions" ); | 829 | config.setGroup( "General" ); |
830 | prefixes.remove( "" ); | 830 | titles += config.readListEntry( "Prefixes" ); |
831 | suffixes += config.readListEntry( "Suffixes" ); | 831 | titles.remove( "" ); |
832 | suffixes.remove( "" ); | 832 | prefixes += config.readListEntry( "Inclusions" ); |
833 | prefixes.remove( "" ); | ||
834 | suffixes += config.readListEntry( "Suffixes" ); | ||
835 | suffixes.remove( "" ); | ||
836 | } | ||
833 | 837 | ||
834 | // clear all name parts | 838 | // clear all name parts |
835 | setPrefix( "" ); | 839 | setPrefix( "" ); |
836 | setGivenName( "" ); | 840 | setGivenName( "" ); |
837 | setAdditionalName( "" ); | 841 | setAdditionalName( "" ); |
838 | setFamilyName( "" ); | 842 | setFamilyName( "" ); |
839 | setSuffix( "" ); | 843 | setSuffix( "" ); |
840 | 844 | ||
841 | if ( str.isEmpty() ) | 845 | if ( str.isEmpty() ) |
842 | return; | 846 | return; |
843 | 847 | ||
844 | int i = str.find(','); | 848 | int i = str.find(','); |
845 | if( i < 0 ) { | 849 | if( i < 0 ) { |
846 | QStringList parts = QStringList::split( " ", str ); | 850 | QStringList parts = QStringList::split( " ", str ); |
847 | int leftOffset = 0; | 851 | int leftOffset = 0; |
848 | int rightOffset = parts.count() - 1; | 852 | int rightOffset = parts.count() - 1; |
849 | 853 | ||
850 | QString suffix; | 854 | QString suffix; |
851 | while ( rightOffset >= 0 ) { | 855 | while ( rightOffset >= 0 ) { |
852 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 856 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
853 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 857 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
854 | rightOffset--; | 858 | rightOffset--; |
855 | } else | 859 | } else |
856 | break; | 860 | break; |
857 | } | 861 | } |
858 | setSuffix( suffix ); | 862 | setSuffix( suffix ); |
859 | 863 | ||
860 | if ( rightOffset < 0 ) | 864 | if ( rightOffset < 0 ) |
861 | return; | 865 | return; |
862 | 866 | ||
863 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 867 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
864 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 868 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
865 | rightOffset--; | 869 | rightOffset--; |
866 | } else | 870 | } else |
867 | setFamilyName( parts[ rightOffset ] ); | 871 | setFamilyName( parts[ rightOffset ] ); |
868 | 872 | ||
869 | QString prefix; | 873 | QString prefix; |
870 | while ( leftOffset < rightOffset ) { | 874 | while ( leftOffset < rightOffset ) { |
871 | if ( titles.contains( parts[ leftOffset ] ) ) { | 875 | if ( titles.contains( parts[ leftOffset ] ) ) { |
872 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 876 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
873 | leftOffset++; | 877 | leftOffset++; |
874 | } else | 878 | } else |
875 | break; | 879 | break; |
876 | } | 880 | } |
877 | setPrefix( prefix ); | 881 | setPrefix( prefix ); |
878 | 882 | ||
879 | if ( leftOffset < rightOffset ) { | 883 | if ( leftOffset < rightOffset ) { |
880 | setGivenName( parts[ leftOffset ] ); | 884 | setGivenName( parts[ leftOffset ] ); |
881 | leftOffset++; | 885 | leftOffset++; |
882 | } | 886 | } |
883 | 887 | ||
884 | QString additionalName; | 888 | QString additionalName; |
885 | while ( leftOffset < rightOffset ) { | 889 | while ( leftOffset < rightOffset ) { |
886 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 890 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
887 | leftOffset++; | 891 | leftOffset++; |
888 | } | 892 | } |
889 | setAdditionalName( additionalName ); | 893 | setAdditionalName( additionalName ); |
890 | } else { | 894 | } else { |
891 | QString part1 = str.left( i ); | 895 | QString part1 = str.left( i ); |
892 | QString part2 = str.mid( i + 1 ); | 896 | QString part2 = str.mid( i + 1 ); |
893 | 897 | ||
894 | QStringList parts = QStringList::split( " ", part1 ); | 898 | QStringList parts = QStringList::split( " ", part1 ); |
895 | int leftOffset = 0; | 899 | int leftOffset = 0; |
896 | int rightOffset = parts.count() - 1; | 900 | int rightOffset = parts.count() - 1; |
897 | 901 | ||
898 | QString suffix; | 902 | QString suffix; |
899 | while ( rightOffset >= 0 ) { | 903 | while ( rightOffset >= 0 ) { |
900 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 904 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
901 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 905 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
902 | rightOffset--; | 906 | rightOffset--; |
903 | } else | 907 | } else |
904 | break; | 908 | break; |
905 | } | 909 | } |
906 | setSuffix( suffix ); | 910 | setSuffix( suffix ); |
907 | 911 | ||
908 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 912 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
909 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 913 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
910 | rightOffset--; | 914 | rightOffset--; |
911 | } else | 915 | } else |
912 | setFamilyName( parts[ rightOffset ] ); | 916 | setFamilyName( parts[ rightOffset ] ); |
913 | 917 | ||
914 | QString prefix; | 918 | QString prefix; |
915 | while ( leftOffset < rightOffset ) { | 919 | while ( leftOffset < rightOffset ) { |
916 | if ( titles.contains( parts[ leftOffset ] ) ) { | 920 | if ( titles.contains( parts[ leftOffset ] ) ) { |
917 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 921 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
918 | leftOffset++; | 922 | leftOffset++; |
919 | } else | 923 | } else |
920 | break; | 924 | break; |
921 | } | 925 | } |
922 | 926 | ||
923 | parts = QStringList::split( " ", part2 ); | 927 | parts = QStringList::split( " ", part2 ); |
924 | 928 | ||
925 | leftOffset = 0; | 929 | leftOffset = 0; |
926 | rightOffset = parts.count(); | 930 | rightOffset = parts.count(); |
927 | 931 | ||
928 | while ( leftOffset < rightOffset ) { | 932 | while ( leftOffset < rightOffset ) { |
929 | if ( titles.contains( parts[ leftOffset ] ) ) { | 933 | if ( titles.contains( parts[ leftOffset ] ) ) { |
930 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 934 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
931 | leftOffset++; | 935 | leftOffset++; |
932 | } else | 936 | } else |
933 | break; | 937 | break; |
934 | } | 938 | } |
935 | setPrefix( prefix ); | 939 | setPrefix( prefix ); |
936 | 940 | ||
937 | if ( leftOffset < rightOffset ) { | 941 | if ( leftOffset < rightOffset ) { |
938 | setGivenName( parts[ leftOffset ] ); | 942 | setGivenName( parts[ leftOffset ] ); |
939 | leftOffset++; | 943 | leftOffset++; |
940 | } | 944 | } |
941 | 945 | ||
942 | QString additionalName; | 946 | QString additionalName; |
943 | while ( leftOffset < rightOffset ) { | 947 | while ( leftOffset < rightOffset ) { |
944 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 948 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
945 | leftOffset++; | 949 | leftOffset++; |
946 | } | 950 | } |
947 | setAdditionalName( additionalName ); | 951 | setAdditionalName( additionalName ); |
948 | } | 952 | } |
949 | } | 953 | } |
950 | 954 | ||
951 | QString Addressee::realName() const | 955 | QString Addressee::realName() const |
952 | { | 956 | { |
953 | if ( !formattedName().isEmpty() ) | 957 | if ( !formattedName().isEmpty() ) |
954 | return formattedName(); | 958 | return formattedName(); |
955 | 959 | ||
956 | QString n = assembledName(); | 960 | QString n = assembledName(); |
957 | 961 | ||
958 | if ( n.isEmpty() ) | 962 | if ( n.isEmpty() ) |
959 | n = name(); | 963 | n = name(); |
960 | 964 | ||
961 | return n; | 965 | return n; |
962 | } | 966 | } |
963 | 967 | ||
964 | QString Addressee::assembledName() const | 968 | QString Addressee::assembledName() const |
965 | { | 969 | { |
966 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 970 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
967 | familyName() + " " + suffix(); | 971 | familyName() + " " + suffix(); |
968 | 972 | ||
969 | return name.simplifyWhiteSpace(); | 973 | return name.simplifyWhiteSpace(); |
970 | } | 974 | } |
971 | 975 | ||
972 | QString Addressee::fullEmail( const QString &email ) const | 976 | QString Addressee::fullEmail( const QString &email ) const |
973 | { | 977 | { |
974 | QString e; | 978 | QString e; |
975 | if ( email.isNull() ) { | 979 | if ( email.isNull() ) { |
976 | e = preferredEmail(); | 980 | e = preferredEmail(); |
977 | } else { | 981 | } else { |
978 | e = email; | 982 | e = email; |
979 | } | 983 | } |
980 | if ( e.isEmpty() ) return QString::null; | 984 | if ( e.isEmpty() ) return QString::null; |
981 | 985 | ||
982 | QString text; | 986 | QString text; |
983 | if ( realName().isEmpty() ) | 987 | if ( realName().isEmpty() ) |
984 | text = e; | 988 | text = e; |
985 | else | 989 | else |
986 | text = assembledName() + " <" + e + ">"; | 990 | text = assembledName() + " <" + e + ">"; |
987 | 991 | ||
988 | return text; | 992 | return text; |
989 | } | 993 | } |
990 | 994 | ||
991 | void Addressee::insertEmail( const QString &email, bool preferred ) | 995 | void Addressee::insertEmail( const QString &email, bool preferred ) |
992 | { | 996 | { |
993 | detach(); | 997 | detach(); |
994 | 998 | ||
995 | QStringList::Iterator it = mData->emails.find( email ); | 999 | QStringList::Iterator it = mData->emails.find( email ); |
996 | 1000 | ||
997 | if ( it != mData->emails.end() ) { | 1001 | if ( it != mData->emails.end() ) { |
998 | if ( !preferred || it == mData->emails.begin() ) return; | 1002 | if ( !preferred || it == mData->emails.begin() ) return; |
999 | mData->emails.remove( it ); | 1003 | mData->emails.remove( it ); |
1000 | mData->emails.prepend( email ); | 1004 | mData->emails.prepend( email ); |
1001 | } else { | 1005 | } else { |
1002 | if ( preferred ) { | 1006 | if ( preferred ) { |
1003 | mData->emails.prepend( email ); | 1007 | mData->emails.prepend( email ); |
1004 | } else { | 1008 | } else { |
1005 | mData->emails.append( email ); | 1009 | mData->emails.append( email ); |
1006 | } | 1010 | } |
1007 | } | 1011 | } |
1008 | } | 1012 | } |
1009 | 1013 | ||
1010 | void Addressee::removeEmail( const QString &email ) | 1014 | void Addressee::removeEmail( const QString &email ) |
1011 | { | 1015 | { |
1012 | detach(); | 1016 | detach(); |
1013 | 1017 | ||
1014 | QStringList::Iterator it = mData->emails.find( email ); | 1018 | QStringList::Iterator it = mData->emails.find( email ); |
1015 | if ( it == mData->emails.end() ) return; | 1019 | if ( it == mData->emails.end() ) return; |
1016 | 1020 | ||
1017 | mData->emails.remove( it ); | 1021 | mData->emails.remove( it ); |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | QString Addressee::preferredEmail() const | 1024 | QString Addressee::preferredEmail() const |
1021 | { | 1025 | { |
1022 | if ( mData->emails.count() == 0 ) return QString::null; | 1026 | if ( mData->emails.count() == 0 ) return QString::null; |
1023 | else return mData->emails.first(); | 1027 | else return mData->emails.first(); |
1024 | } | 1028 | } |