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 | |||
@@ -708,221 +708,225 @@ void Addressee::setSecrecy( const Secrecy &secrecy ) | |||
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 ) { |