-rw-r--r-- | kabc/addressee.cpp | 6 | ||||
-rw-r--r-- | kabc/addressee.h | 6 | ||||
-rw-r--r-- | kabc/field.cpp | 24 |
3 files changed, 32 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 5cb194a..d484073 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -742,875 +742,881 @@ void Addressee::setPhoto( const Picture &photo ) | |||
742 | mData->photo = photo; | 742 | mData->photo = photo; |
743 | } | 743 | } |
744 | 744 | ||
745 | Picture Addressee::photo() const | 745 | Picture Addressee::photo() const |
746 | { | 746 | { |
747 | return mData->photo; | 747 | return mData->photo; |
748 | } | 748 | } |
749 | 749 | ||
750 | QString Addressee::photoLabel() | 750 | QString Addressee::photoLabel() |
751 | { | 751 | { |
752 | return i18n("Photo"); | 752 | return i18n("Photo"); |
753 | } | 753 | } |
754 | 754 | ||
755 | 755 | ||
756 | void Addressee::setSound( const Sound &sound ) | 756 | void Addressee::setSound( const Sound &sound ) |
757 | { | 757 | { |
758 | if ( sound == mData->sound ) return; | 758 | if ( sound == mData->sound ) return; |
759 | detach(); | 759 | detach(); |
760 | mData->empty = false; | 760 | mData->empty = false; |
761 | mData->sound = sound; | 761 | mData->sound = sound; |
762 | } | 762 | } |
763 | 763 | ||
764 | Sound Addressee::sound() const | 764 | Sound Addressee::sound() const |
765 | { | 765 | { |
766 | return mData->sound; | 766 | return mData->sound; |
767 | } | 767 | } |
768 | 768 | ||
769 | QString Addressee::soundLabel() | 769 | QString Addressee::soundLabel() |
770 | { | 770 | { |
771 | return i18n("Sound"); | 771 | return i18n("Sound"); |
772 | } | 772 | } |
773 | 773 | ||
774 | 774 | ||
775 | void Addressee::setAgent( const Agent &agent ) | 775 | void Addressee::setAgent( const Agent &agent ) |
776 | { | 776 | { |
777 | if ( agent == mData->agent ) return; | 777 | if ( agent == mData->agent ) return; |
778 | detach(); | 778 | detach(); |
779 | mData->empty = false; | 779 | mData->empty = false; |
780 | mData->agent = agent; | 780 | mData->agent = agent; |
781 | } | 781 | } |
782 | 782 | ||
783 | Agent Addressee::agent() const | 783 | Agent Addressee::agent() const |
784 | { | 784 | { |
785 | return mData->agent; | 785 | return mData->agent; |
786 | } | 786 | } |
787 | 787 | ||
788 | QString Addressee::agentLabel() | 788 | QString Addressee::agentLabel() |
789 | { | 789 | { |
790 | return i18n("Agent"); | 790 | return i18n("Agent"); |
791 | } | 791 | } |
792 | 792 | ||
793 | 793 | ||
794 | 794 | ||
795 | void Addressee::setNameFromString( const QString &str ) | 795 | void Addressee::setNameFromString( const QString &str ) |
796 | { | 796 | { |
797 | setFormattedName( str ); | 797 | setFormattedName( str ); |
798 | setName( str ); | 798 | setName( str ); |
799 | 799 | ||
800 | QStringList titles; | 800 | QStringList titles; |
801 | titles += i18n( "Dr." ); | 801 | titles += i18n( "Dr." ); |
802 | titles += i18n( "Miss" ); | 802 | titles += i18n( "Miss" ); |
803 | titles += i18n( "Mr." ); | 803 | titles += i18n( "Mr." ); |
804 | titles += i18n( "Mrs." ); | 804 | titles += i18n( "Mrs." ); |
805 | titles += i18n( "Ms." ); | 805 | titles += i18n( "Ms." ); |
806 | titles += i18n( "Prof." ); | 806 | titles += i18n( "Prof." ); |
807 | 807 | ||
808 | QStringList suffixes; | 808 | QStringList suffixes; |
809 | suffixes += i18n( "I" ); | 809 | suffixes += i18n( "I" ); |
810 | suffixes += i18n( "II" ); | 810 | suffixes += i18n( "II" ); |
811 | suffixes += i18n( "III" ); | 811 | suffixes += i18n( "III" ); |
812 | suffixes += i18n( "Jr." ); | 812 | suffixes += i18n( "Jr." ); |
813 | suffixes += i18n( "Sr." ); | 813 | suffixes += i18n( "Sr." ); |
814 | 814 | ||
815 | QStringList prefixes; | 815 | QStringList prefixes; |
816 | prefixes += "van"; | 816 | prefixes += "van"; |
817 | prefixes += "von"; | 817 | prefixes += "von"; |
818 | prefixes += "de"; | 818 | prefixes += "de"; |
819 | 819 | ||
820 | //US KConfig config( "kabcrc" ); | 820 | //US KConfig config( "kabcrc" ); |
821 | KConfig config( locateLocal( "config", "kabcrc") ); | 821 | KConfig config( locateLocal( "config", "kabcrc") ); |
822 | config.setGroup( "General" ); | 822 | config.setGroup( "General" ); |
823 | titles += config.readListEntry( "Prefixes" ); | 823 | titles += config.readListEntry( "Prefixes" ); |
824 | titles.remove( "" ); | 824 | titles.remove( "" ); |
825 | prefixes += config.readListEntry( "Inclusions" ); | 825 | prefixes += config.readListEntry( "Inclusions" ); |
826 | prefixes.remove( "" ); | 826 | prefixes.remove( "" ); |
827 | suffixes += config.readListEntry( "Suffixes" ); | 827 | suffixes += config.readListEntry( "Suffixes" ); |
828 | suffixes.remove( "" ); | 828 | suffixes.remove( "" ); |
829 | 829 | ||
830 | // clear all name parts | 830 | // clear all name parts |
831 | setPrefix( "" ); | 831 | setPrefix( "" ); |
832 | setGivenName( "" ); | 832 | setGivenName( "" ); |
833 | setAdditionalName( "" ); | 833 | setAdditionalName( "" ); |
834 | setFamilyName( "" ); | 834 | setFamilyName( "" ); |
835 | setSuffix( "" ); | 835 | setSuffix( "" ); |
836 | 836 | ||
837 | if ( str.isEmpty() ) | 837 | if ( str.isEmpty() ) |
838 | return; | 838 | return; |
839 | 839 | ||
840 | int i = str.find(','); | 840 | int i = str.find(','); |
841 | if( i < 0 ) { | 841 | if( i < 0 ) { |
842 | QStringList parts = QStringList::split( " ", str ); | 842 | QStringList parts = QStringList::split( " ", str ); |
843 | int leftOffset = 0; | 843 | int leftOffset = 0; |
844 | int rightOffset = parts.count() - 1; | 844 | int rightOffset = parts.count() - 1; |
845 | 845 | ||
846 | QString suffix; | 846 | QString suffix; |
847 | while ( rightOffset >= 0 ) { | 847 | while ( rightOffset >= 0 ) { |
848 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 848 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
849 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 849 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
850 | rightOffset--; | 850 | rightOffset--; |
851 | } else | 851 | } else |
852 | break; | 852 | break; |
853 | } | 853 | } |
854 | setSuffix( suffix ); | 854 | setSuffix( suffix ); |
855 | 855 | ||
856 | if ( rightOffset < 0 ) | 856 | if ( rightOffset < 0 ) |
857 | return; | 857 | return; |
858 | 858 | ||
859 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 859 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
860 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 860 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
861 | rightOffset--; | 861 | rightOffset--; |
862 | } else | 862 | } else |
863 | setFamilyName( parts[ rightOffset ] ); | 863 | setFamilyName( parts[ rightOffset ] ); |
864 | 864 | ||
865 | QString prefix; | 865 | QString prefix; |
866 | while ( leftOffset < rightOffset ) { | 866 | while ( leftOffset < rightOffset ) { |
867 | if ( titles.contains( parts[ leftOffset ] ) ) { | 867 | if ( titles.contains( parts[ leftOffset ] ) ) { |
868 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 868 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
869 | leftOffset++; | 869 | leftOffset++; |
870 | } else | 870 | } else |
871 | break; | 871 | break; |
872 | } | 872 | } |
873 | setPrefix( prefix ); | 873 | setPrefix( prefix ); |
874 | 874 | ||
875 | if ( leftOffset < rightOffset ) { | 875 | if ( leftOffset < rightOffset ) { |
876 | setGivenName( parts[ leftOffset ] ); | 876 | setGivenName( parts[ leftOffset ] ); |
877 | leftOffset++; | 877 | leftOffset++; |
878 | } | 878 | } |
879 | 879 | ||
880 | QString additionalName; | 880 | QString additionalName; |
881 | while ( leftOffset < rightOffset ) { | 881 | while ( leftOffset < rightOffset ) { |
882 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 882 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
883 | leftOffset++; | 883 | leftOffset++; |
884 | } | 884 | } |
885 | setAdditionalName( additionalName ); | 885 | setAdditionalName( additionalName ); |
886 | } else { | 886 | } else { |
887 | QString part1 = str.left( i ); | 887 | QString part1 = str.left( i ); |
888 | QString part2 = str.mid( i + 1 ); | 888 | QString part2 = str.mid( i + 1 ); |
889 | 889 | ||
890 | QStringList parts = QStringList::split( " ", part1 ); | 890 | QStringList parts = QStringList::split( " ", part1 ); |
891 | int leftOffset = 0; | 891 | int leftOffset = 0; |
892 | int rightOffset = parts.count() - 1; | 892 | int rightOffset = parts.count() - 1; |
893 | 893 | ||
894 | QString suffix; | 894 | QString suffix; |
895 | while ( rightOffset >= 0 ) { | 895 | while ( rightOffset >= 0 ) { |
896 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 896 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
897 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 897 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
898 | rightOffset--; | 898 | rightOffset--; |
899 | } else | 899 | } else |
900 | break; | 900 | break; |
901 | } | 901 | } |
902 | setSuffix( suffix ); | 902 | setSuffix( suffix ); |
903 | 903 | ||
904 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 904 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
905 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 905 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
906 | rightOffset--; | 906 | rightOffset--; |
907 | } else | 907 | } else |
908 | setFamilyName( parts[ rightOffset ] ); | 908 | setFamilyName( parts[ rightOffset ] ); |
909 | 909 | ||
910 | QString prefix; | 910 | QString prefix; |
911 | while ( leftOffset < rightOffset ) { | 911 | while ( leftOffset < rightOffset ) { |
912 | if ( titles.contains( parts[ leftOffset ] ) ) { | 912 | if ( titles.contains( parts[ leftOffset ] ) ) { |
913 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 913 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
914 | leftOffset++; | 914 | leftOffset++; |
915 | } else | 915 | } else |
916 | break; | 916 | break; |
917 | } | 917 | } |
918 | 918 | ||
919 | parts = QStringList::split( " ", part2 ); | 919 | parts = QStringList::split( " ", part2 ); |
920 | 920 | ||
921 | leftOffset = 0; | 921 | leftOffset = 0; |
922 | rightOffset = parts.count(); | 922 | rightOffset = parts.count(); |
923 | 923 | ||
924 | while ( leftOffset < rightOffset ) { | 924 | while ( leftOffset < rightOffset ) { |
925 | if ( titles.contains( parts[ leftOffset ] ) ) { | 925 | if ( titles.contains( parts[ leftOffset ] ) ) { |
926 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 926 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
927 | leftOffset++; | 927 | leftOffset++; |
928 | } else | 928 | } else |
929 | break; | 929 | break; |
930 | } | 930 | } |
931 | setPrefix( prefix ); | 931 | setPrefix( prefix ); |
932 | 932 | ||
933 | if ( leftOffset < rightOffset ) { | 933 | if ( leftOffset < rightOffset ) { |
934 | setGivenName( parts[ leftOffset ] ); | 934 | setGivenName( parts[ leftOffset ] ); |
935 | leftOffset++; | 935 | leftOffset++; |
936 | } | 936 | } |
937 | 937 | ||
938 | QString additionalName; | 938 | QString additionalName; |
939 | while ( leftOffset < rightOffset ) { | 939 | while ( leftOffset < rightOffset ) { |
940 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 940 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
941 | leftOffset++; | 941 | leftOffset++; |
942 | } | 942 | } |
943 | setAdditionalName( additionalName ); | 943 | setAdditionalName( additionalName ); |
944 | } | 944 | } |
945 | } | 945 | } |
946 | 946 | ||
947 | QString Addressee::realName() const | 947 | QString Addressee::realName() const |
948 | { | 948 | { |
949 | if ( !formattedName().isEmpty() ) | 949 | if ( !formattedName().isEmpty() ) |
950 | return formattedName(); | 950 | return formattedName(); |
951 | 951 | ||
952 | QString n = assembledName(); | 952 | QString n = assembledName(); |
953 | 953 | ||
954 | if ( n.isEmpty() ) | 954 | if ( n.isEmpty() ) |
955 | n = name(); | 955 | n = name(); |
956 | 956 | ||
957 | return n; | 957 | return n; |
958 | } | 958 | } |
959 | 959 | ||
960 | QString Addressee::assembledName() const | 960 | QString Addressee::assembledName() const |
961 | { | 961 | { |
962 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 962 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
963 | familyName() + " " + suffix(); | 963 | familyName() + " " + suffix(); |
964 | 964 | ||
965 | return name.simplifyWhiteSpace(); | 965 | return name.simplifyWhiteSpace(); |
966 | } | 966 | } |
967 | 967 | ||
968 | QString Addressee::fullEmail( const QString &email ) const | 968 | QString Addressee::fullEmail( const QString &email ) const |
969 | { | 969 | { |
970 | QString e; | 970 | QString e; |
971 | if ( email.isNull() ) { | 971 | if ( email.isNull() ) { |
972 | e = preferredEmail(); | 972 | e = preferredEmail(); |
973 | } else { | 973 | } else { |
974 | e = email; | 974 | e = email; |
975 | } | 975 | } |
976 | if ( e.isEmpty() ) return QString::null; | 976 | if ( e.isEmpty() ) return QString::null; |
977 | 977 | ||
978 | QString text; | 978 | QString text; |
979 | if ( realName().isEmpty() ) | 979 | if ( realName().isEmpty() ) |
980 | text = e; | 980 | text = e; |
981 | else | 981 | else |
982 | text = assembledName() + " <" + e + ">"; | 982 | text = assembledName() + " <" + e + ">"; |
983 | 983 | ||
984 | return text; | 984 | return text; |
985 | } | 985 | } |
986 | 986 | ||
987 | void Addressee::insertEmail( const QString &email, bool preferred ) | 987 | void Addressee::insertEmail( const QString &email, bool preferred ) |
988 | { | 988 | { |
989 | detach(); | 989 | detach(); |
990 | 990 | ||
991 | QStringList::Iterator it = mData->emails.find( email ); | 991 | QStringList::Iterator it = mData->emails.find( email ); |
992 | 992 | ||
993 | if ( it != mData->emails.end() ) { | 993 | if ( it != mData->emails.end() ) { |
994 | if ( !preferred || it == mData->emails.begin() ) return; | 994 | if ( !preferred || it == mData->emails.begin() ) return; |
995 | mData->emails.remove( it ); | 995 | mData->emails.remove( it ); |
996 | mData->emails.prepend( email ); | 996 | mData->emails.prepend( email ); |
997 | } else { | 997 | } else { |
998 | if ( preferred ) { | 998 | if ( preferred ) { |
999 | mData->emails.prepend( email ); | 999 | mData->emails.prepend( email ); |
1000 | } else { | 1000 | } else { |
1001 | mData->emails.append( email ); | 1001 | mData->emails.append( email ); |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | void Addressee::removeEmail( const QString &email ) | 1006 | void Addressee::removeEmail( const QString &email ) |
1007 | { | 1007 | { |
1008 | detach(); | 1008 | detach(); |
1009 | 1009 | ||
1010 | QStringList::Iterator it = mData->emails.find( email ); | 1010 | QStringList::Iterator it = mData->emails.find( email ); |
1011 | if ( it == mData->emails.end() ) return; | 1011 | if ( it == mData->emails.end() ) return; |
1012 | 1012 | ||
1013 | mData->emails.remove( it ); | 1013 | mData->emails.remove( it ); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | QString Addressee::preferredEmail() const | 1016 | QString Addressee::preferredEmail() const |
1017 | { | 1017 | { |
1018 | if ( mData->emails.count() == 0 ) return QString::null; | 1018 | if ( mData->emails.count() == 0 ) return QString::null; |
1019 | else return mData->emails.first(); | 1019 | else return mData->emails.first(); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | QStringList Addressee::emails() const | 1022 | QStringList Addressee::emails() const |
1023 | { | 1023 | { |
1024 | return mData->emails; | 1024 | return mData->emails; |
1025 | } | 1025 | } |
1026 | void Addressee::setEmails( const QStringList& emails ) { | 1026 | void Addressee::setEmails( const QStringList& emails ) { |
1027 | detach(); | 1027 | detach(); |
1028 | mData->emails = emails; | 1028 | mData->emails = emails; |
1029 | } | 1029 | } |
1030 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1030 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1031 | { | 1031 | { |
1032 | detach(); | 1032 | detach(); |
1033 | mData->empty = false; | 1033 | mData->empty = false; |
1034 | 1034 | ||
1035 | PhoneNumber::List::Iterator it; | 1035 | PhoneNumber::List::Iterator it; |
1036 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1036 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1037 | if ( (*it).id() == phoneNumber.id() ) { | 1037 | if ( (*it).id() == phoneNumber.id() ) { |
1038 | *it = phoneNumber; | 1038 | *it = phoneNumber; |
1039 | return; | 1039 | return; |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | mData->phoneNumbers.append( phoneNumber ); | 1042 | mData->phoneNumbers.append( phoneNumber ); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1045 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1046 | { | 1046 | { |
1047 | detach(); | 1047 | detach(); |
1048 | 1048 | ||
1049 | PhoneNumber::List::Iterator it; | 1049 | PhoneNumber::List::Iterator it; |
1050 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1050 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1051 | if ( (*it).id() == phoneNumber.id() ) { | 1051 | if ( (*it).id() == phoneNumber.id() ) { |
1052 | mData->phoneNumbers.remove( it ); | 1052 | mData->phoneNumbers.remove( it ); |
1053 | return; | 1053 | return; |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | PhoneNumber Addressee::phoneNumber( int type ) const | 1058 | PhoneNumber Addressee::phoneNumber( int type ) const |
1059 | { | 1059 | { |
1060 | PhoneNumber phoneNumber( "", type ); | 1060 | PhoneNumber phoneNumber( "", type ); |
1061 | PhoneNumber::List::ConstIterator it; | 1061 | PhoneNumber::List::ConstIterator it; |
1062 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1062 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1063 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1063 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1064 | if ( (*it).type() & PhoneNumber::Pref ) | 1064 | if ( (*it).type() & PhoneNumber::Pref ) |
1065 | return (*it); | 1065 | return (*it); |
1066 | else if ( phoneNumber.number().isEmpty() ) | 1066 | else if ( phoneNumber.number().isEmpty() ) |
1067 | phoneNumber = (*it); | 1067 | phoneNumber = (*it); |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | return phoneNumber; | 1071 | return phoneNumber; |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | PhoneNumber::List Addressee::phoneNumbers() const | 1074 | PhoneNumber::List Addressee::phoneNumbers() const |
1075 | { | 1075 | { |
1076 | return mData->phoneNumbers; | 1076 | return mData->phoneNumbers; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1079 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1080 | { | 1080 | { |
1081 | PhoneNumber::List list; | 1081 | PhoneNumber::List list; |
1082 | 1082 | ||
1083 | PhoneNumber::List::ConstIterator it; | 1083 | PhoneNumber::List::ConstIterator it; |
1084 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1084 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1085 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1085 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1086 | list.append( *it ); | 1086 | list.append( *it ); |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | return list; | 1089 | return list; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1092 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1093 | { | 1093 | { |
1094 | PhoneNumber::List::ConstIterator it; | 1094 | PhoneNumber::List::ConstIterator it; |
1095 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1095 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1096 | if ( (*it).id() == id ) { | 1096 | if ( (*it).id() == id ) { |
1097 | return *it; | 1097 | return *it; |
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | return PhoneNumber(); | 1100 | return PhoneNumber(); |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | void Addressee::insertKey( const Key &key ) | 1103 | void Addressee::insertKey( const Key &key ) |
1104 | { | 1104 | { |
1105 | detach(); | 1105 | detach(); |
1106 | mData->empty = false; | 1106 | mData->empty = false; |
1107 | 1107 | ||
1108 | Key::List::Iterator it; | 1108 | Key::List::Iterator it; |
1109 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1109 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1110 | if ( (*it).id() == key.id() ) { | 1110 | if ( (*it).id() == key.id() ) { |
1111 | *it = key; | 1111 | *it = key; |
1112 | return; | 1112 | return; |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | mData->keys.append( key ); | 1115 | mData->keys.append( key ); |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | void Addressee::removeKey( const Key &key ) | 1118 | void Addressee::removeKey( const Key &key ) |
1119 | { | 1119 | { |
1120 | detach(); | 1120 | detach(); |
1121 | 1121 | ||
1122 | Key::List::Iterator it; | 1122 | Key::List::Iterator it; |
1123 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1123 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1124 | if ( (*it).id() == key.id() ) { | 1124 | if ( (*it).id() == key.id() ) { |
1125 | mData->keys.remove( key ); | 1125 | mData->keys.remove( key ); |
1126 | return; | 1126 | return; |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | Key Addressee::key( int type, QString customTypeString ) const | 1131 | Key Addressee::key( int type, QString customTypeString ) const |
1132 | { | 1132 | { |
1133 | Key::List::ConstIterator it; | 1133 | Key::List::ConstIterator it; |
1134 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1134 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1135 | if ( (*it).type() == type ) { | 1135 | if ( (*it).type() == type ) { |
1136 | if ( type == Key::Custom ) { | 1136 | if ( type == Key::Custom ) { |
1137 | if ( customTypeString.isEmpty() ) { | 1137 | if ( customTypeString.isEmpty() ) { |
1138 | return *it; | 1138 | return *it; |
1139 | } else { | 1139 | } else { |
1140 | if ( (*it).customTypeString() == customTypeString ) | 1140 | if ( (*it).customTypeString() == customTypeString ) |
1141 | return (*it); | 1141 | return (*it); |
1142 | } | 1142 | } |
1143 | } else { | 1143 | } else { |
1144 | return *it; | 1144 | return *it; |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | return Key( QString(), type ); | 1148 | return Key( QString(), type ); |
1149 | } | 1149 | } |
1150 | void Addressee::setKeys( const Key::List& list ) { | 1150 | void Addressee::setKeys( const Key::List& list ) { |
1151 | detach(); | 1151 | detach(); |
1152 | mData->keys = list; | 1152 | mData->keys = list; |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | Key::List Addressee::keys() const | 1155 | Key::List Addressee::keys() const |
1156 | { | 1156 | { |
1157 | return mData->keys; | 1157 | return mData->keys; |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1160 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1161 | { | 1161 | { |
1162 | Key::List list; | 1162 | Key::List list; |
1163 | 1163 | ||
1164 | Key::List::ConstIterator it; | 1164 | Key::List::ConstIterator it; |
1165 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1165 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1166 | if ( (*it).type() == type ) { | 1166 | if ( (*it).type() == type ) { |
1167 | if ( type == Key::Custom ) { | 1167 | if ( type == Key::Custom ) { |
1168 | if ( customTypeString.isEmpty() ) { | 1168 | if ( customTypeString.isEmpty() ) { |
1169 | list.append(*it); | 1169 | list.append(*it); |
1170 | } else { | 1170 | } else { |
1171 | if ( (*it).customTypeString() == customTypeString ) | 1171 | if ( (*it).customTypeString() == customTypeString ) |
1172 | list.append(*it); | 1172 | list.append(*it); |
1173 | } | 1173 | } |
1174 | } else { | 1174 | } else { |
1175 | list.append(*it); | 1175 | list.append(*it); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | return list; | 1179 | return list; |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | Key Addressee::findKey( const QString &id ) const | 1182 | Key Addressee::findKey( const QString &id ) const |
1183 | { | 1183 | { |
1184 | Key::List::ConstIterator it; | 1184 | Key::List::ConstIterator it; |
1185 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1185 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1186 | if ( (*it).id() == id ) { | 1186 | if ( (*it).id() == id ) { |
1187 | return *it; | 1187 | return *it; |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | return Key(); | 1190 | return Key(); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | QString Addressee::asString() const | 1193 | QString Addressee::asString() const |
1194 | { | 1194 | { |
1195 | return "Smith, agent Smith..."; | 1195 | return "Smith, agent Smith..."; |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | void Addressee::dump() const | 1198 | void Addressee::dump() const |
1199 | { | 1199 | { |
1200 | return; | 1200 | return; |
1201 | kdDebug(5700) << "Addressee {" << endl; | 1201 | kdDebug(5700) << "Addressee {" << endl; |
1202 | 1202 | ||
1203 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1203 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1204 | 1204 | ||
1205 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1205 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1206 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1206 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1207 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1207 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1208 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1208 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1209 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1209 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1210 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1210 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1211 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1211 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1212 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1212 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1213 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1213 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1214 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1214 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1215 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1215 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1216 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1216 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1217 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1217 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1218 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1218 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1219 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1219 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1220 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1220 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1221 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1221 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1222 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1222 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1223 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1223 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1224 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1224 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1225 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1225 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1226 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1226 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1227 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1227 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1228 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1228 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1229 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1229 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1230 | 1230 | ||
1231 | kdDebug(5700) << " Emails {" << endl; | 1231 | kdDebug(5700) << " Emails {" << endl; |
1232 | QStringList e = emails(); | 1232 | QStringList e = emails(); |
1233 | QStringList::ConstIterator it; | 1233 | QStringList::ConstIterator it; |
1234 | for( it = e.begin(); it != e.end(); ++it ) { | 1234 | for( it = e.begin(); it != e.end(); ++it ) { |
1235 | kdDebug(5700) << " " << (*it) << endl; | 1235 | kdDebug(5700) << " " << (*it) << endl; |
1236 | } | 1236 | } |
1237 | kdDebug(5700) << " }" << endl; | 1237 | kdDebug(5700) << " }" << endl; |
1238 | 1238 | ||
1239 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1239 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1240 | PhoneNumber::List p = phoneNumbers(); | 1240 | PhoneNumber::List p = phoneNumbers(); |
1241 | PhoneNumber::List::ConstIterator it2; | 1241 | PhoneNumber::List::ConstIterator it2; |
1242 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1242 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1243 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1243 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1244 | } | 1244 | } |
1245 | kdDebug(5700) << " }" << endl; | 1245 | kdDebug(5700) << " }" << endl; |
1246 | 1246 | ||
1247 | Address::List a = addresses(); | 1247 | Address::List a = addresses(); |
1248 | Address::List::ConstIterator it3; | 1248 | Address::List::ConstIterator it3; |
1249 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1249 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1250 | (*it3).dump(); | 1250 | (*it3).dump(); |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | kdDebug(5700) << " Keys {" << endl; | 1253 | kdDebug(5700) << " Keys {" << endl; |
1254 | Key::List k = keys(); | 1254 | Key::List k = keys(); |
1255 | Key::List::ConstIterator it4; | 1255 | Key::List::ConstIterator it4; |
1256 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1256 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1257 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1257 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1258 | " Key: " << (*it4).textData() << | 1258 | " Key: " << (*it4).textData() << |
1259 | " CustomString: " << (*it4).customTypeString() << endl; | 1259 | " CustomString: " << (*it4).customTypeString() << endl; |
1260 | } | 1260 | } |
1261 | kdDebug(5700) << " }" << endl; | 1261 | kdDebug(5700) << " }" << endl; |
1262 | 1262 | ||
1263 | kdDebug(5700) << "}" << endl; | 1263 | kdDebug(5700) << "}" << endl; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | 1266 | ||
1267 | void Addressee::insertAddress( const Address &address ) | 1267 | void Addressee::insertAddress( const Address &address ) |
1268 | { | 1268 | { |
1269 | detach(); | 1269 | detach(); |
1270 | mData->empty = false; | 1270 | mData->empty = false; |
1271 | 1271 | ||
1272 | Address::List::Iterator it; | 1272 | Address::List::Iterator it; |
1273 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1273 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1274 | if ( (*it).id() == address.id() ) { | 1274 | if ( (*it).id() == address.id() ) { |
1275 | *it = address; | 1275 | *it = address; |
1276 | return; | 1276 | return; |
1277 | } | 1277 | } |
1278 | } | 1278 | } |
1279 | mData->addresses.append( address ); | 1279 | mData->addresses.append( address ); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | void Addressee::removeAddress( const Address &address ) | 1282 | void Addressee::removeAddress( const Address &address ) |
1283 | { | 1283 | { |
1284 | detach(); | 1284 | detach(); |
1285 | 1285 | ||
1286 | Address::List::Iterator it; | 1286 | Address::List::Iterator it; |
1287 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1287 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1288 | if ( (*it).id() == address.id() ) { | 1288 | if ( (*it).id() == address.id() ) { |
1289 | mData->addresses.remove( it ); | 1289 | mData->addresses.remove( it ); |
1290 | return; | 1290 | return; |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | Address Addressee::address( int type ) const | 1295 | Address Addressee::address( int type ) const |
1296 | { | 1296 | { |
1297 | Address address( type ); | 1297 | Address address( type ); |
1298 | Address::List::ConstIterator it; | 1298 | Address::List::ConstIterator it; |
1299 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1299 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1300 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1300 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1301 | if ( (*it).type() & Address::Pref ) | 1301 | if ( (*it).type() & Address::Pref ) |
1302 | return (*it); | 1302 | return (*it); |
1303 | else if ( address.isEmpty() ) | 1303 | else if ( address.isEmpty() ) |
1304 | address = (*it); | 1304 | address = (*it); |
1305 | } | 1305 | } |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | return address; | 1308 | return address; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | Address::List Addressee::addresses() const | 1311 | Address::List Addressee::addresses() const |
1312 | { | 1312 | { |
1313 | return mData->addresses; | 1313 | return mData->addresses; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | Address::List Addressee::addresses( int type ) const | 1316 | Address::List Addressee::addresses( int type ) const |
1317 | { | 1317 | { |
1318 | Address::List list; | 1318 | Address::List list; |
1319 | 1319 | ||
1320 | Address::List::ConstIterator it; | 1320 | Address::List::ConstIterator it; |
1321 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1321 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1322 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1322 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1323 | list.append( *it ); | 1323 | list.append( *it ); |
1324 | } | 1324 | } |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | return list; | 1327 | return list; |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | Address Addressee::findAddress( const QString &id ) const | 1330 | Address Addressee::findAddress( const QString &id ) const |
1331 | { | 1331 | { |
1332 | Address::List::ConstIterator it; | 1332 | Address::List::ConstIterator it; |
1333 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1333 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1334 | if ( (*it).id() == id ) { | 1334 | if ( (*it).id() == id ) { |
1335 | return *it; | 1335 | return *it; |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | return Address(); | 1338 | return Address(); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | void Addressee::insertCategory( const QString &c ) | 1341 | void Addressee::insertCategory( const QString &c ) |
1342 | { | 1342 | { |
1343 | detach(); | 1343 | detach(); |
1344 | mData->empty = false; | 1344 | mData->empty = false; |
1345 | 1345 | ||
1346 | if ( mData->categories.contains( c ) ) return; | 1346 | if ( mData->categories.contains( c ) ) return; |
1347 | 1347 | ||
1348 | mData->categories.append( c ); | 1348 | mData->categories.append( c ); |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | void Addressee::removeCategory( const QString &c ) | 1351 | void Addressee::removeCategory( const QString &c ) |
1352 | { | 1352 | { |
1353 | detach(); | 1353 | detach(); |
1354 | 1354 | ||
1355 | QStringList::Iterator it = mData->categories.find( c ); | 1355 | QStringList::Iterator it = mData->categories.find( c ); |
1356 | if ( it == mData->categories.end() ) return; | 1356 | if ( it == mData->categories.end() ) return; |
1357 | 1357 | ||
1358 | mData->categories.remove( it ); | 1358 | mData->categories.remove( it ); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | bool Addressee::hasCategory( const QString &c ) const | 1361 | bool Addressee::hasCategory( const QString &c ) const |
1362 | { | 1362 | { |
1363 | return ( mData->categories.contains( c ) ); | 1363 | return ( mData->categories.contains( c ) ); |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void Addressee::setCategories( const QStringList &c ) | 1366 | void Addressee::setCategories( const QStringList &c ) |
1367 | { | 1367 | { |
1368 | detach(); | 1368 | detach(); |
1369 | mData->empty = false; | 1369 | mData->empty = false; |
1370 | 1370 | ||
1371 | mData->categories = c; | 1371 | mData->categories = c; |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | QStringList Addressee::categories() const | 1374 | QStringList Addressee::categories() const |
1375 | { | 1375 | { |
1376 | return mData->categories; | 1376 | return mData->categories; |
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | void Addressee::insertCustom( const QString &app, const QString &name, | 1379 | void Addressee::insertCustom( const QString &app, const QString &name, |
1380 | const QString &value ) | 1380 | const QString &value ) |
1381 | { | 1381 | { |
1382 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1382 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1383 | 1383 | ||
1384 | detach(); | 1384 | detach(); |
1385 | mData->empty = false; | 1385 | mData->empty = false; |
1386 | 1386 | ||
1387 | QString qualifiedName = app + "-" + name + ":"; | 1387 | QString qualifiedName = app + "-" + name + ":"; |
1388 | 1388 | ||
1389 | QStringList::Iterator it; | 1389 | QStringList::Iterator it; |
1390 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1390 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1391 | if ( (*it).startsWith( qualifiedName ) ) { | 1391 | if ( (*it).startsWith( qualifiedName ) ) { |
1392 | (*it) = qualifiedName + value; | 1392 | (*it) = qualifiedName + value; |
1393 | return; | 1393 | return; |
1394 | } | 1394 | } |
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | mData->custom.append( qualifiedName + value ); | 1397 | mData->custom.append( qualifiedName + value ); |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | void Addressee::removeCustom( const QString &app, const QString &name) | 1400 | void Addressee::removeCustom( const QString &app, const QString &name) |
1401 | { | 1401 | { |
1402 | detach(); | 1402 | detach(); |
1403 | 1403 | ||
1404 | QString qualifiedName = app + "-" + name + ":"; | 1404 | QString qualifiedName = app + "-" + name + ":"; |
1405 | 1405 | ||
1406 | QStringList::Iterator it; | 1406 | QStringList::Iterator it; |
1407 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1407 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1408 | if ( (*it).startsWith( qualifiedName ) ) { | 1408 | if ( (*it).startsWith( qualifiedName ) ) { |
1409 | mData->custom.remove( it ); | 1409 | mData->custom.remove( it ); |
1410 | return; | 1410 | return; |
1411 | } | 1411 | } |
1412 | } | 1412 | } |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | QString Addressee::custom( const QString &app, const QString &name ) const | 1415 | QString Addressee::custom( const QString &app, const QString &name ) const |
1416 | { | 1416 | { |
1417 | QString qualifiedName = app + "-" + name + ":"; | 1417 | QString qualifiedName = app + "-" + name + ":"; |
1418 | QString value; | 1418 | QString value; |
1419 | 1419 | ||
1420 | QStringList::ConstIterator it; | 1420 | QStringList::ConstIterator it; |
1421 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1421 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1422 | if ( (*it).startsWith( qualifiedName ) ) { | 1422 | if ( (*it).startsWith( qualifiedName ) ) { |
1423 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1423 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1424 | break; | 1424 | break; |
1425 | } | 1425 | } |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | return value; | 1428 | return value; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void Addressee::setCustoms( const QStringList &l ) | 1431 | void Addressee::setCustoms( const QStringList &l ) |
1432 | { | 1432 | { |
1433 | detach(); | 1433 | detach(); |
1434 | mData->empty = false; | 1434 | mData->empty = false; |
1435 | 1435 | ||
1436 | mData->custom = l; | 1436 | mData->custom = l; |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | QStringList Addressee::customs() const | 1439 | QStringList Addressee::customs() const |
1440 | { | 1440 | { |
1441 | return mData->custom; | 1441 | return mData->custom; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1444 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1445 | QString &email) | 1445 | QString &email) |
1446 | { | 1446 | { |
1447 | int startPos, endPos, len; | 1447 | int startPos, endPos, len; |
1448 | QString partA, partB, result; | 1448 | QString partA, partB, result; |
1449 | char endCh = '>'; | 1449 | char endCh = '>'; |
1450 | 1450 | ||
1451 | startPos = rawEmail.find('<'); | 1451 | startPos = rawEmail.find('<'); |
1452 | if (startPos < 0) | 1452 | if (startPos < 0) |
1453 | { | 1453 | { |
1454 | startPos = rawEmail.find('('); | 1454 | startPos = rawEmail.find('('); |
1455 | endCh = ')'; | 1455 | endCh = ')'; |
1456 | } | 1456 | } |
1457 | if (startPos < 0) | 1457 | if (startPos < 0) |
1458 | { | 1458 | { |
1459 | // We couldn't find any separators, so we assume the whole string | 1459 | // We couldn't find any separators, so we assume the whole string |
1460 | // is the email address | 1460 | // is the email address |
1461 | email = rawEmail; | 1461 | email = rawEmail; |
1462 | fullName = ""; | 1462 | fullName = ""; |
1463 | } | 1463 | } |
1464 | else | 1464 | else |
1465 | { | 1465 | { |
1466 | // We have a start position, try to find an end | 1466 | // We have a start position, try to find an end |
1467 | endPos = rawEmail.find(endCh, startPos+1); | 1467 | endPos = rawEmail.find(endCh, startPos+1); |
1468 | 1468 | ||
1469 | if (endPos < 0) | 1469 | if (endPos < 0) |
1470 | { | 1470 | { |
1471 | // We couldn't find the end of the email address. We can only | 1471 | // We couldn't find the end of the email address. We can only |
1472 | // assume the entire string is the email address. | 1472 | // assume the entire string is the email address. |
1473 | email = rawEmail; | 1473 | email = rawEmail; |
1474 | fullName = ""; | 1474 | fullName = ""; |
1475 | } | 1475 | } |
1476 | else | 1476 | else |
1477 | { | 1477 | { |
1478 | // We have a start and end to the email address | 1478 | // We have a start and end to the email address |
1479 | 1479 | ||
1480 | // Grab the name part | 1480 | // Grab the name part |
1481 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1481 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1482 | 1482 | ||
1483 | // grab the email part | 1483 | // grab the email part |
1484 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1484 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1485 | 1485 | ||
1486 | // Check that we do not have any extra characters on the end of the | 1486 | // Check that we do not have any extra characters on the end of the |
1487 | // strings | 1487 | // strings |
1488 | len = fullName.length(); | 1488 | len = fullName.length(); |
1489 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1489 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1490 | fullName = fullName.mid(1, len-2); | 1490 | fullName = fullName.mid(1, len-2); |
1491 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1491 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1492 | fullName = fullName.mid(1, len-2); | 1492 | fullName = fullName.mid(1, len-2); |
1493 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1493 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1494 | fullName = fullName.mid(1, len-2); | 1494 | fullName = fullName.mid(1, len-2); |
1495 | } | 1495 | } |
1496 | } | 1496 | } |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void Addressee::setResource( Resource *resource ) | 1499 | void Addressee::setResource( Resource *resource ) |
1500 | { | 1500 | { |
1501 | detach(); | 1501 | detach(); |
1502 | mData->resource = resource; | 1502 | mData->resource = resource; |
1503 | } | 1503 | } |
1504 | 1504 | ||
1505 | Resource *Addressee::resource() const | 1505 | Resource *Addressee::resource() const |
1506 | { | 1506 | { |
1507 | return mData->resource; | 1507 | return mData->resource; |
1508 | } | 1508 | } |
1509 | 1509 | ||
1510 | //US | ||
1511 | QString Addressee::resourceLabel() | ||
1512 | { | ||
1513 | return i18n("Resource"); | ||
1514 | } | ||
1515 | |||
1510 | void Addressee::setChanged( bool value ) | 1516 | void Addressee::setChanged( bool value ) |
1511 | { | 1517 | { |
1512 | detach(); | 1518 | detach(); |
1513 | mData->changed = value; | 1519 | mData->changed = value; |
1514 | } | 1520 | } |
1515 | 1521 | ||
1516 | bool Addressee::changed() const | 1522 | bool Addressee::changed() const |
1517 | { | 1523 | { |
1518 | return mData->changed; | 1524 | return mData->changed; |
1519 | } | 1525 | } |
1520 | 1526 | ||
1521 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1527 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1522 | { | 1528 | { |
1523 | if (!a.mData) return s; | 1529 | if (!a.mData) return s; |
1524 | 1530 | ||
1525 | s << a.uid(); | 1531 | s << a.uid(); |
1526 | 1532 | ||
1527 | s << a.mData->name; | 1533 | s << a.mData->name; |
1528 | s << a.mData->formattedName; | 1534 | s << a.mData->formattedName; |
1529 | s << a.mData->familyName; | 1535 | s << a.mData->familyName; |
1530 | s << a.mData->givenName; | 1536 | s << a.mData->givenName; |
1531 | s << a.mData->additionalName; | 1537 | s << a.mData->additionalName; |
1532 | s << a.mData->prefix; | 1538 | s << a.mData->prefix; |
1533 | s << a.mData->suffix; | 1539 | s << a.mData->suffix; |
1534 | s << a.mData->nickName; | 1540 | s << a.mData->nickName; |
1535 | s << a.mData->birthday; | 1541 | s << a.mData->birthday; |
1536 | s << a.mData->mailer; | 1542 | s << a.mData->mailer; |
1537 | s << a.mData->timeZone; | 1543 | s << a.mData->timeZone; |
1538 | s << a.mData->geo; | 1544 | s << a.mData->geo; |
1539 | s << a.mData->title; | 1545 | s << a.mData->title; |
1540 | s << a.mData->role; | 1546 | s << a.mData->role; |
1541 | s << a.mData->organization; | 1547 | s << a.mData->organization; |
1542 | s << a.mData->note; | 1548 | s << a.mData->note; |
1543 | s << a.mData->productId; | 1549 | s << a.mData->productId; |
1544 | s << a.mData->revision; | 1550 | s << a.mData->revision; |
1545 | s << a.mData->sortString; | 1551 | s << a.mData->sortString; |
1546 | s << a.mData->url; | 1552 | s << a.mData->url; |
1547 | s << a.mData->secrecy; | 1553 | s << a.mData->secrecy; |
1548 | s << a.mData->logo; | 1554 | s << a.mData->logo; |
1549 | s << a.mData->photo; | 1555 | s << a.mData->photo; |
1550 | s << a.mData->sound; | 1556 | s << a.mData->sound; |
1551 | s << a.mData->agent; | 1557 | s << a.mData->agent; |
1552 | s << a.mData->phoneNumbers; | 1558 | s << a.mData->phoneNumbers; |
1553 | s << a.mData->addresses; | 1559 | s << a.mData->addresses; |
1554 | s << a.mData->emails; | 1560 | s << a.mData->emails; |
1555 | s << a.mData->categories; | 1561 | s << a.mData->categories; |
1556 | s << a.mData->custom; | 1562 | s << a.mData->custom; |
1557 | s << a.mData->keys; | 1563 | s << a.mData->keys; |
1558 | return s; | 1564 | return s; |
1559 | } | 1565 | } |
1560 | 1566 | ||
1561 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1567 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1562 | { | 1568 | { |
1563 | if (!a.mData) return s; | 1569 | if (!a.mData) return s; |
1564 | 1570 | ||
1565 | s >> a.mData->uid; | 1571 | s >> a.mData->uid; |
1566 | 1572 | ||
1567 | s >> a.mData->name; | 1573 | s >> a.mData->name; |
1568 | s >> a.mData->formattedName; | 1574 | s >> a.mData->formattedName; |
1569 | s >> a.mData->familyName; | 1575 | s >> a.mData->familyName; |
1570 | s >> a.mData->givenName; | 1576 | s >> a.mData->givenName; |
1571 | s >> a.mData->additionalName; | 1577 | s >> a.mData->additionalName; |
1572 | s >> a.mData->prefix; | 1578 | s >> a.mData->prefix; |
1573 | s >> a.mData->suffix; | 1579 | s >> a.mData->suffix; |
1574 | s >> a.mData->nickName; | 1580 | s >> a.mData->nickName; |
1575 | s >> a.mData->birthday; | 1581 | s >> a.mData->birthday; |
1576 | s >> a.mData->mailer; | 1582 | s >> a.mData->mailer; |
1577 | s >> a.mData->timeZone; | 1583 | s >> a.mData->timeZone; |
1578 | s >> a.mData->geo; | 1584 | s >> a.mData->geo; |
1579 | s >> a.mData->title; | 1585 | s >> a.mData->title; |
1580 | s >> a.mData->role; | 1586 | s >> a.mData->role; |
1581 | s >> a.mData->organization; | 1587 | s >> a.mData->organization; |
1582 | s >> a.mData->note; | 1588 | s >> a.mData->note; |
1583 | s >> a.mData->productId; | 1589 | s >> a.mData->productId; |
1584 | s >> a.mData->revision; | 1590 | s >> a.mData->revision; |
1585 | s >> a.mData->sortString; | 1591 | s >> a.mData->sortString; |
1586 | s >> a.mData->url; | 1592 | s >> a.mData->url; |
1587 | s >> a.mData->secrecy; | 1593 | s >> a.mData->secrecy; |
1588 | s >> a.mData->logo; | 1594 | s >> a.mData->logo; |
1589 | s >> a.mData->photo; | 1595 | s >> a.mData->photo; |
1590 | s >> a.mData->sound; | 1596 | s >> a.mData->sound; |
1591 | s >> a.mData->agent; | 1597 | s >> a.mData->agent; |
1592 | s >> a.mData->phoneNumbers; | 1598 | s >> a.mData->phoneNumbers; |
1593 | s >> a.mData->addresses; | 1599 | s >> a.mData->addresses; |
1594 | s >> a.mData->emails; | 1600 | s >> a.mData->emails; |
1595 | s >> a.mData->categories; | 1601 | s >> a.mData->categories; |
1596 | s >> a.mData->custom; | 1602 | s >> a.mData->custom; |
1597 | s >> a.mData->keys; | 1603 | s >> a.mData->keys; |
1598 | 1604 | ||
1599 | a.mData->empty = false; | 1605 | a.mData->empty = false; |
1600 | 1606 | ||
1601 | return s; | 1607 | return s; |
1602 | } | 1608 | } |
1603 | 1609 | ||
1604 | bool matchBinaryPattern( int value, int pattern ) | 1610 | bool matchBinaryPattern( int value, int pattern ) |
1605 | { | 1611 | { |
1606 | /** | 1612 | /** |
1607 | We want to match all telephonnumbers/addresses which have the bits in the | 1613 | We want to match all telephonnumbers/addresses which have the bits in the |
1608 | pattern set. More are allowed. | 1614 | pattern set. More are allowed. |
1609 | if pattern == 0 we have a special handling, then we want only those with | 1615 | if pattern == 0 we have a special handling, then we want only those with |
1610 | exactly no bit set. | 1616 | exactly no bit set. |
1611 | */ | 1617 | */ |
1612 | if ( pattern == 0 ) | 1618 | if ( pattern == 0 ) |
1613 | return ( value == 0 ); | 1619 | return ( value == 0 ); |
1614 | else | 1620 | else |
1615 | return ( pattern == ( pattern & value ) ); | 1621 | return ( pattern == ( pattern & value ) ); |
1616 | } | 1622 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index ee98e03..393d1cc 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -27,791 +27,797 @@ $Id$ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Return, if the address book entry is empty. | 101 | Return, if the address book entry is empty. |
102 | */ | 102 | */ |
103 | bool isEmpty() const; | 103 | bool isEmpty() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Set unique identifier. | 106 | Set unique identifier. |
107 | */ | 107 | */ |
108 | void setUid( const QString &uid ); | 108 | void setUid( const QString &uid ); |
109 | /** | 109 | /** |
110 | Return unique identifier. | 110 | Return unique identifier. |
111 | */ | 111 | */ |
112 | QString uid() const; | 112 | QString uid() const; |
113 | /** | 113 | /** |
114 | Return translated label for uid field. | 114 | Return translated label for uid field. |
115 | */ | 115 | */ |
116 | static QString uidLabel(); | 116 | static QString uidLabel(); |
117 | 117 | ||
118 | /** | 118 | /** |
119 | Set name. | 119 | Set name. |
120 | */ | 120 | */ |
121 | void setName( const QString &name ); | 121 | void setName( const QString &name ); |
122 | /** | 122 | /** |
123 | Return name. | 123 | Return name. |
124 | */ | 124 | */ |
125 | QString name() const; | 125 | QString name() const; |
126 | /** | 126 | /** |
127 | Return translated label for name field. | 127 | Return translated label for name field. |
128 | */ | 128 | */ |
129 | static QString nameLabel(); | 129 | static QString nameLabel(); |
130 | 130 | ||
131 | /** | 131 | /** |
132 | Set formatted name. | 132 | Set formatted name. |
133 | */ | 133 | */ |
134 | void setFormattedName( const QString &formattedName ); | 134 | void setFormattedName( const QString &formattedName ); |
135 | /** | 135 | /** |
136 | Return formatted name. | 136 | Return formatted name. |
137 | */ | 137 | */ |
138 | QString formattedName() const; | 138 | QString formattedName() const; |
139 | /** | 139 | /** |
140 | Return translated label for formattedName field. | 140 | Return translated label for formattedName field. |
141 | */ | 141 | */ |
142 | static QString formattedNameLabel(); | 142 | static QString formattedNameLabel(); |
143 | 143 | ||
144 | /** | 144 | /** |
145 | Set family name. | 145 | Set family name. |
146 | */ | 146 | */ |
147 | void setFamilyName( const QString &familyName ); | 147 | void setFamilyName( const QString &familyName ); |
148 | /** | 148 | /** |
149 | Return family name. | 149 | Return family name. |
150 | */ | 150 | */ |
151 | QString familyName() const; | 151 | QString familyName() const; |
152 | /** | 152 | /** |
153 | Return translated label for familyName field. | 153 | Return translated label for familyName field. |
154 | */ | 154 | */ |
155 | static QString familyNameLabel(); | 155 | static QString familyNameLabel(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Set given name. | 158 | Set given name. |
159 | */ | 159 | */ |
160 | void setGivenName( const QString &givenName ); | 160 | void setGivenName( const QString &givenName ); |
161 | /** | 161 | /** |
162 | Return given name. | 162 | Return given name. |
163 | */ | 163 | */ |
164 | QString givenName() const; | 164 | QString givenName() const; |
165 | /** | 165 | /** |
166 | Return translated label for givenName field. | 166 | Return translated label for givenName field. |
167 | */ | 167 | */ |
168 | static QString givenNameLabel(); | 168 | static QString givenNameLabel(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Set additional names. | 171 | Set additional names. |
172 | */ | 172 | */ |
173 | void setAdditionalName( const QString &additionalName ); | 173 | void setAdditionalName( const QString &additionalName ); |
174 | /** | 174 | /** |
175 | Return additional names. | 175 | Return additional names. |
176 | */ | 176 | */ |
177 | QString additionalName() const; | 177 | QString additionalName() const; |
178 | /** | 178 | /** |
179 | Return translated label for additionalName field. | 179 | Return translated label for additionalName field. |
180 | */ | 180 | */ |
181 | static QString additionalNameLabel(); | 181 | static QString additionalNameLabel(); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Set honorific prefixes. | 184 | Set honorific prefixes. |
185 | */ | 185 | */ |
186 | void setPrefix( const QString &prefix ); | 186 | void setPrefix( const QString &prefix ); |
187 | /** | 187 | /** |
188 | Return honorific prefixes. | 188 | Return honorific prefixes. |
189 | */ | 189 | */ |
190 | QString prefix() const; | 190 | QString prefix() const; |
191 | /** | 191 | /** |
192 | Return translated label for prefix field. | 192 | Return translated label for prefix field. |
193 | */ | 193 | */ |
194 | static QString prefixLabel(); | 194 | static QString prefixLabel(); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Set honorific suffixes. | 197 | Set honorific suffixes. |
198 | */ | 198 | */ |
199 | void setSuffix( const QString &suffix ); | 199 | void setSuffix( const QString &suffix ); |
200 | /** | 200 | /** |
201 | Return honorific suffixes. | 201 | Return honorific suffixes. |
202 | */ | 202 | */ |
203 | QString suffix() const; | 203 | QString suffix() const; |
204 | /** | 204 | /** |
205 | Return translated label for suffix field. | 205 | Return translated label for suffix field. |
206 | */ | 206 | */ |
207 | static QString suffixLabel(); | 207 | static QString suffixLabel(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Set nick name. | 210 | Set nick name. |
211 | */ | 211 | */ |
212 | void setNickName( const QString &nickName ); | 212 | void setNickName( const QString &nickName ); |
213 | /** | 213 | /** |
214 | Return nick name. | 214 | Return nick name. |
215 | */ | 215 | */ |
216 | QString nickName() const; | 216 | QString nickName() const; |
217 | /** | 217 | /** |
218 | Return translated label for nickName field. | 218 | Return translated label for nickName field. |
219 | */ | 219 | */ |
220 | static QString nickNameLabel(); | 220 | static QString nickNameLabel(); |
221 | 221 | ||
222 | /** | 222 | /** |
223 | Set birthday. | 223 | Set birthday. |
224 | */ | 224 | */ |
225 | void setBirthday( const QDateTime &birthday ); | 225 | void setBirthday( const QDateTime &birthday ); |
226 | /** | 226 | /** |
227 | Return birthday. | 227 | Return birthday. |
228 | */ | 228 | */ |
229 | QDateTime birthday() const; | 229 | QDateTime birthday() const; |
230 | /** | 230 | /** |
231 | Return translated label for birthday field. | 231 | Return translated label for birthday field. |
232 | */ | 232 | */ |
233 | static QString birthdayLabel(); | 233 | static QString birthdayLabel(); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return translated label for homeAddressStreet field. | 236 | Return translated label for homeAddressStreet field. |
237 | */ | 237 | */ |
238 | static QString homeAddressStreetLabel(); | 238 | static QString homeAddressStreetLabel(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return translated label for homeAddressLocality field. | 241 | Return translated label for homeAddressLocality field. |
242 | */ | 242 | */ |
243 | static QString homeAddressLocalityLabel(); | 243 | static QString homeAddressLocalityLabel(); |
244 | 244 | ||
245 | /** | 245 | /** |
246 | Return translated label for homeAddressRegion field. | 246 | Return translated label for homeAddressRegion field. |
247 | */ | 247 | */ |
248 | static QString homeAddressRegionLabel(); | 248 | static QString homeAddressRegionLabel(); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Return translated label for homeAddressPostalCode field. | 251 | Return translated label for homeAddressPostalCode field. |
252 | */ | 252 | */ |
253 | static QString homeAddressPostalCodeLabel(); | 253 | static QString homeAddressPostalCodeLabel(); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Return translated label for homeAddressCountry field. | 256 | Return translated label for homeAddressCountry field. |
257 | */ | 257 | */ |
258 | static QString homeAddressCountryLabel(); | 258 | static QString homeAddressCountryLabel(); |
259 | 259 | ||
260 | /** | 260 | /** |
261 | Return translated label for homeAddressLabel field. | 261 | Return translated label for homeAddressLabel field. |
262 | */ | 262 | */ |
263 | static QString homeAddressLabelLabel(); | 263 | static QString homeAddressLabelLabel(); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Return translated label for businessAddressStreet field. | 266 | Return translated label for businessAddressStreet field. |
267 | */ | 267 | */ |
268 | static QString businessAddressStreetLabel(); | 268 | static QString businessAddressStreetLabel(); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return translated label for businessAddressLocality field. | 271 | Return translated label for businessAddressLocality field. |
272 | */ | 272 | */ |
273 | static QString businessAddressLocalityLabel(); | 273 | static QString businessAddressLocalityLabel(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Return translated label for businessAddressRegion field. | 276 | Return translated label for businessAddressRegion field. |
277 | */ | 277 | */ |
278 | static QString businessAddressRegionLabel(); | 278 | static QString businessAddressRegionLabel(); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return translated label for businessAddressPostalCode field. | 281 | Return translated label for businessAddressPostalCode field. |
282 | */ | 282 | */ |
283 | static QString businessAddressPostalCodeLabel(); | 283 | static QString businessAddressPostalCodeLabel(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Return translated label for businessAddressCountry field. | 286 | Return translated label for businessAddressCountry field. |
287 | */ | 287 | */ |
288 | static QString businessAddressCountryLabel(); | 288 | static QString businessAddressCountryLabel(); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | Return translated label for businessAddressLabel field. | 291 | Return translated label for businessAddressLabel field. |
292 | */ | 292 | */ |
293 | static QString businessAddressLabelLabel(); | 293 | static QString businessAddressLabelLabel(); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Return translated label for homePhone field. | 296 | Return translated label for homePhone field. |
297 | */ | 297 | */ |
298 | static QString homePhoneLabel(); | 298 | static QString homePhoneLabel(); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | Return translated label for businessPhone field. | 301 | Return translated label for businessPhone field. |
302 | */ | 302 | */ |
303 | static QString businessPhoneLabel(); | 303 | static QString businessPhoneLabel(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | Return translated label for mobilePhone field. | 306 | Return translated label for mobilePhone field. |
307 | */ | 307 | */ |
308 | static QString mobilePhoneLabel(); | 308 | static QString mobilePhoneLabel(); |
309 | 309 | ||
310 | /** | 310 | /** |
311 | Return translated label for homeFax field. | 311 | Return translated label for homeFax field. |
312 | */ | 312 | */ |
313 | static QString homeFaxLabel(); | 313 | static QString homeFaxLabel(); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Return translated label for businessFax field. | 316 | Return translated label for businessFax field. |
317 | */ | 317 | */ |
318 | static QString businessFaxLabel(); | 318 | static QString businessFaxLabel(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Return translated label for carPhone field. | 321 | Return translated label for carPhone field. |
322 | */ | 322 | */ |
323 | static QString carPhoneLabel(); | 323 | static QString carPhoneLabel(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Return translated label for isdn field. | 326 | Return translated label for isdn field. |
327 | */ | 327 | */ |
328 | static QString isdnLabel(); | 328 | static QString isdnLabel(); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | Return translated label for pager field. | 331 | Return translated label for pager field. |
332 | */ | 332 | */ |
333 | static QString pagerLabel(); | 333 | static QString pagerLabel(); |
334 | 334 | ||
335 | /** | 335 | /** |
336 | Return translated label for email field. | 336 | Return translated label for email field. |
337 | */ | 337 | */ |
338 | static QString emailLabel(); | 338 | static QString emailLabel(); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | Set mail client. | 341 | Set mail client. |
342 | */ | 342 | */ |
343 | void setMailer( const QString &mailer ); | 343 | void setMailer( const QString &mailer ); |
344 | /** | 344 | /** |
345 | Return mail client. | 345 | Return mail client. |
346 | */ | 346 | */ |
347 | QString mailer() const; | 347 | QString mailer() const; |
348 | /** | 348 | /** |
349 | Return translated label for mailer field. | 349 | Return translated label for mailer field. |
350 | */ | 350 | */ |
351 | static QString mailerLabel(); | 351 | static QString mailerLabel(); |
352 | 352 | ||
353 | /** | 353 | /** |
354 | Set time zone. | 354 | Set time zone. |
355 | */ | 355 | */ |
356 | void setTimeZone( const TimeZone &timeZone ); | 356 | void setTimeZone( const TimeZone &timeZone ); |
357 | /** | 357 | /** |
358 | Return time zone. | 358 | Return time zone. |
359 | */ | 359 | */ |
360 | TimeZone timeZone() const; | 360 | TimeZone timeZone() const; |
361 | /** | 361 | /** |
362 | Return translated label for timeZone field. | 362 | Return translated label for timeZone field. |
363 | */ | 363 | */ |
364 | static QString timeZoneLabel(); | 364 | static QString timeZoneLabel(); |
365 | 365 | ||
366 | /** | 366 | /** |
367 | Set geographic position. | 367 | Set geographic position. |
368 | */ | 368 | */ |
369 | void setGeo( const Geo &geo ); | 369 | void setGeo( const Geo &geo ); |
370 | /** | 370 | /** |
371 | Return geographic position. | 371 | Return geographic position. |
372 | */ | 372 | */ |
373 | Geo geo() const; | 373 | Geo geo() const; |
374 | /** | 374 | /** |
375 | Return translated label for geo field. | 375 | Return translated label for geo field. |
376 | */ | 376 | */ |
377 | static QString geoLabel(); | 377 | static QString geoLabel(); |
378 | 378 | ||
379 | /** | 379 | /** |
380 | Set title. | 380 | Set title. |
381 | */ | 381 | */ |
382 | void setTitle( const QString &title ); | 382 | void setTitle( const QString &title ); |
383 | /** | 383 | /** |
384 | Return title. | 384 | Return title. |
385 | */ | 385 | */ |
386 | QString title() const; | 386 | QString title() const; |
387 | /** | 387 | /** |
388 | Return translated label for title field. | 388 | Return translated label for title field. |
389 | */ | 389 | */ |
390 | static QString titleLabel(); | 390 | static QString titleLabel(); |
391 | 391 | ||
392 | /** | 392 | /** |
393 | Set role. | 393 | Set role. |
394 | */ | 394 | */ |
395 | void setRole( const QString &role ); | 395 | void setRole( const QString &role ); |
396 | /** | 396 | /** |
397 | Return role. | 397 | Return role. |
398 | */ | 398 | */ |
399 | QString role() const; | 399 | QString role() const; |
400 | /** | 400 | /** |
401 | Return translated label for role field. | 401 | Return translated label for role field. |
402 | */ | 402 | */ |
403 | static QString roleLabel(); | 403 | static QString roleLabel(); |
404 | 404 | ||
405 | /** | 405 | /** |
406 | Set organization. | 406 | Set organization. |
407 | */ | 407 | */ |
408 | void setOrganization( const QString &organization ); | 408 | void setOrganization( const QString &organization ); |
409 | /** | 409 | /** |
410 | Return organization. | 410 | Return organization. |
411 | */ | 411 | */ |
412 | QString organization() const; | 412 | QString organization() const; |
413 | /** | 413 | /** |
414 | Return translated label for organization field. | 414 | Return translated label for organization field. |
415 | */ | 415 | */ |
416 | static QString organizationLabel(); | 416 | static QString organizationLabel(); |
417 | 417 | ||
418 | /** | 418 | /** |
419 | Set note. | 419 | Set note. |
420 | */ | 420 | */ |
421 | void setNote( const QString ¬e ); | 421 | void setNote( const QString ¬e ); |
422 | /** | 422 | /** |
423 | Return note. | 423 | Return note. |
424 | */ | 424 | */ |
425 | QString note() const; | 425 | QString note() const; |
426 | /** | 426 | /** |
427 | Return translated label for note field. | 427 | Return translated label for note field. |
428 | */ | 428 | */ |
429 | static QString noteLabel(); | 429 | static QString noteLabel(); |
430 | 430 | ||
431 | /** | 431 | /** |
432 | Set product identifier. | 432 | Set product identifier. |
433 | */ | 433 | */ |
434 | void setProductId( const QString &productId ); | 434 | void setProductId( const QString &productId ); |
435 | /** | 435 | /** |
436 | Return product identifier. | 436 | Return product identifier. |
437 | */ | 437 | */ |
438 | QString productId() const; | 438 | QString productId() const; |
439 | /** | 439 | /** |
440 | Return translated label for productId field. | 440 | Return translated label for productId field. |
441 | */ | 441 | */ |
442 | static QString productIdLabel(); | 442 | static QString productIdLabel(); |
443 | 443 | ||
444 | /** | 444 | /** |
445 | Set revision date. | 445 | Set revision date. |
446 | */ | 446 | */ |
447 | void setRevision( const QDateTime &revision ); | 447 | void setRevision( const QDateTime &revision ); |
448 | /** | 448 | /** |
449 | Return revision date. | 449 | Return revision date. |
450 | */ | 450 | */ |
451 | QDateTime revision() const; | 451 | QDateTime revision() const; |
452 | /** | 452 | /** |
453 | Return translated label for revision field. | 453 | Return translated label for revision field. |
454 | */ | 454 | */ |
455 | static QString revisionLabel(); | 455 | static QString revisionLabel(); |
456 | 456 | ||
457 | /** | 457 | /** |
458 | Set sort string. | 458 | Set sort string. |
459 | */ | 459 | */ |
460 | void setSortString( const QString &sortString ); | 460 | void setSortString( const QString &sortString ); |
461 | /** | 461 | /** |
462 | Return sort string. | 462 | Return sort string. |
463 | */ | 463 | */ |
464 | QString sortString() const; | 464 | QString sortString() const; |
465 | /** | 465 | /** |
466 | Return translated label for sortString field. | 466 | Return translated label for sortString field. |
467 | */ | 467 | */ |
468 | static QString sortStringLabel(); | 468 | static QString sortStringLabel(); |
469 | 469 | ||
470 | /** | 470 | /** |
471 | Set URL. | 471 | Set URL. |
472 | */ | 472 | */ |
473 | void setUrl( const KURL &url ); | 473 | void setUrl( const KURL &url ); |
474 | /** | 474 | /** |
475 | Return URL. | 475 | Return URL. |
476 | */ | 476 | */ |
477 | KURL url() const; | 477 | KURL url() const; |
478 | /** | 478 | /** |
479 | Return translated label for url field. | 479 | Return translated label for url field. |
480 | */ | 480 | */ |
481 | static QString urlLabel(); | 481 | static QString urlLabel(); |
482 | 482 | ||
483 | /** | 483 | /** |
484 | Set security class. | 484 | Set security class. |
485 | */ | 485 | */ |
486 | void setSecrecy( const Secrecy &secrecy ); | 486 | void setSecrecy( const Secrecy &secrecy ); |
487 | /** | 487 | /** |
488 | Return security class. | 488 | Return security class. |
489 | */ | 489 | */ |
490 | Secrecy secrecy() const; | 490 | Secrecy secrecy() const; |
491 | /** | 491 | /** |
492 | Return translated label for secrecy field. | 492 | Return translated label for secrecy field. |
493 | */ | 493 | */ |
494 | static QString secrecyLabel(); | 494 | static QString secrecyLabel(); |
495 | 495 | ||
496 | /** | 496 | /** |
497 | Set logo. | 497 | Set logo. |
498 | */ | 498 | */ |
499 | void setLogo( const Picture &logo ); | 499 | void setLogo( const Picture &logo ); |
500 | /** | 500 | /** |
501 | Return logo. | 501 | Return logo. |
502 | */ | 502 | */ |
503 | Picture logo() const; | 503 | Picture logo() const; |
504 | /** | 504 | /** |
505 | Return translated label for logo field. | 505 | Return translated label for logo field. |
506 | */ | 506 | */ |
507 | static QString logoLabel(); | 507 | static QString logoLabel(); |
508 | 508 | ||
509 | /** | 509 | /** |
510 | Set photo. | 510 | Set photo. |
511 | */ | 511 | */ |
512 | void setPhoto( const Picture &photo ); | 512 | void setPhoto( const Picture &photo ); |
513 | /** | 513 | /** |
514 | Return photo. | 514 | Return photo. |
515 | */ | 515 | */ |
516 | Picture photo() const; | 516 | Picture photo() const; |
517 | /** | 517 | /** |
518 | Return translated label for photo field. | 518 | Return translated label for photo field. |
519 | */ | 519 | */ |
520 | static QString photoLabel(); | 520 | static QString photoLabel(); |
521 | 521 | ||
522 | /** | 522 | /** |
523 | Set sound. | 523 | Set sound. |
524 | */ | 524 | */ |
525 | void setSound( const Sound &sound ); | 525 | void setSound( const Sound &sound ); |
526 | /** | 526 | /** |
527 | Return sound. | 527 | Return sound. |
528 | */ | 528 | */ |
529 | Sound sound() const; | 529 | Sound sound() const; |
530 | /** | 530 | /** |
531 | Return translated label for sound field. | 531 | Return translated label for sound field. |
532 | */ | 532 | */ |
533 | static QString soundLabel(); | 533 | static QString soundLabel(); |
534 | 534 | ||
535 | /** | 535 | /** |
536 | Set agent. | 536 | Set agent. |
537 | */ | 537 | */ |
538 | void setAgent( const Agent &agent ); | 538 | void setAgent( const Agent &agent ); |
539 | /** | 539 | /** |
540 | Return agent. | 540 | Return agent. |
541 | */ | 541 | */ |
542 | Agent agent() const; | 542 | Agent agent() const; |
543 | /** | 543 | /** |
544 | Return translated label for agent field. | 544 | Return translated label for agent field. |
545 | */ | 545 | */ |
546 | static QString agentLabel(); | 546 | static QString agentLabel(); |
547 | 547 | ||
548 | /** | 548 | /** |
549 | Set name fields by parsing the given string and trying to associate the | 549 | Set name fields by parsing the given string and trying to associate the |
550 | parts of the string with according fields. This function should probably | 550 | parts of the string with according fields. This function should probably |
551 | be a bit more clever. | 551 | be a bit more clever. |
552 | */ | 552 | */ |
553 | void setNameFromString( const QString & ); | 553 | void setNameFromString( const QString & ); |
554 | 554 | ||
555 | /** | 555 | /** |
556 | Return the name of the addressee. This is calculated from all the name | 556 | Return the name of the addressee. This is calculated from all the name |
557 | fields. | 557 | fields. |
558 | */ | 558 | */ |
559 | QString realName() const; | 559 | QString realName() const; |
560 | 560 | ||
561 | /** | 561 | /** |
562 | Return the name that consists of all name parts. | 562 | Return the name that consists of all name parts. |
563 | */ | 563 | */ |
564 | QString assembledName() const; | 564 | QString assembledName() const; |
565 | 565 | ||
566 | /** | 566 | /** |
567 | Return email address including real name. | 567 | Return email address including real name. |
568 | 568 | ||
569 | @param email Email address to be used to construct the full email string. | 569 | @param email Email address to be used to construct the full email string. |
570 | If this is QString::null the preferred email address is used. | 570 | If this is QString::null the preferred email address is used. |
571 | */ | 571 | */ |
572 | QString fullEmail( const QString &email=QString::null ) const; | 572 | QString fullEmail( const QString &email=QString::null ) const; |
573 | 573 | ||
574 | /** | 574 | /** |
575 | Insert an email address. If the email address already exists in this | 575 | Insert an email address. If the email address already exists in this |
576 | addressee it is not duplicated. | 576 | addressee it is not duplicated. |
577 | 577 | ||
578 | @param email Email address | 578 | @param email Email address |
579 | @param preferred Set to true, if this is the preferred email address of | 579 | @param preferred Set to true, if this is the preferred email address of |
580 | the addressee. | 580 | the addressee. |
581 | */ | 581 | */ |
582 | void insertEmail( const QString &email, bool preferred=false ); | 582 | void insertEmail( const QString &email, bool preferred=false ); |
583 | 583 | ||
584 | /** | 584 | /** |
585 | Remove email address. If the email address doesn't exist, nothing happens. | 585 | Remove email address. If the email address doesn't exist, nothing happens. |
586 | */ | 586 | */ |
587 | void removeEmail( const QString &email ); | 587 | void removeEmail( const QString &email ); |
588 | 588 | ||
589 | /** | 589 | /** |
590 | Return preferred email address. This is the first email address or the | 590 | Return preferred email address. This is the first email address or the |
591 | last one added with @ref insertEmail() with a set preferred parameter. | 591 | last one added with @ref insertEmail() with a set preferred parameter. |
592 | */ | 592 | */ |
593 | QString preferredEmail() const; | 593 | QString preferredEmail() const; |
594 | 594 | ||
595 | /** | 595 | /** |
596 | Return list of all email addresses. | 596 | Return list of all email addresses. |
597 | */ | 597 | */ |
598 | QStringList emails() const; | 598 | QStringList emails() const; |
599 | 599 | ||
600 | /** | 600 | /** |
601 | Set the emails to @param. | 601 | Set the emails to @param. |
602 | The first email address gets the preferred one! | 602 | The first email address gets the preferred one! |
603 | @param list The list of email addresses. | 603 | @param list The list of email addresses. |
604 | */ | 604 | */ |
605 | void setEmails( const QStringList& list); | 605 | void setEmails( const QStringList& list); |
606 | 606 | ||
607 | /** | 607 | /** |
608 | Insert a phone number. If a phone number with the same id already exists | 608 | Insert a phone number. If a phone number with the same id already exists |
609 | in this addressee it is not duplicated. | 609 | in this addressee it is not duplicated. |
610 | */ | 610 | */ |
611 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 611 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
612 | 612 | ||
613 | /** | 613 | /** |
614 | Remove phone number. If no phone number with the given id exists for this | 614 | Remove phone number. If no phone number with the given id exists for this |
615 | addresse nothing happens. | 615 | addresse nothing happens. |
616 | */ | 616 | */ |
617 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 617 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
618 | 618 | ||
619 | /** | 619 | /** |
620 | Return phone number, which matches the given type. | 620 | Return phone number, which matches the given type. |
621 | */ | 621 | */ |
622 | PhoneNumber phoneNumber( int type ) const; | 622 | PhoneNumber phoneNumber( int type ) const; |
623 | 623 | ||
624 | /** | 624 | /** |
625 | Return list of all phone numbers. | 625 | Return list of all phone numbers. |
626 | */ | 626 | */ |
627 | PhoneNumber::List phoneNumbers() const; | 627 | PhoneNumber::List phoneNumbers() const; |
628 | 628 | ||
629 | /** | 629 | /** |
630 | Return list of phone numbers with a special type. | 630 | Return list of phone numbers with a special type. |
631 | */ | 631 | */ |
632 | PhoneNumber::List phoneNumbers( int type ) const; | 632 | PhoneNumber::List phoneNumbers( int type ) const; |
633 | 633 | ||
634 | /** | 634 | /** |
635 | Return phone number with the given id. | 635 | Return phone number with the given id. |
636 | */ | 636 | */ |
637 | PhoneNumber findPhoneNumber( const QString &id ) const; | 637 | PhoneNumber findPhoneNumber( const QString &id ) const; |
638 | 638 | ||
639 | /** | 639 | /** |
640 | Insert a key. If a key with the same id already exists | 640 | Insert a key. If a key with the same id already exists |
641 | in this addressee it is not duplicated. | 641 | in this addressee it is not duplicated. |
642 | */ | 642 | */ |
643 | void insertKey( const Key &key ); | 643 | void insertKey( const Key &key ); |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Remove a key. If no key with the given id exists for this | 646 | Remove a key. If no key with the given id exists for this |
647 | addresse nothing happens. | 647 | addresse nothing happens. |
648 | */ | 648 | */ |
649 | void removeKey( const Key &key ); | 649 | void removeKey( const Key &key ); |
650 | 650 | ||
651 | /** | 651 | /** |
652 | Return key, which matches the given type. | 652 | Return key, which matches the given type. |
653 | If @p type == Key::Custom you can specify a string | 653 | If @p type == Key::Custom you can specify a string |
654 | that should match. If you leave the string empty, the first | 654 | that should match. If you leave the string empty, the first |
655 | key with a custom value is returned. | 655 | key with a custom value is returned. |
656 | */ | 656 | */ |
657 | Key key( int type, QString customTypeString = QString::null ) const; | 657 | Key key( int type, QString customTypeString = QString::null ) const; |
658 | 658 | ||
659 | /** | 659 | /** |
660 | Return list of all keys. | 660 | Return list of all keys. |
661 | */ | 661 | */ |
662 | Key::List keys() const; | 662 | Key::List keys() const; |
663 | 663 | ||
664 | /** | 664 | /** |
665 | Set the list of keys | 665 | Set the list of keys |
666 | @param keys The keys to be set. | 666 | @param keys The keys to be set. |
667 | */ | 667 | */ |
668 | void setKeys( const Key::List& keys); | 668 | void setKeys( const Key::List& keys); |
669 | 669 | ||
670 | /** | 670 | /** |
671 | Return list of keys with a special type. | 671 | Return list of keys with a special type. |
672 | If @p type == Key::Custom you can specify a string | 672 | If @p type == Key::Custom you can specify a string |
673 | that should match. If you leave the string empty, all custom | 673 | that should match. If you leave the string empty, all custom |
674 | keys will be returned. | 674 | keys will be returned. |
675 | */ | 675 | */ |
676 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 676 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
677 | 677 | ||
678 | /** | 678 | /** |
679 | Return key with the given id. | 679 | Return key with the given id. |
680 | */ | 680 | */ |
681 | Key findKey( const QString &id ) const; | 681 | Key findKey( const QString &id ) const; |
682 | 682 | ||
683 | /** | 683 | /** |
684 | Insert an address. If an address with the same id already exists | 684 | Insert an address. If an address with the same id already exists |
685 | in this addressee it is not duplicated. | 685 | in this addressee it is not duplicated. |
686 | */ | 686 | */ |
687 | void insertAddress( const Address &address ); | 687 | void insertAddress( const Address &address ); |
688 | 688 | ||
689 | /** | 689 | /** |
690 | Remove address. If no address with the given id exists for this | 690 | Remove address. If no address with the given id exists for this |
691 | addresse nothing happens. | 691 | addresse nothing happens. |
692 | */ | 692 | */ |
693 | void removeAddress( const Address &address ); | 693 | void removeAddress( const Address &address ); |
694 | 694 | ||
695 | /** | 695 | /** |
696 | Return address, which matches the given type. | 696 | Return address, which matches the given type. |
697 | */ | 697 | */ |
698 | Address address( int type ) const; | 698 | Address address( int type ) const; |
699 | 699 | ||
700 | /** | 700 | /** |
701 | Return list of all addresses. | 701 | Return list of all addresses. |
702 | */ | 702 | */ |
703 | Address::List addresses() const; | 703 | Address::List addresses() const; |
704 | 704 | ||
705 | /** | 705 | /** |
706 | Return list of addresses with a special type. | 706 | Return list of addresses with a special type. |
707 | */ | 707 | */ |
708 | Address::List addresses( int type ) const; | 708 | Address::List addresses( int type ) const; |
709 | 709 | ||
710 | /** | 710 | /** |
711 | Return address with the given id. | 711 | Return address with the given id. |
712 | */ | 712 | */ |
713 | Address findAddress( const QString &id ) const; | 713 | Address findAddress( const QString &id ) const; |
714 | 714 | ||
715 | /** | 715 | /** |
716 | Insert category. If the category already exists it is not duplicated. | 716 | Insert category. If the category already exists it is not duplicated. |
717 | */ | 717 | */ |
718 | void insertCategory( const QString & ); | 718 | void insertCategory( const QString & ); |
719 | 719 | ||
720 | /** | 720 | /** |
721 | Remove category. | 721 | Remove category. |
722 | */ | 722 | */ |
723 | void removeCategory( const QString & ); | 723 | void removeCategory( const QString & ); |
724 | 724 | ||
725 | /** | 725 | /** |
726 | Return, if addressee has the given category. | 726 | Return, if addressee has the given category. |
727 | */ | 727 | */ |
728 | bool hasCategory( const QString & ) const; | 728 | bool hasCategory( const QString & ) const; |
729 | 729 | ||
730 | /** | 730 | /** |
731 | Set categories to given value. | 731 | Set categories to given value. |
732 | */ | 732 | */ |
733 | void setCategories( const QStringList & ); | 733 | void setCategories( const QStringList & ); |
734 | 734 | ||
735 | /** | 735 | /** |
736 | Return list of all set categories. | 736 | Return list of all set categories. |
737 | */ | 737 | */ |
738 | QStringList categories() const; | 738 | QStringList categories() const; |
739 | 739 | ||
740 | /** | 740 | /** |
741 | Insert custom entry. The entry is identified by the name of the inserting | 741 | Insert custom entry. The entry is identified by the name of the inserting |
742 | application and a unique name. If an entry with the given app and name | 742 | application and a unique name. If an entry with the given app and name |
743 | already exists its value is replaced with the new given value. | 743 | already exists its value is replaced with the new given value. |
744 | */ | 744 | */ |
745 | void insertCustom( const QString &app, const QString &name, | 745 | void insertCustom( const QString &app, const QString &name, |
746 | const QString &value ); | 746 | const QString &value ); |
747 | 747 | ||
748 | /** | 748 | /** |
749 | Remove custom entry. | 749 | Remove custom entry. |
750 | */ | 750 | */ |
751 | void removeCustom( const QString &app, const QString &name ); | 751 | void removeCustom( const QString &app, const QString &name ); |
752 | 752 | ||
753 | /** | 753 | /** |
754 | Return value of custom entry, identified by app and entry name. | 754 | Return value of custom entry, identified by app and entry name. |
755 | */ | 755 | */ |
756 | QString custom( const QString &app, const QString &name ) const; | 756 | QString custom( const QString &app, const QString &name ) const; |
757 | 757 | ||
758 | /** | 758 | /** |
759 | Set all custom entries. | 759 | Set all custom entries. |
760 | */ | 760 | */ |
761 | void setCustoms( const QStringList & ); | 761 | void setCustoms( const QStringList & ); |
762 | 762 | ||
763 | /** | 763 | /** |
764 | Return list of all custom entries. | 764 | Return list of all custom entries. |
765 | */ | 765 | */ |
766 | QStringList customs() const; | 766 | QStringList customs() const; |
767 | 767 | ||
768 | /** | 768 | /** |
769 | Parse full email address. The result is given back in fullName and email. | 769 | Parse full email address. The result is given back in fullName and email. |
770 | */ | 770 | */ |
771 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 771 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
772 | QString &email ); | 772 | QString &email ); |
773 | 773 | ||
774 | /** | 774 | /** |
775 | Debug output. | 775 | Debug output. |
776 | */ | 776 | */ |
777 | void dump() const; | 777 | void dump() const; |
778 | 778 | ||
779 | /** | 779 | /** |
780 | Returns string representation of the addressee. | 780 | Returns string representation of the addressee. |
781 | */ | 781 | */ |
782 | QString asString() const; | 782 | QString asString() const; |
783 | 783 | ||
784 | /** | 784 | /** |
785 | Set resource where the addressee is from. | 785 | Set resource where the addressee is from. |
786 | */ | 786 | */ |
787 | void setResource( Resource *resource ); | 787 | void setResource( Resource *resource ); |
788 | 788 | ||
789 | /** | 789 | /** |
790 | Return pointer to resource. | 790 | Return pointer to resource. |
791 | */ | 791 | */ |
792 | Resource *resource() const; | 792 | Resource *resource() const; |
793 | 793 | ||
794 | /** | 794 | /** |
795 | Return resourcelabel. | ||
796 | */ | ||
797 | //US | ||
798 | static QString resourceLabel(); | ||
799 | |||
800 | /** | ||
795 | Mark addressee as changed. | 801 | Mark addressee as changed. |
796 | */ | 802 | */ |
797 | void setChanged( bool value ); | 803 | void setChanged( bool value ); |
798 | 804 | ||
799 | /** | 805 | /** |
800 | Return whether the addressee is changed. | 806 | Return whether the addressee is changed. |
801 | */ | 807 | */ |
802 | bool changed() const; | 808 | bool changed() const; |
803 | 809 | ||
804 | private: | 810 | private: |
805 | Addressee copy(); | 811 | Addressee copy(); |
806 | void detach(); | 812 | void detach(); |
807 | 813 | ||
808 | struct AddresseeData; | 814 | struct AddresseeData; |
809 | mutable KSharedPtr<AddresseeData> mData; | 815 | mutable KSharedPtr<AddresseeData> mData; |
810 | }; | 816 | }; |
811 | 817 | ||
812 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 818 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
813 | QDataStream &operator>>( QDataStream &, Addressee & ); | 819 | QDataStream &operator>>( QDataStream &, Addressee & ); |
814 | 820 | ||
815 | } | 821 | } |
816 | 822 | ||
817 | #endif | 823 | #endif |
diff --git a/kabc/field.cpp b/kabc/field.cpp index 41bbfde..bc2e176 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -1,550 +1,566 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | 33 | ||
34 | #include "field.h" | 34 | #include "field.h" |
35 | #include "resource.h" | ||
35 | 36 | ||
36 | using namespace KABC; | 37 | using namespace KABC; |
37 | 38 | ||
38 | class Field::FieldImpl | 39 | class Field::FieldImpl |
39 | { | 40 | { |
40 | public: | 41 | public: |
41 | FieldImpl( int fieldId, int category = 0, | 42 | FieldImpl( int fieldId, int category = 0, |
42 | const QString &label = QString::null, | 43 | const QString &label = QString::null, |
43 | const QString &key = QString::null, | 44 | const QString &key = QString::null, |
44 | const QString &app = QString::null ) | 45 | const QString &app = QString::null ) |
45 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), | 46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), |
46 | mKey( key ), mApp( app ) {} | 47 | mKey( key ), mApp( app ) {} |
47 | 48 | ||
48 | enum FieldId | 49 | enum FieldId |
49 | { | 50 | { |
50 | CustomField, | 51 | CustomField, |
51 | FormattedName, | 52 | FormattedName, |
52 | FamilyName, | 53 | FamilyName, |
53 | GivenName, | 54 | GivenName, |
54 | AdditionalName, | 55 | AdditionalName, |
55 | Prefix, | 56 | Prefix, |
56 | Suffix, | 57 | Suffix, |
57 | NickName, | 58 | NickName, |
58 | Birthday, | 59 | Birthday, |
59 | HomeAddressStreet, | 60 | HomeAddressStreet, |
60 | HomeAddressLocality, | 61 | HomeAddressLocality, |
61 | HomeAddressRegion, | 62 | HomeAddressRegion, |
62 | HomeAddressPostalCode, | 63 | HomeAddressPostalCode, |
63 | HomeAddressCountry, | 64 | HomeAddressCountry, |
64 | HomeAddressLabel, | 65 | HomeAddressLabel, |
65 | BusinessAddressStreet, | 66 | BusinessAddressStreet, |
66 | BusinessAddressLocality, | 67 | BusinessAddressLocality, |
67 | BusinessAddressRegion, | 68 | BusinessAddressRegion, |
68 | BusinessAddressPostalCode, | 69 | BusinessAddressPostalCode, |
69 | BusinessAddressCountry, | 70 | BusinessAddressCountry, |
70 | BusinessAddressLabel, | 71 | BusinessAddressLabel, |
71 | HomePhone, | 72 | HomePhone, |
72 | BusinessPhone, | 73 | BusinessPhone, |
73 | MobilePhone, | 74 | MobilePhone, |
74 | HomeFax, | 75 | HomeFax, |
75 | BusinessFax, | 76 | BusinessFax, |
76 | CarPhone, | 77 | CarPhone, |
77 | Isdn, | 78 | Isdn, |
78 | Pager, | 79 | Pager, |
79 | Email, | 80 | Email, |
80 | Mailer, | 81 | Mailer, |
81 | Title, | 82 | Title, |
82 | Role, | 83 | Role, |
83 | Organization, | 84 | Organization, |
84 | Note, | 85 | Note, |
85 | Url | 86 | Url, |
87 | Resource | ||
86 | }; | 88 | }; |
87 | 89 | ||
88 | int fieldId() { return mFieldId; } | 90 | int fieldId() { return mFieldId; } |
89 | int category() { return mCategory; } | 91 | int category() { return mCategory; } |
90 | 92 | ||
91 | QString label() { return mLabel; } | 93 | QString label() { return mLabel; } |
92 | QString key() { return mKey; } | 94 | QString key() { return mKey; } |
93 | QString app() { return mApp; } | 95 | QString app() { return mApp; } |
94 | 96 | ||
95 | private: | 97 | private: |
96 | int mFieldId; | 98 | int mFieldId; |
97 | int mCategory; | 99 | int mCategory; |
98 | 100 | ||
99 | QString mLabel; | 101 | QString mLabel; |
100 | QString mKey; | 102 | QString mKey; |
101 | QString mApp; | 103 | QString mApp; |
102 | }; | 104 | }; |
103 | 105 | ||
104 | 106 | ||
105 | Field::List Field::mAllFields; | 107 | Field::List Field::mAllFields; |
106 | Field::List Field::mDefaultFields; | 108 | Field::List Field::mDefaultFields; |
107 | Field::List Field::mCustomFields; | 109 | Field::List Field::mCustomFields; |
108 | 110 | ||
109 | 111 | ||
110 | Field::Field( FieldImpl *impl ) | 112 | Field::Field( FieldImpl *impl ) |
111 | { | 113 | { |
112 | mImpl = impl; | 114 | mImpl = impl; |
113 | } | 115 | } |
114 | 116 | ||
115 | Field::~Field() | 117 | Field::~Field() |
116 | { | 118 | { |
117 | delete mImpl; | 119 | delete mImpl; |
118 | } | 120 | } |
119 | 121 | ||
120 | QString Field::label() | 122 | QString Field::label() |
121 | { | 123 | { |
122 | switch ( mImpl->fieldId() ) { | 124 | switch ( mImpl->fieldId() ) { |
123 | case FieldImpl::FormattedName: | 125 | case FieldImpl::FormattedName: |
124 | return Addressee::formattedNameLabel(); | 126 | return Addressee::formattedNameLabel(); |
125 | case FieldImpl::FamilyName: | 127 | case FieldImpl::FamilyName: |
126 | return Addressee::familyNameLabel(); | 128 | return Addressee::familyNameLabel(); |
127 | case FieldImpl::GivenName: | 129 | case FieldImpl::GivenName: |
128 | return Addressee::givenNameLabel(); | 130 | return Addressee::givenNameLabel(); |
129 | case FieldImpl::AdditionalName: | 131 | case FieldImpl::AdditionalName: |
130 | return Addressee::additionalNameLabel(); | 132 | return Addressee::additionalNameLabel(); |
131 | case FieldImpl::Prefix: | 133 | case FieldImpl::Prefix: |
132 | return Addressee::prefixLabel(); | 134 | return Addressee::prefixLabel(); |
133 | case FieldImpl::Suffix: | 135 | case FieldImpl::Suffix: |
134 | return Addressee::suffixLabel(); | 136 | return Addressee::suffixLabel(); |
135 | case FieldImpl::NickName: | 137 | case FieldImpl::NickName: |
136 | return Addressee::nickNameLabel(); | 138 | return Addressee::nickNameLabel(); |
137 | case FieldImpl::Birthday: | 139 | case FieldImpl::Birthday: |
138 | return Addressee::birthdayLabel(); | 140 | return Addressee::birthdayLabel(); |
139 | case FieldImpl::HomeAddressStreet: | 141 | case FieldImpl::HomeAddressStreet: |
140 | return Addressee::homeAddressStreetLabel(); | 142 | return Addressee::homeAddressStreetLabel(); |
141 | case FieldImpl::HomeAddressLocality: | 143 | case FieldImpl::HomeAddressLocality: |
142 | return Addressee::homeAddressLocalityLabel(); | 144 | return Addressee::homeAddressLocalityLabel(); |
143 | case FieldImpl::HomeAddressRegion: | 145 | case FieldImpl::HomeAddressRegion: |
144 | return Addressee::homeAddressRegionLabel(); | 146 | return Addressee::homeAddressRegionLabel(); |
145 | case FieldImpl::HomeAddressPostalCode: | 147 | case FieldImpl::HomeAddressPostalCode: |
146 | return Addressee::homeAddressPostalCodeLabel(); | 148 | return Addressee::homeAddressPostalCodeLabel(); |
147 | case FieldImpl::HomeAddressCountry: | 149 | case FieldImpl::HomeAddressCountry: |
148 | return Addressee::homeAddressCountryLabel(); | 150 | return Addressee::homeAddressCountryLabel(); |
149 | case FieldImpl::HomeAddressLabel: | 151 | case FieldImpl::HomeAddressLabel: |
150 | return Addressee::homeAddressLabelLabel(); | 152 | return Addressee::homeAddressLabelLabel(); |
151 | case FieldImpl::BusinessAddressStreet: | 153 | case FieldImpl::BusinessAddressStreet: |
152 | return Addressee::businessAddressStreetLabel(); | 154 | return Addressee::businessAddressStreetLabel(); |
153 | case FieldImpl::BusinessAddressLocality: | 155 | case FieldImpl::BusinessAddressLocality: |
154 | return Addressee::businessAddressLocalityLabel(); | 156 | return Addressee::businessAddressLocalityLabel(); |
155 | case FieldImpl::BusinessAddressRegion: | 157 | case FieldImpl::BusinessAddressRegion: |
156 | return Addressee::businessAddressRegionLabel(); | 158 | return Addressee::businessAddressRegionLabel(); |
157 | case FieldImpl::BusinessAddressPostalCode: | 159 | case FieldImpl::BusinessAddressPostalCode: |
158 | return Addressee::businessAddressPostalCodeLabel(); | 160 | return Addressee::businessAddressPostalCodeLabel(); |
159 | case FieldImpl::BusinessAddressCountry: | 161 | case FieldImpl::BusinessAddressCountry: |
160 | return Addressee::businessAddressCountryLabel(); | 162 | return Addressee::businessAddressCountryLabel(); |
161 | case FieldImpl::BusinessAddressLabel: | 163 | case FieldImpl::BusinessAddressLabel: |
162 | return Addressee::businessAddressLabelLabel(); | 164 | return Addressee::businessAddressLabelLabel(); |
163 | case FieldImpl::HomePhone: | 165 | case FieldImpl::HomePhone: |
164 | return Addressee::homePhoneLabel(); | 166 | return Addressee::homePhoneLabel(); |
165 | case FieldImpl::BusinessPhone: | 167 | case FieldImpl::BusinessPhone: |
166 | return Addressee::businessPhoneLabel(); | 168 | return Addressee::businessPhoneLabel(); |
167 | case FieldImpl::MobilePhone: | 169 | case FieldImpl::MobilePhone: |
168 | return Addressee::mobilePhoneLabel(); | 170 | return Addressee::mobilePhoneLabel(); |
169 | case FieldImpl::HomeFax: | 171 | case FieldImpl::HomeFax: |
170 | return Addressee::homeFaxLabel(); | 172 | return Addressee::homeFaxLabel(); |
171 | case FieldImpl::BusinessFax: | 173 | case FieldImpl::BusinessFax: |
172 | return Addressee::businessFaxLabel(); | 174 | return Addressee::businessFaxLabel(); |
173 | case FieldImpl::CarPhone: | 175 | case FieldImpl::CarPhone: |
174 | return Addressee::carPhoneLabel(); | 176 | return Addressee::carPhoneLabel(); |
175 | case FieldImpl::Isdn: | 177 | case FieldImpl::Isdn: |
176 | return Addressee::isdnLabel(); | 178 | return Addressee::isdnLabel(); |
177 | case FieldImpl::Pager: | 179 | case FieldImpl::Pager: |
178 | return Addressee::pagerLabel(); | 180 | return Addressee::pagerLabel(); |
179 | case FieldImpl::Email: | 181 | case FieldImpl::Email: |
180 | return Addressee::emailLabel(); | 182 | return Addressee::emailLabel(); |
181 | case FieldImpl::Mailer: | 183 | case FieldImpl::Mailer: |
182 | return Addressee::mailerLabel(); | 184 | return Addressee::mailerLabel(); |
183 | case FieldImpl::Title: | 185 | case FieldImpl::Title: |
184 | return Addressee::titleLabel(); | 186 | return Addressee::titleLabel(); |
185 | case FieldImpl::Role: | 187 | case FieldImpl::Role: |
186 | return Addressee::roleLabel(); | 188 | return Addressee::roleLabel(); |
187 | case FieldImpl::Organization: | 189 | case FieldImpl::Organization: |
188 | return Addressee::organizationLabel(); | 190 | return Addressee::organizationLabel(); |
189 | case FieldImpl::Note: | 191 | case FieldImpl::Note: |
190 | return Addressee::noteLabel(); | 192 | return Addressee::noteLabel(); |
191 | case FieldImpl::Url: | 193 | case FieldImpl::Url: |
192 | return Addressee::urlLabel(); | 194 | return Addressee::urlLabel(); |
195 | case FieldImpl::Resource: | ||
196 | return Addressee::resourceLabel(); | ||
193 | case FieldImpl::CustomField: | 197 | case FieldImpl::CustomField: |
194 | return mImpl->label(); | 198 | return mImpl->label(); |
195 | default: | 199 | default: |
196 | return i18n("Unknown Field"); | 200 | return i18n("Unknown Field"); |
197 | } | 201 | } |
198 | } | 202 | } |
199 | 203 | ||
200 | int Field::category() | 204 | int Field::category() |
201 | { | 205 | { |
202 | return mImpl->category(); | 206 | return mImpl->category(); |
203 | } | 207 | } |
204 | 208 | ||
205 | QString Field::categoryLabel( int category ) | 209 | QString Field::categoryLabel( int category ) |
206 | { | 210 | { |
207 | switch ( category ) { | 211 | switch ( category ) { |
208 | case All: | 212 | case All: |
209 | return i18n("All"); | 213 | return i18n("All"); |
210 | case Frequent: | 214 | case Frequent: |
211 | return i18n("Frequent"); | 215 | return i18n("Frequent"); |
212 | case Address: | 216 | case Address: |
213 | return i18n("Address"); | 217 | return i18n("Address"); |
214 | case Email: | 218 | case Email: |
215 | return i18n("Email"); | 219 | return i18n("Email"); |
216 | case Personal: | 220 | case Personal: |
217 | return i18n("Personal"); | 221 | return i18n("Personal"); |
218 | case Organization: | 222 | case Organization: |
219 | return i18n("Organization"); | 223 | return i18n("Organization"); |
220 | case CustomCategory: | 224 | case CustomCategory: |
221 | return i18n("Custom"); | 225 | return i18n("Custom"); |
222 | default: | 226 | default: |
223 | return i18n("Undefined"); | 227 | return i18n("Undefined"); |
224 | } | 228 | } |
225 | } | 229 | } |
226 | 230 | ||
227 | QString Field::value( const KABC::Addressee &a ) | 231 | QString Field::value( const KABC::Addressee &a ) |
228 | { | 232 | { |
229 | switch ( mImpl->fieldId() ) { | 233 | switch ( mImpl->fieldId() ) { |
230 | case FieldImpl::FormattedName: | 234 | case FieldImpl::FormattedName: |
231 | return a.formattedName(); | 235 | return a.formattedName(); |
232 | case FieldImpl::FamilyName: | 236 | case FieldImpl::FamilyName: |
233 | return a.familyName(); | 237 | return a.familyName(); |
234 | case FieldImpl::GivenName: | 238 | case FieldImpl::GivenName: |
235 | return a.givenName(); | 239 | return a.givenName(); |
236 | case FieldImpl::AdditionalName: | 240 | case FieldImpl::AdditionalName: |
237 | return a.additionalName(); | 241 | return a.additionalName(); |
238 | case FieldImpl::Prefix: | 242 | case FieldImpl::Prefix: |
239 | return a.prefix(); | 243 | return a.prefix(); |
240 | case FieldImpl::Suffix: | 244 | case FieldImpl::Suffix: |
241 | return a.suffix(); | 245 | return a.suffix(); |
242 | case FieldImpl::NickName: | 246 | case FieldImpl::NickName: |
243 | return a.nickName(); | 247 | return a.nickName(); |
244 | case FieldImpl::Mailer: | 248 | case FieldImpl::Mailer: |
245 | return a.mailer(); | 249 | return a.mailer(); |
246 | case FieldImpl::Title: | 250 | case FieldImpl::Title: |
247 | return a.title(); | 251 | return a.title(); |
248 | case FieldImpl::Role: | 252 | case FieldImpl::Role: |
249 | return a.role(); | 253 | return a.role(); |
250 | case FieldImpl::Organization: | 254 | case FieldImpl::Organization: |
251 | return a.organization(); | 255 | return a.organization(); |
252 | case FieldImpl::Note: | 256 | case FieldImpl::Note: |
253 | return a.note(); | 257 | return a.note(); |
254 | case FieldImpl::Email: | 258 | case FieldImpl::Email: |
255 | return a.preferredEmail(); | 259 | return a.preferredEmail(); |
256 | case FieldImpl::Birthday: | 260 | case FieldImpl::Birthday: |
257 | if ( a.birthday().isValid() ) { | 261 | if ( a.birthday().isValid() ) { |
258 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); | 262 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); |
259 | // But Qt::IsoDate was not specified. | 263 | // But Qt::IsoDate was not specified. |
260 | QString _oldFormat = KGlobal::locale()->dateFormat(); | 264 | QString _oldFormat = KGlobal::locale()->dateFormat(); |
261 | KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate | 265 | KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate |
262 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false); | 266 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false); |
263 | KGlobal::locale()->setDateFormat(_oldFormat); | 267 | KGlobal::locale()->setDateFormat(_oldFormat); |
264 | return dt; | 268 | return dt; |
265 | } | 269 | } |
266 | else | 270 | else |
267 | return QString::null; | 271 | return QString::null; |
268 | case FieldImpl::Url: | 272 | case FieldImpl::Url: |
269 | return a.url().prettyURL(); | 273 | return a.url().prettyURL(); |
274 | //US | ||
275 | case FieldImpl::Resource: | ||
276 | return a.resource()->resourceName(); | ||
270 | case FieldImpl::HomePhone: | 277 | case FieldImpl::HomePhone: |
271 | return a.phoneNumber( PhoneNumber::Home ).number(); | 278 | return a.phoneNumber( PhoneNumber::Home ).number(); |
272 | case FieldImpl::BusinessPhone: | 279 | case FieldImpl::BusinessPhone: |
273 | return a.phoneNumber( PhoneNumber::Work ).number(); | 280 | return a.phoneNumber( PhoneNumber::Work ).number(); |
274 | case FieldImpl::MobilePhone: | 281 | case FieldImpl::MobilePhone: |
275 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 282 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
276 | case FieldImpl::HomeFax: | 283 | case FieldImpl::HomeFax: |
277 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 284 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
278 | case FieldImpl::BusinessFax: | 285 | case FieldImpl::BusinessFax: |
279 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); | 286 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); |
280 | case FieldImpl::CarPhone: | 287 | case FieldImpl::CarPhone: |
281 | return a.phoneNumber( PhoneNumber::Car ).number(); | 288 | return a.phoneNumber( PhoneNumber::Car ).number(); |
282 | case FieldImpl::Isdn: | 289 | case FieldImpl::Isdn: |
283 | return a.phoneNumber( PhoneNumber::Isdn ).number(); | 290 | return a.phoneNumber( PhoneNumber::Isdn ).number(); |
284 | case FieldImpl::Pager: | 291 | case FieldImpl::Pager: |
285 | return a.phoneNumber( PhoneNumber::Pager ).number(); | 292 | return a.phoneNumber( PhoneNumber::Pager ).number(); |
286 | case FieldImpl::HomeAddressStreet: | 293 | case FieldImpl::HomeAddressStreet: |
287 | return a.address( Address::Home ).street(); | 294 | return a.address( Address::Home ).street(); |
288 | case FieldImpl::HomeAddressLocality: | 295 | case FieldImpl::HomeAddressLocality: |
289 | return a.address( Address::Home ).locality(); | 296 | return a.address( Address::Home ).locality(); |
290 | case FieldImpl::HomeAddressRegion: | 297 | case FieldImpl::HomeAddressRegion: |
291 | return a.address( Address::Home ).region(); | 298 | return a.address( Address::Home ).region(); |
292 | case FieldImpl::HomeAddressPostalCode: | 299 | case FieldImpl::HomeAddressPostalCode: |
293 | return a.address( Address::Home ).postalCode(); | 300 | return a.address( Address::Home ).postalCode(); |
294 | case FieldImpl::HomeAddressCountry: | 301 | case FieldImpl::HomeAddressCountry: |
295 | return a.address( Address::Home ).country(); | 302 | return a.address( Address::Home ).country(); |
296 | case FieldImpl::BusinessAddressStreet: | 303 | case FieldImpl::BusinessAddressStreet: |
297 | return a.address( Address::Work ).street(); | 304 | return a.address( Address::Work ).street(); |
298 | case FieldImpl::BusinessAddressLocality: | 305 | case FieldImpl::BusinessAddressLocality: |
299 | return a.address( Address::Work ).locality(); | 306 | return a.address( Address::Work ).locality(); |
300 | case FieldImpl::BusinessAddressRegion: | 307 | case FieldImpl::BusinessAddressRegion: |
301 | return a.address( Address::Work ).region(); | 308 | return a.address( Address::Work ).region(); |
302 | case FieldImpl::BusinessAddressPostalCode: | 309 | case FieldImpl::BusinessAddressPostalCode: |
303 | return a.address( Address::Work ).postalCode(); | 310 | return a.address( Address::Work ).postalCode(); |
304 | case FieldImpl::BusinessAddressCountry: | 311 | case FieldImpl::BusinessAddressCountry: |
305 | return a.address( Address::Work ).country(); | 312 | return a.address( Address::Work ).country(); |
306 | case FieldImpl::CustomField: | 313 | case FieldImpl::CustomField: |
307 | return a.custom( mImpl->app(), mImpl->key() ); | 314 | return a.custom( mImpl->app(), mImpl->key() ); |
308 | default: | 315 | default: |
309 | return QString::null; | 316 | return QString::null; |
310 | } | 317 | } |
311 | } | 318 | } |
312 | 319 | ||
313 | bool Field::setValue( KABC::Addressee &a, const QString &value ) | 320 | bool Field::setValue( KABC::Addressee &a, const QString &value ) |
314 | { | 321 | { |
315 | switch ( mImpl->fieldId() ) { | 322 | switch ( mImpl->fieldId() ) { |
316 | case FieldImpl::FormattedName: | 323 | case FieldImpl::FormattedName: |
317 | a.setFormattedName( value ); | 324 | a.setFormattedName( value ); |
318 | return true; | 325 | return true; |
319 | case FieldImpl::FamilyName: | 326 | case FieldImpl::FamilyName: |
320 | a.setFamilyName( value ); | 327 | a.setFamilyName( value ); |
321 | return true; | 328 | return true; |
322 | case FieldImpl::GivenName: | 329 | case FieldImpl::GivenName: |
323 | a.setGivenName( value ); | 330 | a.setGivenName( value ); |
324 | return true; | 331 | return true; |
325 | case FieldImpl::AdditionalName: | 332 | case FieldImpl::AdditionalName: |
326 | a.setAdditionalName( value ); | 333 | a.setAdditionalName( value ); |
327 | return true; | 334 | return true; |
328 | case FieldImpl::Prefix: | 335 | case FieldImpl::Prefix: |
329 | a.setPrefix( value ); | 336 | a.setPrefix( value ); |
330 | return true; | 337 | return true; |
331 | case FieldImpl::Suffix: | 338 | case FieldImpl::Suffix: |
332 | a.setSuffix( value ); | 339 | a.setSuffix( value ); |
333 | return true; | 340 | return true; |
334 | case FieldImpl::NickName: | 341 | case FieldImpl::NickName: |
335 | a.setNickName( value ); | 342 | a.setNickName( value ); |
336 | return true; | 343 | return true; |
337 | case FieldImpl::Mailer: | 344 | case FieldImpl::Mailer: |
338 | a.setMailer( value ); | 345 | a.setMailer( value ); |
339 | return true; | 346 | return true; |
340 | case FieldImpl::Title: | 347 | case FieldImpl::Title: |
341 | a.setTitle( value ); | 348 | a.setTitle( value ); |
342 | return true; | 349 | return true; |
343 | case FieldImpl::Role: | 350 | case FieldImpl::Role: |
344 | a.setRole( value ); | 351 | a.setRole( value ); |
345 | return true; | 352 | return true; |
346 | case FieldImpl::Organization: | 353 | case FieldImpl::Organization: |
347 | a.setOrganization( value ); | 354 | a.setOrganization( value ); |
348 | return true; | 355 | return true; |
349 | case FieldImpl::Note: | 356 | case FieldImpl::Note: |
350 | a.setNote( value ); | 357 | a.setNote( value ); |
351 | return true; | 358 | return true; |
352 | case FieldImpl::Birthday: | 359 | case FieldImpl::Birthday: |
353 | //US | 360 | //US |
354 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 361 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
355 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 362 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
356 | { | 363 | { |
357 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 364 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
358 | a.setBirthday(dt); | 365 | a.setBirthday(dt); |
359 | } | 366 | } |
360 | return true; | 367 | return true; |
361 | case FieldImpl::CustomField: | 368 | case FieldImpl::CustomField: |
362 | a.insertCustom( mImpl->app(), mImpl->key(), value ); | 369 | a.insertCustom( mImpl->app(), mImpl->key(), value ); |
370 | //US never copy the resourcename back to the adressee. | ||
371 | case FieldImpl::Resource: | ||
363 | default: | 372 | default: |
364 | return false; | 373 | return false; |
365 | } | 374 | } |
366 | } | 375 | } |
367 | 376 | ||
368 | bool Field::isCustom() | 377 | bool Field::isCustom() |
369 | { | 378 | { |
370 | return mImpl->fieldId() == FieldImpl::CustomField; | 379 | return mImpl->fieldId() == FieldImpl::CustomField; |
371 | } | 380 | } |
372 | 381 | ||
373 | Field::List Field::allFields() | 382 | Field::List Field::allFields() |
374 | { | 383 | { |
375 | if ( mAllFields.isEmpty() ) { | 384 | if ( mAllFields.isEmpty() ) { |
376 | createField( FieldImpl::FormattedName, Frequent ); | 385 | createField( FieldImpl::FormattedName, Frequent ); |
377 | createField( FieldImpl::FamilyName, Frequent ); | 386 | createField( FieldImpl::FamilyName, Frequent ); |
378 | createField( FieldImpl::GivenName, Frequent ); | 387 | createField( FieldImpl::GivenName, Frequent ); |
379 | createField( FieldImpl::AdditionalName ); | 388 | createField( FieldImpl::AdditionalName ); |
380 | createField( FieldImpl::Prefix ); | 389 | createField( FieldImpl::Prefix ); |
381 | createField( FieldImpl::Suffix ); | 390 | createField( FieldImpl::Suffix ); |
382 | createField( FieldImpl::NickName, Personal ); | 391 | createField( FieldImpl::NickName, Personal ); |
383 | createField( FieldImpl::Birthday, Personal ); | 392 | createField( FieldImpl::Birthday, Personal ); |
384 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 393 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
385 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 394 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
386 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 395 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
387 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 396 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
388 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 397 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
389 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 398 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
390 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 399 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
391 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 400 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); |
392 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); | 401 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); |
393 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); | 402 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); |
394 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); | 403 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); |
395 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); | 404 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); |
396 | createField( FieldImpl::HomePhone, Personal|Frequent ); | 405 | createField( FieldImpl::HomePhone, Personal|Frequent ); |
397 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); | 406 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); |
398 | createField( FieldImpl::MobilePhone, Frequent ); | 407 | createField( FieldImpl::MobilePhone, Frequent ); |
399 | createField( FieldImpl::HomeFax ); | 408 | createField( FieldImpl::HomeFax ); |
400 | createField( FieldImpl::BusinessFax ); | 409 | createField( FieldImpl::BusinessFax ); |
401 | createField( FieldImpl::CarPhone ); | 410 | createField( FieldImpl::CarPhone ); |
402 | createField( FieldImpl::Isdn ); | 411 | createField( FieldImpl::Isdn ); |
403 | createField( FieldImpl::Pager ); | 412 | createField( FieldImpl::Pager ); |
404 | createField( FieldImpl::Email, Email|Frequent ); | 413 | createField( FieldImpl::Email, Email|Frequent ); |
405 | createField( FieldImpl::Mailer, Email ); | 414 | createField( FieldImpl::Mailer, Email ); |
406 | createField( FieldImpl::Title, Organization ); | 415 | createField( FieldImpl::Title, Organization ); |
407 | createField( FieldImpl::Role, Organization ); | 416 | createField( FieldImpl::Role, Organization ); |
408 | createField( FieldImpl::Organization, Organization ); | 417 | createField( FieldImpl::Organization, Organization ); |
409 | createField( FieldImpl::Note ); | 418 | createField( FieldImpl::Note ); |
410 | createField( FieldImpl::Url ); | 419 | createField( FieldImpl::Url ); |
420 | createField( FieldImpl::Resource ); | ||
411 | } | 421 | } |
412 | 422 | ||
413 | return mAllFields; | 423 | return mAllFields; |
414 | } | 424 | } |
415 | 425 | ||
416 | Field::List Field::defaultFields() | 426 | Field::List Field::defaultFields() |
417 | { | 427 | { |
418 | if ( mDefaultFields.isEmpty() ) { | 428 | if ( mDefaultFields.isEmpty() ) { |
419 | createDefaultField( FieldImpl::GivenName ); | 429 | createDefaultField( FieldImpl::GivenName ); |
420 | createDefaultField( FieldImpl::FamilyName ); | 430 | createDefaultField( FieldImpl::FamilyName ); |
421 | createDefaultField( FieldImpl::Email ); | 431 | createDefaultField( FieldImpl::Email ); |
422 | } | 432 | } |
423 | 433 | ||
424 | return mDefaultFields; | 434 | return mDefaultFields; |
425 | } | 435 | } |
426 | 436 | ||
427 | void Field::createField( int id, int category ) | 437 | void Field::createField( int id, int category ) |
428 | { | 438 | { |
429 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); | 439 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); |
430 | } | 440 | } |
431 | 441 | ||
432 | void Field::createDefaultField( int id, int category ) | 442 | void Field::createDefaultField( int id, int category ) |
433 | { | 443 | { |
434 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); | 444 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); |
435 | } | 445 | } |
436 | 446 | ||
437 | void Field::deleteFields() | 447 | void Field::deleteFields() |
438 | { | 448 | { |
439 | Field::List::ConstIterator it; | 449 | Field::List::ConstIterator it; |
440 | 450 | ||
441 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { | 451 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { |
442 | delete (*it); | 452 | delete (*it); |
443 | } | 453 | } |
444 | mAllFields.clear(); | 454 | mAllFields.clear(); |
445 | 455 | ||
446 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { | 456 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { |
447 | delete (*it); | 457 | delete (*it); |
448 | } | 458 | } |
449 | mDefaultFields.clear(); | 459 | mDefaultFields.clear(); |
450 | 460 | ||
451 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { | 461 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { |
452 | delete (*it); | 462 | delete (*it); |
453 | } | 463 | } |
454 | mCustomFields.clear(); | 464 | mCustomFields.clear(); |
455 | } | 465 | } |
456 | 466 | ||
457 | void Field::saveFields( const QString &identifier, | 467 | void Field::saveFields( const QString &identifier, |
458 | const Field::List &fields ) | 468 | const Field::List &fields ) |
459 | { | 469 | { |
460 | KConfig *cfg = KGlobal::config(); | 470 | KConfig *cfg = KGlobal::config(); |
461 | KConfigGroupSaver( cfg, "KABCFields" ); | 471 | KConfigGroupSaver( cfg, "KABCFields" ); |
462 | saveFields( cfg, identifier, fields ); | 472 | saveFields( cfg, identifier, fields ); |
463 | } | 473 | } |
464 | 474 | ||
465 | void Field::saveFields( KConfig *cfg, const QString &identifier, | 475 | void Field::saveFields( KConfig *cfg, const QString &identifier, |
466 | const Field::List &fields ) | 476 | const Field::List &fields ) |
467 | { | 477 | { |
468 | QValueList<int> fieldIds; | 478 | QValueList<int> fieldIds; |
469 | 479 | ||
470 | //US | 480 | //US |
471 | //US qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); | 481 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); |
472 | 482 | ||
473 | int custom = 0; | 483 | int custom = 0; |
474 | Field::List::ConstIterator it; | 484 | Field::List::ConstIterator it; |
475 | for( it = fields.begin(); it != fields.end(); ++it ) { | 485 | for( it = fields.begin(); it != fields.end(); ++it ) { |
476 | //US | 486 | //US |
477 | //US qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); | 487 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); |
478 | 488 | ||
479 | fieldIds.append( (*it)->mImpl->fieldId() ); | 489 | fieldIds.append( (*it)->mImpl->fieldId() ); |
480 | if( (*it)->isCustom() ) { | 490 | if( (*it)->isCustom() ) { |
481 | QStringList customEntry; | 491 | QStringList customEntry; |
482 | customEntry << (*it)->mImpl->label(); | 492 | customEntry << (*it)->mImpl->label(); |
483 | customEntry << (*it)->mImpl->key(); | 493 | customEntry << (*it)->mImpl->key(); |
484 | customEntry << (*it)->mImpl->app(); | 494 | customEntry << (*it)->mImpl->app(); |
485 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + | 495 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + |
486 | QString::number( custom++ ), customEntry ); | 496 | QString::number( custom++ ), customEntry ); |
487 | } | 497 | } |
488 | } | 498 | } |
489 | cfg->writeEntry( identifier, fieldIds ); | 499 | cfg->writeEntry( identifier, fieldIds ); |
490 | } | 500 | } |
491 | 501 | ||
492 | Field::List Field::restoreFields( const QString &identifier ) | 502 | Field::List Field::restoreFields( const QString &identifier ) |
493 | { | 503 | { |
504 | //US | ||
505 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); | ||
506 | |||
494 | KConfig *cfg = KGlobal::config(); | 507 | KConfig *cfg = KGlobal::config(); |
495 | KConfigGroupSaver( cfg, "KABCFields" ); | 508 | KConfigGroupSaver( cfg, "KABCFields" ); |
496 | cfg->setGroup( "KABCFields" ); | 509 | cfg->setGroup( "KABCFields" ); |
497 | 510 | ||
498 | Field::List l = restoreFields( cfg, identifier ); | 511 | Field::List l = restoreFields( cfg, identifier ); |
499 | 512 | ||
500 | return l; | 513 | return l; |
501 | } | 514 | } |
502 | 515 | ||
503 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) | 516 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) |
504 | { | 517 | { |
505 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); | 518 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); |
506 | //US | 519 | //US |
507 | qDebug("Field::restoreFields from %s", cfg->getFileName().latin1()); | 520 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); |
508 | 521 | ||
509 | Field::List fields; | 522 | Field::List fields; |
510 | 523 | ||
511 | int custom = 0; | 524 | int custom = 0; |
512 | QValueList<int>::ConstIterator it; | 525 | QValueList<int>::ConstIterator it; |
513 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { | 526 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { |
514 | FieldImpl *f = 0; | 527 | FieldImpl *f = 0; |
515 | if ( (*it) == FieldImpl::CustomField ) { | 528 | if ( (*it) == FieldImpl::CustomField ) { |
516 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + | 529 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + |
517 | identifier + "_" + | 530 | identifier + "_" + |
518 | QString::number( custom++ ) ); | 531 | QString::number( custom++ ) ); |
519 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], | 532 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], |
520 | customEntry[ 1 ], customEntry[ 2 ] ); | 533 | customEntry[ 1 ], customEntry[ 2 ] ); |
521 | } else { | 534 | } else { |
522 | f = new FieldImpl( *it ); | 535 | f = new FieldImpl( *it ); |
523 | } | 536 | } |
524 | fields.append( new Field( f ) ); | 537 | fields.append( new Field( f ) ); |
525 | } | 538 | } |
526 | 539 | ||
527 | return fields; | 540 | return fields; |
528 | } | 541 | } |
529 | 542 | ||
530 | bool Field::equals( Field *field ) | 543 | bool Field::equals( Field *field ) |
531 | { | 544 | { |
532 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); | 545 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); |
533 | 546 | ||
534 | if ( !sameId ) return false; | 547 | if ( !sameId ) return false; |
535 | 548 | ||
536 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; | 549 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; |
537 | 550 | ||
538 | return mImpl->key() == field->mImpl->key(); | 551 | return mImpl->key() == field->mImpl->key(); |
539 | } | 552 | } |
540 | 553 | ||
541 | Field *Field::createCustomField( const QString &label, int category, | 554 | Field *Field::createCustomField( const QString &label, int category, |
542 | const QString &key, const QString &app ) | 555 | const QString &key, const QString &app ) |
543 | { | 556 | { |
544 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, | 557 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, |
545 | category | CustomCategory, | 558 | category | CustomCategory, |
546 | label, key, app ) ); | 559 | label, key, app ) ); |
560 | //US | ||
561 | // qDebug("Field::createCustomField label %s", label.latin1() ); | ||
562 | |||
547 | mCustomFields.append( field ); | 563 | mCustomFields.append( field ); |
548 | 564 | ||
549 | return field; | 565 | return field; |
550 | } | 566 | } |