-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/picture.cpp | 38 | ||||
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 30 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 77 |
4 files changed, 99 insertions, 48 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3ce733d..568dfc4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -662,1476 +662,1478 @@ QString Addressee::uid() const | |||
662 | QString Addressee::uidLabel() | 662 | QString Addressee::uidLabel() |
663 | { | 663 | { |
664 | return i18n("Unique Identifier"); | 664 | return i18n("Unique Identifier"); |
665 | } | 665 | } |
666 | 666 | ||
667 | void Addressee::setName( const QString &name ) | 667 | void Addressee::setName( const QString &name ) |
668 | { | 668 | { |
669 | if ( name == mData->name ) return; | 669 | if ( name == mData->name ) return; |
670 | detach(); | 670 | detach(); |
671 | mData->empty = false; | 671 | mData->empty = false; |
672 | mData->name = name; | 672 | mData->name = name; |
673 | } | 673 | } |
674 | 674 | ||
675 | QString Addressee::name() const | 675 | QString Addressee::name() const |
676 | { | 676 | { |
677 | return mData->name; | 677 | return mData->name; |
678 | } | 678 | } |
679 | 679 | ||
680 | QString Addressee::nameLabel() | 680 | QString Addressee::nameLabel() |
681 | { | 681 | { |
682 | return i18n("Name"); | 682 | return i18n("Name"); |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | void Addressee::setFormattedName( const QString &formattedName ) | 686 | void Addressee::setFormattedName( const QString &formattedName ) |
687 | { | 687 | { |
688 | if ( formattedName == mData->formattedName ) return; | 688 | if ( formattedName == mData->formattedName ) return; |
689 | detach(); | 689 | detach(); |
690 | mData->empty = false; | 690 | mData->empty = false; |
691 | mData->formattedName = formattedName; | 691 | mData->formattedName = formattedName; |
692 | } | 692 | } |
693 | 693 | ||
694 | QString Addressee::formattedName() const | 694 | QString Addressee::formattedName() const |
695 | { | 695 | { |
696 | return mData->formattedName; | 696 | return mData->formattedName; |
697 | } | 697 | } |
698 | 698 | ||
699 | QString Addressee::formattedNameLabel() | 699 | QString Addressee::formattedNameLabel() |
700 | { | 700 | { |
701 | return i18n("Formatted Name"); | 701 | return i18n("Formatted Name"); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | void Addressee::setFamilyName( const QString &familyName ) | 705 | void Addressee::setFamilyName( const QString &familyName ) |
706 | { | 706 | { |
707 | if ( familyName == mData->familyName ) return; | 707 | if ( familyName == mData->familyName ) return; |
708 | detach(); | 708 | detach(); |
709 | mData->empty = false; | 709 | mData->empty = false; |
710 | mData->familyName = familyName; | 710 | mData->familyName = familyName; |
711 | } | 711 | } |
712 | 712 | ||
713 | QString Addressee::familyName() const | 713 | QString Addressee::familyName() const |
714 | { | 714 | { |
715 | return mData->familyName; | 715 | return mData->familyName; |
716 | } | 716 | } |
717 | 717 | ||
718 | QString Addressee::familyNameLabel() | 718 | QString Addressee::familyNameLabel() |
719 | { | 719 | { |
720 | return i18n("Family Name"); | 720 | return i18n("Family Name"); |
721 | } | 721 | } |
722 | 722 | ||
723 | 723 | ||
724 | void Addressee::setGivenName( const QString &givenName ) | 724 | void Addressee::setGivenName( const QString &givenName ) |
725 | { | 725 | { |
726 | if ( givenName == mData->givenName ) return; | 726 | if ( givenName == mData->givenName ) return; |
727 | detach(); | 727 | detach(); |
728 | mData->empty = false; | 728 | mData->empty = false; |
729 | mData->givenName = givenName; | 729 | mData->givenName = givenName; |
730 | } | 730 | } |
731 | 731 | ||
732 | QString Addressee::givenName() const | 732 | QString Addressee::givenName() const |
733 | { | 733 | { |
734 | return mData->givenName; | 734 | return mData->givenName; |
735 | } | 735 | } |
736 | 736 | ||
737 | QString Addressee::givenNameLabel() | 737 | QString Addressee::givenNameLabel() |
738 | { | 738 | { |
739 | return i18n("Given Name"); | 739 | return i18n("Given Name"); |
740 | } | 740 | } |
741 | 741 | ||
742 | 742 | ||
743 | void Addressee::setAdditionalName( const QString &additionalName ) | 743 | void Addressee::setAdditionalName( const QString &additionalName ) |
744 | { | 744 | { |
745 | if ( additionalName == mData->additionalName ) return; | 745 | if ( additionalName == mData->additionalName ) return; |
746 | detach(); | 746 | detach(); |
747 | mData->empty = false; | 747 | mData->empty = false; |
748 | mData->additionalName = additionalName; | 748 | mData->additionalName = additionalName; |
749 | } | 749 | } |
750 | 750 | ||
751 | QString Addressee::additionalName() const | 751 | QString Addressee::additionalName() const |
752 | { | 752 | { |
753 | return mData->additionalName; | 753 | return mData->additionalName; |
754 | } | 754 | } |
755 | 755 | ||
756 | QString Addressee::additionalNameLabel() | 756 | QString Addressee::additionalNameLabel() |
757 | { | 757 | { |
758 | return i18n("Additional Names"); | 758 | return i18n("Additional Names"); |
759 | } | 759 | } |
760 | 760 | ||
761 | 761 | ||
762 | void Addressee::setPrefix( const QString &prefix ) | 762 | void Addressee::setPrefix( const QString &prefix ) |
763 | { | 763 | { |
764 | if ( prefix == mData->prefix ) return; | 764 | if ( prefix == mData->prefix ) return; |
765 | detach(); | 765 | detach(); |
766 | mData->empty = false; | 766 | mData->empty = false; |
767 | mData->prefix = prefix; | 767 | mData->prefix = prefix; |
768 | } | 768 | } |
769 | 769 | ||
770 | QString Addressee::prefix() const | 770 | QString Addressee::prefix() const |
771 | { | 771 | { |
772 | return mData->prefix; | 772 | return mData->prefix; |
773 | } | 773 | } |
774 | 774 | ||
775 | QString Addressee::prefixLabel() | 775 | QString Addressee::prefixLabel() |
776 | { | 776 | { |
777 | return i18n("Honorific Prefixes"); | 777 | return i18n("Honorific Prefixes"); |
778 | } | 778 | } |
779 | 779 | ||
780 | 780 | ||
781 | void Addressee::setSuffix( const QString &suffix ) | 781 | void Addressee::setSuffix( const QString &suffix ) |
782 | { | 782 | { |
783 | if ( suffix == mData->suffix ) return; | 783 | if ( suffix == mData->suffix ) return; |
784 | detach(); | 784 | detach(); |
785 | mData->empty = false; | 785 | mData->empty = false; |
786 | mData->suffix = suffix; | 786 | mData->suffix = suffix; |
787 | } | 787 | } |
788 | 788 | ||
789 | QString Addressee::suffix() const | 789 | QString Addressee::suffix() const |
790 | { | 790 | { |
791 | return mData->suffix; | 791 | return mData->suffix; |
792 | } | 792 | } |
793 | 793 | ||
794 | QString Addressee::suffixLabel() | 794 | QString Addressee::suffixLabel() |
795 | { | 795 | { |
796 | return i18n("Honorific Suffixes"); | 796 | return i18n("Honorific Suffixes"); |
797 | } | 797 | } |
798 | 798 | ||
799 | 799 | ||
800 | void Addressee::setNickName( const QString &nickName ) | 800 | void Addressee::setNickName( const QString &nickName ) |
801 | { | 801 | { |
802 | if ( nickName == mData->nickName ) return; | 802 | if ( nickName == mData->nickName ) return; |
803 | detach(); | 803 | detach(); |
804 | mData->empty = false; | 804 | mData->empty = false; |
805 | mData->nickName = nickName; | 805 | mData->nickName = nickName; |
806 | } | 806 | } |
807 | 807 | ||
808 | QString Addressee::nickName() const | 808 | QString Addressee::nickName() const |
809 | { | 809 | { |
810 | return mData->nickName; | 810 | return mData->nickName; |
811 | } | 811 | } |
812 | 812 | ||
813 | QString Addressee::nickNameLabel() | 813 | QString Addressee::nickNameLabel() |
814 | { | 814 | { |
815 | return i18n("Nick Name"); | 815 | return i18n("Nick Name"); |
816 | } | 816 | } |
817 | 817 | ||
818 | 818 | ||
819 | void Addressee::setBirthday( const QDateTime &birthday ) | 819 | void Addressee::setBirthday( const QDateTime &birthday ) |
820 | { | 820 | { |
821 | if ( birthday == mData->birthday ) return; | 821 | if ( birthday == mData->birthday ) return; |
822 | detach(); | 822 | detach(); |
823 | mData->empty = false; | 823 | mData->empty = false; |
824 | mData->birthday = birthday; | 824 | mData->birthday = birthday; |
825 | } | 825 | } |
826 | 826 | ||
827 | QDateTime Addressee::birthday() const | 827 | QDateTime Addressee::birthday() const |
828 | { | 828 | { |
829 | return mData->birthday; | 829 | return mData->birthday; |
830 | } | 830 | } |
831 | 831 | ||
832 | QString Addressee::birthdayLabel() | 832 | QString Addressee::birthdayLabel() |
833 | { | 833 | { |
834 | return i18n("Birthday"); | 834 | return i18n("Birthday"); |
835 | } | 835 | } |
836 | 836 | ||
837 | 837 | ||
838 | QString Addressee::homeAddressStreetLabel() | 838 | QString Addressee::homeAddressStreetLabel() |
839 | { | 839 | { |
840 | return i18n("Home Address Street"); | 840 | return i18n("Home Address Street"); |
841 | } | 841 | } |
842 | 842 | ||
843 | 843 | ||
844 | QString Addressee::homeAddressLocalityLabel() | 844 | QString Addressee::homeAddressLocalityLabel() |
845 | { | 845 | { |
846 | return i18n("Home Address Locality"); | 846 | return i18n("Home Address Locality"); |
847 | } | 847 | } |
848 | 848 | ||
849 | 849 | ||
850 | QString Addressee::homeAddressRegionLabel() | 850 | QString Addressee::homeAddressRegionLabel() |
851 | { | 851 | { |
852 | return i18n("Home Address Region"); | 852 | return i18n("Home Address Region"); |
853 | } | 853 | } |
854 | 854 | ||
855 | 855 | ||
856 | QString Addressee::homeAddressPostalCodeLabel() | 856 | QString Addressee::homeAddressPostalCodeLabel() |
857 | { | 857 | { |
858 | return i18n("Home Address Postal Code"); | 858 | return i18n("Home Address Postal Code"); |
859 | } | 859 | } |
860 | 860 | ||
861 | 861 | ||
862 | QString Addressee::homeAddressCountryLabel() | 862 | QString Addressee::homeAddressCountryLabel() |
863 | { | 863 | { |
864 | return i18n("Home Address Country"); | 864 | return i18n("Home Address Country"); |
865 | } | 865 | } |
866 | 866 | ||
867 | 867 | ||
868 | QString Addressee::homeAddressLabelLabel() | 868 | QString Addressee::homeAddressLabelLabel() |
869 | { | 869 | { |
870 | return i18n("Home Address Label"); | 870 | return i18n("Home Address Label"); |
871 | } | 871 | } |
872 | 872 | ||
873 | 873 | ||
874 | QString Addressee::businessAddressStreetLabel() | 874 | QString Addressee::businessAddressStreetLabel() |
875 | { | 875 | { |
876 | return i18n("Business Address Street"); | 876 | return i18n("Business Address Street"); |
877 | } | 877 | } |
878 | 878 | ||
879 | 879 | ||
880 | QString Addressee::businessAddressLocalityLabel() | 880 | QString Addressee::businessAddressLocalityLabel() |
881 | { | 881 | { |
882 | return i18n("Business Address Locality"); | 882 | return i18n("Business Address Locality"); |
883 | } | 883 | } |
884 | 884 | ||
885 | 885 | ||
886 | QString Addressee::businessAddressRegionLabel() | 886 | QString Addressee::businessAddressRegionLabel() |
887 | { | 887 | { |
888 | return i18n("Business Address Region"); | 888 | return i18n("Business Address Region"); |
889 | } | 889 | } |
890 | 890 | ||
891 | 891 | ||
892 | QString Addressee::businessAddressPostalCodeLabel() | 892 | QString Addressee::businessAddressPostalCodeLabel() |
893 | { | 893 | { |
894 | return i18n("Business Address Postal Code"); | 894 | return i18n("Business Address Postal Code"); |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | QString Addressee::businessAddressCountryLabel() | 898 | QString Addressee::businessAddressCountryLabel() |
899 | { | 899 | { |
900 | return i18n("Business Address Country"); | 900 | return i18n("Business Address Country"); |
901 | } | 901 | } |
902 | 902 | ||
903 | 903 | ||
904 | QString Addressee::businessAddressLabelLabel() | 904 | QString Addressee::businessAddressLabelLabel() |
905 | { | 905 | { |
906 | return i18n("Business Address Label"); | 906 | return i18n("Business Address Label"); |
907 | } | 907 | } |
908 | 908 | ||
909 | 909 | ||
910 | QString Addressee::homePhoneLabel() | 910 | QString Addressee::homePhoneLabel() |
911 | { | 911 | { |
912 | return i18n("Home Phone"); | 912 | return i18n("Home Phone"); |
913 | } | 913 | } |
914 | 914 | ||
915 | 915 | ||
916 | QString Addressee::businessPhoneLabel() | 916 | QString Addressee::businessPhoneLabel() |
917 | { | 917 | { |
918 | return i18n("Business Phone"); | 918 | return i18n("Business Phone"); |
919 | } | 919 | } |
920 | 920 | ||
921 | 921 | ||
922 | QString Addressee::mobilePhoneLabel() | 922 | QString Addressee::mobilePhoneLabel() |
923 | { | 923 | { |
924 | return i18n("Mobile Phone"); | 924 | return i18n("Mobile Phone"); |
925 | } | 925 | } |
926 | 926 | ||
927 | 927 | ||
928 | QString Addressee::homeFaxLabel() | 928 | QString Addressee::homeFaxLabel() |
929 | { | 929 | { |
930 | return i18n("Home Fax"); | 930 | return i18n("Home Fax"); |
931 | } | 931 | } |
932 | 932 | ||
933 | 933 | ||
934 | QString Addressee::businessFaxLabel() | 934 | QString Addressee::businessFaxLabel() |
935 | { | 935 | { |
936 | return i18n("Business Fax"); | 936 | return i18n("Business Fax"); |
937 | } | 937 | } |
938 | 938 | ||
939 | 939 | ||
940 | QString Addressee::carPhoneLabel() | 940 | QString Addressee::carPhoneLabel() |
941 | { | 941 | { |
942 | return i18n("Car Phone"); | 942 | return i18n("Car Phone"); |
943 | } | 943 | } |
944 | 944 | ||
945 | 945 | ||
946 | QString Addressee::isdnLabel() | 946 | QString Addressee::isdnLabel() |
947 | { | 947 | { |
948 | return i18n("ISDN"); | 948 | return i18n("ISDN"); |
949 | } | 949 | } |
950 | 950 | ||
951 | 951 | ||
952 | QString Addressee::pagerLabel() | 952 | QString Addressee::pagerLabel() |
953 | { | 953 | { |
954 | return i18n("Pager"); | 954 | return i18n("Pager"); |
955 | } | 955 | } |
956 | 956 | ||
957 | QString Addressee::sipLabel() | 957 | QString Addressee::sipLabel() |
958 | { | 958 | { |
959 | return i18n("SIP"); | 959 | return i18n("SIP"); |
960 | } | 960 | } |
961 | 961 | ||
962 | QString Addressee::emailLabel() | 962 | QString Addressee::emailLabel() |
963 | { | 963 | { |
964 | return i18n("Email Address"); | 964 | return i18n("Email Address"); |
965 | } | 965 | } |
966 | 966 | ||
967 | 967 | ||
968 | void Addressee::setMailer( const QString &mailer ) | 968 | void Addressee::setMailer( const QString &mailer ) |
969 | { | 969 | { |
970 | if ( mailer == mData->mailer ) return; | 970 | if ( mailer == mData->mailer ) return; |
971 | detach(); | 971 | detach(); |
972 | mData->empty = false; | 972 | mData->empty = false; |
973 | mData->mailer = mailer; | 973 | mData->mailer = mailer; |
974 | } | 974 | } |
975 | 975 | ||
976 | QString Addressee::mailer() const | 976 | QString Addressee::mailer() const |
977 | { | 977 | { |
978 | return mData->mailer; | 978 | return mData->mailer; |
979 | } | 979 | } |
980 | 980 | ||
981 | QString Addressee::mailerLabel() | 981 | QString Addressee::mailerLabel() |
982 | { | 982 | { |
983 | return i18n("Mail Client"); | 983 | return i18n("Mail Client"); |
984 | } | 984 | } |
985 | 985 | ||
986 | 986 | ||
987 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 987 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
988 | { | 988 | { |
989 | if ( timeZone == mData->timeZone ) return; | 989 | if ( timeZone == mData->timeZone ) return; |
990 | detach(); | 990 | detach(); |
991 | mData->empty = false; | 991 | mData->empty = false; |
992 | mData->timeZone = timeZone; | 992 | mData->timeZone = timeZone; |
993 | } | 993 | } |
994 | 994 | ||
995 | TimeZone Addressee::timeZone() const | 995 | TimeZone Addressee::timeZone() const |
996 | { | 996 | { |
997 | return mData->timeZone; | 997 | return mData->timeZone; |
998 | } | 998 | } |
999 | 999 | ||
1000 | QString Addressee::timeZoneLabel() | 1000 | QString Addressee::timeZoneLabel() |
1001 | { | 1001 | { |
1002 | return i18n("Time Zone"); | 1002 | return i18n("Time Zone"); |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | void Addressee::setGeo( const Geo &geo ) | 1006 | void Addressee::setGeo( const Geo &geo ) |
1007 | { | 1007 | { |
1008 | if ( geo == mData->geo ) return; | 1008 | if ( geo == mData->geo ) return; |
1009 | detach(); | 1009 | detach(); |
1010 | mData->empty = false; | 1010 | mData->empty = false; |
1011 | mData->geo = geo; | 1011 | mData->geo = geo; |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | Geo Addressee::geo() const | 1014 | Geo Addressee::geo() const |
1015 | { | 1015 | { |
1016 | return mData->geo; | 1016 | return mData->geo; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | QString Addressee::geoLabel() | 1019 | QString Addressee::geoLabel() |
1020 | { | 1020 | { |
1021 | return i18n("Geographic Position"); | 1021 | return i18n("Geographic Position"); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | 1024 | ||
1025 | void Addressee::setTitle( const QString &title ) | 1025 | void Addressee::setTitle( const QString &title ) |
1026 | { | 1026 | { |
1027 | if ( title == mData->title ) return; | 1027 | if ( title == mData->title ) return; |
1028 | detach(); | 1028 | detach(); |
1029 | mData->empty = false; | 1029 | mData->empty = false; |
1030 | mData->title = title; | 1030 | mData->title = title; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | QString Addressee::title() const | 1033 | QString Addressee::title() const |
1034 | { | 1034 | { |
1035 | return mData->title; | 1035 | return mData->title; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | QString Addressee::titleLabel() | 1038 | QString Addressee::titleLabel() |
1039 | { | 1039 | { |
1040 | return i18n("Title"); | 1040 | return i18n("Title"); |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | 1043 | ||
1044 | void Addressee::setRole( const QString &role ) | 1044 | void Addressee::setRole( const QString &role ) |
1045 | { | 1045 | { |
1046 | if ( role == mData->role ) return; | 1046 | if ( role == mData->role ) return; |
1047 | detach(); | 1047 | detach(); |
1048 | mData->empty = false; | 1048 | mData->empty = false; |
1049 | mData->role = role; | 1049 | mData->role = role; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | QString Addressee::role() const | 1052 | QString Addressee::role() const |
1053 | { | 1053 | { |
1054 | return mData->role; | 1054 | return mData->role; |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | QString Addressee::roleLabel() | 1057 | QString Addressee::roleLabel() |
1058 | { | 1058 | { |
1059 | return i18n("Role"); | 1059 | return i18n("Role"); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | 1062 | ||
1063 | void Addressee::setOrganization( const QString &organization ) | 1063 | void Addressee::setOrganization( const QString &organization ) |
1064 | { | 1064 | { |
1065 | if ( organization == mData->organization ) return; | 1065 | if ( organization == mData->organization ) return; |
1066 | detach(); | 1066 | detach(); |
1067 | mData->empty = false; | 1067 | mData->empty = false; |
1068 | mData->organization = organization; | 1068 | mData->organization = organization; |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | QString Addressee::organization() const | 1071 | QString Addressee::organization() const |
1072 | { | 1072 | { |
1073 | return mData->organization; | 1073 | return mData->organization; |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | QString Addressee::organizationLabel() | 1076 | QString Addressee::organizationLabel() |
1077 | { | 1077 | { |
1078 | return i18n("Organization"); | 1078 | return i18n("Organization"); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | void Addressee::setNote( const QString ¬e ) | 1082 | void Addressee::setNote( const QString ¬e ) |
1083 | { | 1083 | { |
1084 | if ( note == mData->note ) return; | 1084 | if ( note == mData->note ) return; |
1085 | detach(); | 1085 | detach(); |
1086 | mData->empty = false; | 1086 | mData->empty = false; |
1087 | mData->note = note; | 1087 | mData->note = note; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | QString Addressee::note() const | 1090 | QString Addressee::note() const |
1091 | { | 1091 | { |
1092 | return mData->note; | 1092 | return mData->note; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | QString Addressee::noteLabel() | 1095 | QString Addressee::noteLabel() |
1096 | { | 1096 | { |
1097 | return i18n("Note"); | 1097 | return i18n("Note"); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | 1100 | ||
1101 | void Addressee::setProductId( const QString &productId ) | 1101 | void Addressee::setProductId( const QString &productId ) |
1102 | { | 1102 | { |
1103 | if ( productId == mData->productId ) return; | 1103 | if ( productId == mData->productId ) return; |
1104 | detach(); | 1104 | detach(); |
1105 | mData->empty = false; | 1105 | mData->empty = false; |
1106 | mData->productId = productId; | 1106 | mData->productId = productId; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | QString Addressee::productId() const | 1109 | QString Addressee::productId() const |
1110 | { | 1110 | { |
1111 | return mData->productId; | 1111 | return mData->productId; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | QString Addressee::productIdLabel() | 1114 | QString Addressee::productIdLabel() |
1115 | { | 1115 | { |
1116 | return i18n("Product Identifier"); | 1116 | return i18n("Product Identifier"); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | 1119 | ||
1120 | void Addressee::setRevision( const QDateTime &revision ) | 1120 | void Addressee::setRevision( const QDateTime &revision ) |
1121 | { | 1121 | { |
1122 | if ( revision == mData->revision ) return; | 1122 | if ( revision == mData->revision ) return; |
1123 | detach(); | 1123 | detach(); |
1124 | mData->empty = false; | 1124 | mData->empty = false; |
1125 | mData->revision = QDateTime( revision.date(), | 1125 | mData->revision = QDateTime( revision.date(), |
1126 | QTime (revision.time().hour(), | 1126 | QTime (revision.time().hour(), |
1127 | revision.time().minute(), | 1127 | revision.time().minute(), |
1128 | revision.time().second())); | 1128 | revision.time().second())); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | QDateTime Addressee::revision() const | 1131 | QDateTime Addressee::revision() const |
1132 | { | 1132 | { |
1133 | return mData->revision; | 1133 | return mData->revision; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | QString Addressee::revisionLabel() | 1136 | QString Addressee::revisionLabel() |
1137 | { | 1137 | { |
1138 | return i18n("Revision Date"); | 1138 | return i18n("Revision Date"); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | 1141 | ||
1142 | void Addressee::setSortString( const QString &sortString ) | 1142 | void Addressee::setSortString( const QString &sortString ) |
1143 | { | 1143 | { |
1144 | if ( sortString == mData->sortString ) return; | 1144 | if ( sortString == mData->sortString ) return; |
1145 | detach(); | 1145 | detach(); |
1146 | mData->empty = false; | 1146 | mData->empty = false; |
1147 | mData->sortString = sortString; | 1147 | mData->sortString = sortString; |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | QString Addressee::sortString() const | 1150 | QString Addressee::sortString() const |
1151 | { | 1151 | { |
1152 | return mData->sortString; | 1152 | return mData->sortString; |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | QString Addressee::sortStringLabel() | 1155 | QString Addressee::sortStringLabel() |
1156 | { | 1156 | { |
1157 | return i18n("Sort String"); | 1157 | return i18n("Sort String"); |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | 1160 | ||
1161 | void Addressee::setUrl( const KURL &url ) | 1161 | void Addressee::setUrl( const KURL &url ) |
1162 | { | 1162 | { |
1163 | if ( url == mData->url ) return; | 1163 | if ( url == mData->url ) return; |
1164 | detach(); | 1164 | detach(); |
1165 | mData->empty = false; | 1165 | mData->empty = false; |
1166 | mData->url = url; | 1166 | mData->url = url; |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | KURL Addressee::url() const | 1169 | KURL Addressee::url() const |
1170 | { | 1170 | { |
1171 | return mData->url; | 1171 | return mData->url; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | QString Addressee::urlLabel() | 1174 | QString Addressee::urlLabel() |
1175 | { | 1175 | { |
1176 | return i18n("URL"); | 1176 | return i18n("URL"); |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | 1179 | ||
1180 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1180 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1181 | { | 1181 | { |
1182 | if ( secrecy == mData->secrecy ) return; | 1182 | if ( secrecy == mData->secrecy ) return; |
1183 | detach(); | 1183 | detach(); |
1184 | mData->empty = false; | 1184 | mData->empty = false; |
1185 | mData->secrecy = secrecy; | 1185 | mData->secrecy = secrecy; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | Secrecy Addressee::secrecy() const | 1188 | Secrecy Addressee::secrecy() const |
1189 | { | 1189 | { |
1190 | return mData->secrecy; | 1190 | return mData->secrecy; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | QString Addressee::secrecyLabel() | 1193 | QString Addressee::secrecyLabel() |
1194 | { | 1194 | { |
1195 | return i18n("Security Class"); | 1195 | return i18n("Security Class"); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | 1198 | ||
1199 | void Addressee::setLogo( const Picture &logo ) | 1199 | void Addressee::setLogo( const Picture &logo ) |
1200 | { | 1200 | { |
1201 | if ( logo == mData->logo ) return; | 1201 | if ( logo == mData->logo ) return; |
1202 | detach(); | 1202 | detach(); |
1203 | mData->empty = false; | 1203 | mData->empty = false; |
1204 | mData->logo = logo; | 1204 | mData->logo = logo; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | Picture Addressee::logo() const | 1207 | Picture Addressee::logo() const |
1208 | { | 1208 | { |
1209 | return mData->logo; | 1209 | return mData->logo; |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | QString Addressee::logoLabel() | 1212 | QString Addressee::logoLabel() |
1213 | { | 1213 | { |
1214 | return i18n("Logo"); | 1214 | return i18n("Logo"); |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | 1217 | ||
1218 | void Addressee::setPhoto( const Picture &photo ) | 1218 | void Addressee::setPhoto( const Picture &photo ) |
1219 | { | 1219 | { |
1220 | if ( photo == mData->photo ) return; | 1220 | if ( photo == mData->photo ) return; |
1221 | detach(); | 1221 | detach(); |
1222 | mData->empty = false; | 1222 | mData->empty = false; |
1223 | mData->photo = photo; | 1223 | mData->photo = photo; |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | Picture Addressee::photo() const | 1226 | Picture Addressee::photo() const |
1227 | { | 1227 | { |
1228 | return mData->photo; | 1228 | return mData->photo; |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | QString Addressee::photoLabel() | 1231 | QString Addressee::photoLabel() |
1232 | { | 1232 | { |
1233 | return i18n("Photo"); | 1233 | return i18n("Photo"); |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | 1236 | ||
1237 | void Addressee::setSound( const Sound &sound ) | 1237 | void Addressee::setSound( const Sound &sound ) |
1238 | { | 1238 | { |
1239 | if ( sound == mData->sound ) return; | 1239 | if ( sound == mData->sound ) return; |
1240 | detach(); | 1240 | detach(); |
1241 | mData->empty = false; | 1241 | mData->empty = false; |
1242 | mData->sound = sound; | 1242 | mData->sound = sound; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | Sound Addressee::sound() const | 1245 | Sound Addressee::sound() const |
1246 | { | 1246 | { |
1247 | return mData->sound; | 1247 | return mData->sound; |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | QString Addressee::soundLabel() | 1250 | QString Addressee::soundLabel() |
1251 | { | 1251 | { |
1252 | return i18n("Sound"); | 1252 | return i18n("Sound"); |
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | 1255 | ||
1256 | void Addressee::setAgent( const Agent &agent ) | 1256 | void Addressee::setAgent( const Agent &agent ) |
1257 | { | 1257 | { |
1258 | if ( agent == mData->agent ) return; | 1258 | if ( agent == mData->agent ) return; |
1259 | detach(); | 1259 | detach(); |
1260 | mData->empty = false; | 1260 | mData->empty = false; |
1261 | mData->agent = agent; | 1261 | mData->agent = agent; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | Agent Addressee::agent() const | 1264 | Agent Addressee::agent() const |
1265 | { | 1265 | { |
1266 | return mData->agent; | 1266 | return mData->agent; |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | QString Addressee::agentLabel() | 1269 | QString Addressee::agentLabel() |
1270 | { | 1270 | { |
1271 | return i18n("Agent"); | 1271 | return i18n("Agent"); |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | 1274 | ||
1275 | 1275 | ||
1276 | void Addressee::setNameFromString( const QString &str ) | 1276 | void Addressee::setNameFromString( const QString &str ) |
1277 | { | 1277 | { |
1278 | setFormattedName( str ); | 1278 | setFormattedName( str ); |
1279 | setName( str ); | 1279 | setName( str ); |
1280 | 1280 | ||
1281 | static bool first = true; | 1281 | static bool first = true; |
1282 | static QStringList titles; | 1282 | static QStringList titles; |
1283 | static QStringList suffixes; | 1283 | static QStringList suffixes; |
1284 | static QStringList prefixes; | 1284 | static QStringList prefixes; |
1285 | 1285 | ||
1286 | if ( first ) { | 1286 | if ( first ) { |
1287 | first = false; | 1287 | first = false; |
1288 | titles += i18n( "Dr." ); | 1288 | titles += i18n( "Dr." ); |
1289 | titles += i18n( "Miss" ); | 1289 | titles += i18n( "Miss" ); |
1290 | titles += i18n( "Mr." ); | 1290 | titles += i18n( "Mr." ); |
1291 | titles += i18n( "Mrs." ); | 1291 | titles += i18n( "Mrs." ); |
1292 | titles += i18n( "Ms." ); | 1292 | titles += i18n( "Ms." ); |
1293 | titles += i18n( "Prof." ); | 1293 | titles += i18n( "Prof." ); |
1294 | 1294 | ||
1295 | suffixes += i18n( "I" ); | 1295 | suffixes += i18n( "I" ); |
1296 | suffixes += i18n( "II" ); | 1296 | suffixes += i18n( "II" ); |
1297 | suffixes += i18n( "III" ); | 1297 | suffixes += i18n( "III" ); |
1298 | suffixes += i18n( "Jr." ); | 1298 | suffixes += i18n( "Jr." ); |
1299 | suffixes += i18n( "Sr." ); | 1299 | suffixes += i18n( "Sr." ); |
1300 | 1300 | ||
1301 | prefixes += "van"; | 1301 | prefixes += "van"; |
1302 | prefixes += "von"; | 1302 | prefixes += "von"; |
1303 | prefixes += "de"; | 1303 | prefixes += "de"; |
1304 | 1304 | ||
1305 | KConfig config( locateLocal( "config", "kabcrc") ); | 1305 | KConfig config( locateLocal( "config", "kabcrc") ); |
1306 | config.setGroup( "General" ); | 1306 | config.setGroup( "General" ); |
1307 | titles += config.readListEntry( "Prefixes" ); | 1307 | titles += config.readListEntry( "Prefixes" ); |
1308 | titles.remove( "" ); | 1308 | titles.remove( "" ); |
1309 | prefixes += config.readListEntry( "Inclusions" ); | 1309 | prefixes += config.readListEntry( "Inclusions" ); |
1310 | prefixes.remove( "" ); | 1310 | prefixes.remove( "" ); |
1311 | suffixes += config.readListEntry( "Suffixes" ); | 1311 | suffixes += config.readListEntry( "Suffixes" ); |
1312 | suffixes.remove( "" ); | 1312 | suffixes.remove( "" ); |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | // clear all name parts | 1315 | // clear all name parts |
1316 | setPrefix( "" ); | 1316 | setPrefix( "" ); |
1317 | setGivenName( "" ); | 1317 | setGivenName( "" ); |
1318 | setAdditionalName( "" ); | 1318 | setAdditionalName( "" ); |
1319 | setFamilyName( "" ); | 1319 | setFamilyName( "" ); |
1320 | setSuffix( "" ); | 1320 | setSuffix( "" ); |
1321 | 1321 | ||
1322 | if ( str.isEmpty() ) | 1322 | if ( str.isEmpty() ) |
1323 | return; | 1323 | return; |
1324 | 1324 | ||
1325 | int i = str.find(','); | 1325 | int i = str.find(','); |
1326 | if( i < 0 ) { | 1326 | if( i < 0 ) { |
1327 | QStringList parts = QStringList::split( " ", str ); | 1327 | QStringList parts = QStringList::split( " ", str ); |
1328 | int leftOffset = 0; | 1328 | int leftOffset = 0; |
1329 | int rightOffset = parts.count() - 1; | 1329 | int rightOffset = parts.count() - 1; |
1330 | 1330 | ||
1331 | QString suffix; | 1331 | QString suffix; |
1332 | while ( rightOffset >= 0 ) { | 1332 | while ( rightOffset >= 0 ) { |
1333 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1333 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1334 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1334 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1335 | rightOffset--; | 1335 | rightOffset--; |
1336 | } else | 1336 | } else |
1337 | break; | 1337 | break; |
1338 | } | 1338 | } |
1339 | setSuffix( suffix ); | 1339 | setSuffix( suffix ); |
1340 | 1340 | ||
1341 | if ( rightOffset < 0 ) | 1341 | if ( rightOffset < 0 ) |
1342 | return; | 1342 | return; |
1343 | 1343 | ||
1344 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1344 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1345 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1345 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1346 | rightOffset--; | 1346 | rightOffset--; |
1347 | } else | 1347 | } else |
1348 | setFamilyName( parts[ rightOffset ] ); | 1348 | setFamilyName( parts[ rightOffset ] ); |
1349 | 1349 | ||
1350 | QString prefix; | 1350 | QString prefix; |
1351 | while ( leftOffset < rightOffset ) { | 1351 | while ( leftOffset < rightOffset ) { |
1352 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1352 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1353 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1353 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1354 | leftOffset++; | 1354 | leftOffset++; |
1355 | } else | 1355 | } else |
1356 | break; | 1356 | break; |
1357 | } | 1357 | } |
1358 | setPrefix( prefix ); | 1358 | setPrefix( prefix ); |
1359 | 1359 | ||
1360 | if ( leftOffset < rightOffset ) { | 1360 | if ( leftOffset < rightOffset ) { |
1361 | setGivenName( parts[ leftOffset ] ); | 1361 | setGivenName( parts[ leftOffset ] ); |
1362 | leftOffset++; | 1362 | leftOffset++; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | QString additionalName; | 1365 | QString additionalName; |
1366 | while ( leftOffset < rightOffset ) { | 1366 | while ( leftOffset < rightOffset ) { |
1367 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1367 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1368 | leftOffset++; | 1368 | leftOffset++; |
1369 | } | 1369 | } |
1370 | setAdditionalName( additionalName ); | 1370 | setAdditionalName( additionalName ); |
1371 | } else { | 1371 | } else { |
1372 | QString part1 = str.left( i ); | 1372 | QString part1 = str.left( i ); |
1373 | QString part2 = str.mid( i + 1 ); | 1373 | QString part2 = str.mid( i + 1 ); |
1374 | 1374 | ||
1375 | QStringList parts = QStringList::split( " ", part1 ); | 1375 | QStringList parts = QStringList::split( " ", part1 ); |
1376 | int leftOffset = 0; | 1376 | int leftOffset = 0; |
1377 | int rightOffset = parts.count() - 1; | 1377 | int rightOffset = parts.count() - 1; |
1378 | 1378 | ||
1379 | QString suffix; | 1379 | QString suffix; |
1380 | while ( rightOffset >= 0 ) { | 1380 | while ( rightOffset >= 0 ) { |
1381 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1381 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1382 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1382 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1383 | rightOffset--; | 1383 | rightOffset--; |
1384 | } else | 1384 | } else |
1385 | break; | 1385 | break; |
1386 | } | 1386 | } |
1387 | setSuffix( suffix ); | 1387 | setSuffix( suffix ); |
1388 | 1388 | ||
1389 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1389 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1390 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1390 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1391 | rightOffset--; | 1391 | rightOffset--; |
1392 | } else | 1392 | } else |
1393 | setFamilyName( parts[ rightOffset ] ); | 1393 | setFamilyName( parts[ rightOffset ] ); |
1394 | 1394 | ||
1395 | QString prefix; | 1395 | QString prefix; |
1396 | while ( leftOffset < rightOffset ) { | 1396 | while ( leftOffset < rightOffset ) { |
1397 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1397 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1398 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1398 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1399 | leftOffset++; | 1399 | leftOffset++; |
1400 | } else | 1400 | } else |
1401 | break; | 1401 | break; |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | parts = QStringList::split( " ", part2 ); | 1404 | parts = QStringList::split( " ", part2 ); |
1405 | 1405 | ||
1406 | leftOffset = 0; | 1406 | leftOffset = 0; |
1407 | rightOffset = parts.count(); | 1407 | rightOffset = parts.count(); |
1408 | 1408 | ||
1409 | while ( leftOffset < rightOffset ) { | 1409 | while ( leftOffset < rightOffset ) { |
1410 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1410 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1412 | leftOffset++; | 1412 | leftOffset++; |
1413 | } else | 1413 | } else |
1414 | break; | 1414 | break; |
1415 | } | 1415 | } |
1416 | setPrefix( prefix ); | 1416 | setPrefix( prefix ); |
1417 | 1417 | ||
1418 | if ( leftOffset < rightOffset ) { | 1418 | if ( leftOffset < rightOffset ) { |
1419 | setGivenName( parts[ leftOffset ] ); | 1419 | setGivenName( parts[ leftOffset ] ); |
1420 | leftOffset++; | 1420 | leftOffset++; |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | QString additionalName; | 1423 | QString additionalName; |
1424 | while ( leftOffset < rightOffset ) { | 1424 | while ( leftOffset < rightOffset ) { |
1425 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1425 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1426 | leftOffset++; | 1426 | leftOffset++; |
1427 | } | 1427 | } |
1428 | setAdditionalName( additionalName ); | 1428 | setAdditionalName( additionalName ); |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | QString Addressee::realName() const | 1432 | QString Addressee::realName() const |
1433 | { | 1433 | { |
1434 | if ( !formattedName().isEmpty() ) | 1434 | if ( !formattedName().isEmpty() ) |
1435 | return formattedName(); | 1435 | return formattedName(); |
1436 | 1436 | ||
1437 | QString n = assembledName(); | 1437 | QString n = assembledName(); |
1438 | 1438 | ||
1439 | if ( n.isEmpty() ) | 1439 | if ( n.isEmpty() ) |
1440 | n = name(); | 1440 | n = name(); |
1441 | 1441 | ||
1442 | return n; | 1442 | return n; |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | QString Addressee::assembledName() const | 1445 | QString Addressee::assembledName() const |
1446 | { | 1446 | { |
1447 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1447 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1448 | familyName() + " " + suffix(); | 1448 | familyName() + " " + suffix(); |
1449 | 1449 | ||
1450 | return name.simplifyWhiteSpace(); | 1450 | return name.simplifyWhiteSpace(); |
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | QString Addressee::fullEmail( const QString &email ) const | 1453 | QString Addressee::fullEmail( const QString &email ) const |
1454 | { | 1454 | { |
1455 | QString e; | 1455 | QString e; |
1456 | if ( email.isNull() ) { | 1456 | if ( email.isNull() ) { |
1457 | e = preferredEmail(); | 1457 | e = preferredEmail(); |
1458 | } else { | 1458 | } else { |
1459 | e = email; | 1459 | e = email; |
1460 | } | 1460 | } |
1461 | if ( e.isEmpty() ) return QString::null; | 1461 | if ( e.isEmpty() ) return QString::null; |
1462 | 1462 | ||
1463 | QString text; | 1463 | QString text; |
1464 | if ( realName().isEmpty() ) | 1464 | if ( realName().isEmpty() ) |
1465 | text = e; | 1465 | text = e; |
1466 | else | 1466 | else |
1467 | text = assembledName() + " <" + e + ">"; | 1467 | text = assembledName() + " <" + e + ">"; |
1468 | 1468 | ||
1469 | return text; | 1469 | return text; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1472 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1473 | { | 1473 | { |
1474 | detach(); | 1474 | detach(); |
1475 | 1475 | ||
1476 | QStringList::Iterator it = mData->emails.find( email ); | 1476 | QStringList::Iterator it = mData->emails.find( email ); |
1477 | 1477 | ||
1478 | if ( it != mData->emails.end() ) { | 1478 | if ( it != mData->emails.end() ) { |
1479 | if ( !preferred || it == mData->emails.begin() ) return; | 1479 | if ( !preferred || it == mData->emails.begin() ) return; |
1480 | mData->emails.remove( it ); | 1480 | mData->emails.remove( it ); |
1481 | mData->emails.prepend( email ); | 1481 | mData->emails.prepend( email ); |
1482 | } else { | 1482 | } else { |
1483 | if ( preferred ) { | 1483 | if ( preferred ) { |
1484 | mData->emails.prepend( email ); | 1484 | mData->emails.prepend( email ); |
1485 | } else { | 1485 | } else { |
1486 | mData->emails.append( email ); | 1486 | mData->emails.append( email ); |
1487 | } | 1487 | } |
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void Addressee::removeEmail( const QString &email ) | 1491 | void Addressee::removeEmail( const QString &email ) |
1492 | { | 1492 | { |
1493 | detach(); | 1493 | detach(); |
1494 | 1494 | ||
1495 | QStringList::Iterator it = mData->emails.find( email ); | 1495 | QStringList::Iterator it = mData->emails.find( email ); |
1496 | if ( it == mData->emails.end() ) return; | 1496 | if ( it == mData->emails.end() ) return; |
1497 | 1497 | ||
1498 | mData->emails.remove( it ); | 1498 | mData->emails.remove( it ); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | QString Addressee::preferredEmail() const | 1501 | QString Addressee::preferredEmail() const |
1502 | { | 1502 | { |
1503 | if ( mData->emails.count() == 0 ) return QString::null; | 1503 | if ( mData->emails.count() == 0 ) return QString::null; |
1504 | else return mData->emails.first(); | 1504 | else return mData->emails.first(); |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | QStringList Addressee::emails() const | 1507 | QStringList Addressee::emails() const |
1508 | { | 1508 | { |
1509 | return mData->emails; | 1509 | return mData->emails; |
1510 | } | 1510 | } |
1511 | void Addressee::setEmails( const QStringList& emails ) { | 1511 | void Addressee::setEmails( const QStringList& emails ) { |
1512 | detach(); | 1512 | detach(); |
1513 | mData->emails = emails; | 1513 | mData->emails = emails; |
1514 | } | 1514 | } |
1515 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1515 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1516 | { | 1516 | { |
1517 | detach(); | 1517 | detach(); |
1518 | mData->empty = false; | 1518 | mData->empty = false; |
1519 | 1519 | ||
1520 | PhoneNumber::List::Iterator it; | 1520 | PhoneNumber::List::Iterator it; |
1521 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1521 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1522 | if ( (*it).id() == phoneNumber.id() ) { | 1522 | if ( (*it).id() == phoneNumber.id() ) { |
1523 | *it = phoneNumber; | 1523 | *it = phoneNumber; |
1524 | return; | 1524 | return; |
1525 | } | 1525 | } |
1526 | } | 1526 | } |
1527 | mData->phoneNumbers.append( phoneNumber ); | 1527 | mData->phoneNumbers.append( phoneNumber ); |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1530 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1531 | { | 1531 | { |
1532 | detach(); | 1532 | detach(); |
1533 | 1533 | ||
1534 | PhoneNumber::List::Iterator it; | 1534 | PhoneNumber::List::Iterator it; |
1535 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1535 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1536 | if ( (*it).id() == phoneNumber.id() ) { | 1536 | if ( (*it).id() == phoneNumber.id() ) { |
1537 | mData->phoneNumbers.remove( it ); | 1537 | mData->phoneNumbers.remove( it ); |
1538 | return; | 1538 | return; |
1539 | } | 1539 | } |
1540 | } | 1540 | } |
1541 | } | 1541 | } |
1542 | 1542 | ||
1543 | PhoneNumber Addressee::phoneNumber( int type ) const | 1543 | PhoneNumber Addressee::phoneNumber( int type ) const |
1544 | { | 1544 | { |
1545 | PhoneNumber phoneNumber( "", type ); | 1545 | PhoneNumber phoneNumber( "", type ); |
1546 | PhoneNumber::List::ConstIterator it; | 1546 | PhoneNumber::List::ConstIterator it; |
1547 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1547 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1548 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1548 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1549 | if ( (*it).type() & PhoneNumber::Pref ) | 1549 | if ( (*it).type() & PhoneNumber::Pref ) |
1550 | return (*it); | 1550 | return (*it); |
1551 | else if ( phoneNumber.number().isEmpty() ) | 1551 | else if ( phoneNumber.number().isEmpty() ) |
1552 | phoneNumber = (*it); | 1552 | phoneNumber = (*it); |
1553 | } | 1553 | } |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | return phoneNumber; | 1556 | return phoneNumber; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | PhoneNumber::List Addressee::phoneNumbers() const | 1559 | PhoneNumber::List Addressee::phoneNumbers() const |
1560 | { | 1560 | { |
1561 | return mData->phoneNumbers; | 1561 | return mData->phoneNumbers; |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1564 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1565 | { | 1565 | { |
1566 | PhoneNumber::List list; | 1566 | PhoneNumber::List list; |
1567 | 1567 | ||
1568 | PhoneNumber::List::ConstIterator it; | 1568 | PhoneNumber::List::ConstIterator it; |
1569 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1569 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1570 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1570 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1571 | list.append( *it ); | 1571 | list.append( *it ); |
1572 | } | 1572 | } |
1573 | } | 1573 | } |
1574 | return list; | 1574 | return list; |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1577 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1578 | { | 1578 | { |
1579 | PhoneNumber::List::ConstIterator it; | 1579 | PhoneNumber::List::ConstIterator it; |
1580 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1580 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1581 | if ( (*it).id() == id ) { | 1581 | if ( (*it).id() == id ) { |
1582 | return *it; | 1582 | return *it; |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | return PhoneNumber(); | 1585 | return PhoneNumber(); |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | void Addressee::insertKey( const Key &key ) | 1588 | void Addressee::insertKey( const Key &key ) |
1589 | { | 1589 | { |
1590 | detach(); | 1590 | detach(); |
1591 | mData->empty = false; | 1591 | mData->empty = false; |
1592 | 1592 | ||
1593 | Key::List::Iterator it; | 1593 | Key::List::Iterator it; |
1594 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1594 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1595 | if ( (*it).id() == key.id() ) { | 1595 | if ( (*it).id() == key.id() ) { |
1596 | *it = key; | 1596 | *it = key; |
1597 | return; | 1597 | return; |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | mData->keys.append( key ); | 1600 | mData->keys.append( key ); |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | void Addressee::removeKey( const Key &key ) | 1603 | void Addressee::removeKey( const Key &key ) |
1604 | { | 1604 | { |
1605 | detach(); | 1605 | detach(); |
1606 | 1606 | ||
1607 | Key::List::Iterator it; | 1607 | Key::List::Iterator it; |
1608 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1608 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1609 | if ( (*it).id() == key.id() ) { | 1609 | if ( (*it).id() == key.id() ) { |
1610 | mData->keys.remove( key ); | 1610 | mData->keys.remove( key ); |
1611 | return; | 1611 | return; |
1612 | } | 1612 | } |
1613 | } | 1613 | } |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | Key Addressee::key( int type, QString customTypeString ) const | 1616 | Key Addressee::key( int type, QString customTypeString ) const |
1617 | { | 1617 | { |
1618 | Key::List::ConstIterator it; | 1618 | Key::List::ConstIterator it; |
1619 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1619 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1620 | if ( (*it).type() == type ) { | 1620 | if ( (*it).type() == type ) { |
1621 | if ( type == Key::Custom ) { | 1621 | if ( type == Key::Custom ) { |
1622 | if ( customTypeString.isEmpty() ) { | 1622 | if ( customTypeString.isEmpty() ) { |
1623 | return *it; | 1623 | return *it; |
1624 | } else { | 1624 | } else { |
1625 | if ( (*it).customTypeString() == customTypeString ) | 1625 | if ( (*it).customTypeString() == customTypeString ) |
1626 | return (*it); | 1626 | return (*it); |
1627 | } | 1627 | } |
1628 | } else { | 1628 | } else { |
1629 | return *it; | 1629 | return *it; |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | return Key( QString(), type ); | 1633 | return Key( QString(), type ); |
1634 | } | 1634 | } |
1635 | void Addressee::setKeys( const Key::List& list ) { | 1635 | void Addressee::setKeys( const Key::List& list ) { |
1636 | detach(); | 1636 | detach(); |
1637 | mData->keys = list; | 1637 | mData->keys = list; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | Key::List Addressee::keys() const | 1640 | Key::List Addressee::keys() const |
1641 | { | 1641 | { |
1642 | return mData->keys; | 1642 | return mData->keys; |
1643 | } | 1643 | } |
1644 | 1644 | ||
1645 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1645 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1646 | { | 1646 | { |
1647 | Key::List list; | 1647 | Key::List list; |
1648 | 1648 | ||
1649 | Key::List::ConstIterator it; | 1649 | Key::List::ConstIterator it; |
1650 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1650 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1651 | if ( (*it).type() == type ) { | 1651 | if ( (*it).type() == type ) { |
1652 | if ( type == Key::Custom ) { | 1652 | if ( type == Key::Custom ) { |
1653 | if ( customTypeString.isEmpty() ) { | 1653 | if ( customTypeString.isEmpty() ) { |
1654 | list.append(*it); | 1654 | list.append(*it); |
1655 | } else { | 1655 | } else { |
1656 | if ( (*it).customTypeString() == customTypeString ) | 1656 | if ( (*it).customTypeString() == customTypeString ) |
1657 | list.append(*it); | 1657 | list.append(*it); |
1658 | } | 1658 | } |
1659 | } else { | 1659 | } else { |
1660 | list.append(*it); | 1660 | list.append(*it); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | return list; | 1664 | return list; |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | Key Addressee::findKey( const QString &id ) const | 1667 | Key Addressee::findKey( const QString &id ) const |
1668 | { | 1668 | { |
1669 | Key::List::ConstIterator it; | 1669 | Key::List::ConstIterator it; |
1670 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1670 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1671 | if ( (*it).id() == id ) { | 1671 | if ( (*it).id() == id ) { |
1672 | return *it; | 1672 | return *it; |
1673 | } | 1673 | } |
1674 | } | 1674 | } |
1675 | return Key(); | 1675 | return Key(); |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | QString Addressee::asString() const | 1678 | QString Addressee::asString() const |
1679 | { | 1679 | { |
1680 | return "Smith, agent Smith..."; | 1680 | return "Smith, agent Smith..."; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | void Addressee::dump() const | 1683 | void Addressee::dump() const |
1684 | { | 1684 | { |
1685 | return; | 1685 | return; |
1686 | #if 0 | ||
1686 | kdDebug(5700) << "Addressee {" << endl; | 1687 | kdDebug(5700) << "Addressee {" << endl; |
1687 | 1688 | ||
1688 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1689 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1689 | 1690 | ||
1690 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1691 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1691 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1692 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1692 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1693 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1693 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1694 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1694 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1695 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1695 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1696 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1696 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1697 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1697 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1698 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1698 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1699 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1699 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1700 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1700 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1701 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1701 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1702 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1702 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1703 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1703 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1704 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1704 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1705 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1705 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1706 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1706 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1707 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1707 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1708 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1708 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1709 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1709 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1710 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1710 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1711 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1711 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1712 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1712 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1713 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1713 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1714 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1715 | 1716 | ||
1716 | kdDebug(5700) << " Emails {" << endl; | 1717 | kdDebug(5700) << " Emails {" << endl; |
1717 | QStringList e = emails(); | 1718 | QStringList e = emails(); |
1718 | QStringList::ConstIterator it; | 1719 | QStringList::ConstIterator it; |
1719 | for( it = e.begin(); it != e.end(); ++it ) { | 1720 | for( it = e.begin(); it != e.end(); ++it ) { |
1720 | kdDebug(5700) << " " << (*it) << endl; | 1721 | kdDebug(5700) << " " << (*it) << endl; |
1721 | } | 1722 | } |
1722 | kdDebug(5700) << " }" << endl; | 1723 | kdDebug(5700) << " }" << endl; |
1723 | 1724 | ||
1724 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1725 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1725 | PhoneNumber::List p = phoneNumbers(); | 1726 | PhoneNumber::List p = phoneNumbers(); |
1726 | PhoneNumber::List::ConstIterator it2; | 1727 | PhoneNumber::List::ConstIterator it2; |
1727 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1728 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1728 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1729 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1729 | } | 1730 | } |
1730 | kdDebug(5700) << " }" << endl; | 1731 | kdDebug(5700) << " }" << endl; |
1731 | 1732 | ||
1732 | Address::List a = addresses(); | 1733 | Address::List a = addresses(); |
1733 | Address::List::ConstIterator it3; | 1734 | Address::List::ConstIterator it3; |
1734 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1735 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1735 | (*it3).dump(); | 1736 | (*it3).dump(); |
1736 | } | 1737 | } |
1737 | 1738 | ||
1738 | kdDebug(5700) << " Keys {" << endl; | 1739 | kdDebug(5700) << " Keys {" << endl; |
1739 | Key::List k = keys(); | 1740 | Key::List k = keys(); |
1740 | Key::List::ConstIterator it4; | 1741 | Key::List::ConstIterator it4; |
1741 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1742 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1742 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1743 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1743 | " Key: " << (*it4).textData() << | 1744 | " Key: " << (*it4).textData() << |
1744 | " CustomString: " << (*it4).customTypeString() << endl; | 1745 | " CustomString: " << (*it4).customTypeString() << endl; |
1745 | } | 1746 | } |
1746 | kdDebug(5700) << " }" << endl; | 1747 | kdDebug(5700) << " }" << endl; |
1747 | 1748 | ||
1748 | kdDebug(5700) << "}" << endl; | 1749 | kdDebug(5700) << "}" << endl; |
1750 | #endif | ||
1749 | } | 1751 | } |
1750 | 1752 | ||
1751 | 1753 | ||
1752 | void Addressee::insertAddress( const Address &address ) | 1754 | void Addressee::insertAddress( const Address &address ) |
1753 | { | 1755 | { |
1754 | detach(); | 1756 | detach(); |
1755 | mData->empty = false; | 1757 | mData->empty = false; |
1756 | 1758 | ||
1757 | Address::List::Iterator it; | 1759 | Address::List::Iterator it; |
1758 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1760 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1759 | if ( (*it).id() == address.id() ) { | 1761 | if ( (*it).id() == address.id() ) { |
1760 | *it = address; | 1762 | *it = address; |
1761 | return; | 1763 | return; |
1762 | } | 1764 | } |
1763 | } | 1765 | } |
1764 | mData->addresses.append( address ); | 1766 | mData->addresses.append( address ); |
1765 | } | 1767 | } |
1766 | 1768 | ||
1767 | void Addressee::removeAddress( const Address &address ) | 1769 | void Addressee::removeAddress( const Address &address ) |
1768 | { | 1770 | { |
1769 | detach(); | 1771 | detach(); |
1770 | 1772 | ||
1771 | Address::List::Iterator it; | 1773 | Address::List::Iterator it; |
1772 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1774 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1773 | if ( (*it).id() == address.id() ) { | 1775 | if ( (*it).id() == address.id() ) { |
1774 | mData->addresses.remove( it ); | 1776 | mData->addresses.remove( it ); |
1775 | return; | 1777 | return; |
1776 | } | 1778 | } |
1777 | } | 1779 | } |
1778 | } | 1780 | } |
1779 | 1781 | ||
1780 | Address Addressee::address( int type ) const | 1782 | Address Addressee::address( int type ) const |
1781 | { | 1783 | { |
1782 | Address address( type ); | 1784 | Address address( type ); |
1783 | Address::List::ConstIterator it; | 1785 | Address::List::ConstIterator it; |
1784 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1786 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1785 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1787 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1786 | if ( (*it).type() & Address::Pref ) | 1788 | if ( (*it).type() & Address::Pref ) |
1787 | return (*it); | 1789 | return (*it); |
1788 | else if ( address.isEmpty() ) | 1790 | else if ( address.isEmpty() ) |
1789 | address = (*it); | 1791 | address = (*it); |
1790 | } | 1792 | } |
1791 | } | 1793 | } |
1792 | 1794 | ||
1793 | return address; | 1795 | return address; |
1794 | } | 1796 | } |
1795 | 1797 | ||
1796 | Address::List Addressee::addresses() const | 1798 | Address::List Addressee::addresses() const |
1797 | { | 1799 | { |
1798 | return mData->addresses; | 1800 | return mData->addresses; |
1799 | } | 1801 | } |
1800 | 1802 | ||
1801 | Address::List Addressee::addresses( int type ) const | 1803 | Address::List Addressee::addresses( int type ) const |
1802 | { | 1804 | { |
1803 | Address::List list; | 1805 | Address::List list; |
1804 | 1806 | ||
1805 | Address::List::ConstIterator it; | 1807 | Address::List::ConstIterator it; |
1806 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1808 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1807 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1809 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1808 | list.append( *it ); | 1810 | list.append( *it ); |
1809 | } | 1811 | } |
1810 | } | 1812 | } |
1811 | 1813 | ||
1812 | return list; | 1814 | return list; |
1813 | } | 1815 | } |
1814 | 1816 | ||
1815 | Address Addressee::findAddress( const QString &id ) const | 1817 | Address Addressee::findAddress( const QString &id ) const |
1816 | { | 1818 | { |
1817 | Address::List::ConstIterator it; | 1819 | Address::List::ConstIterator it; |
1818 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1820 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1819 | if ( (*it).id() == id ) { | 1821 | if ( (*it).id() == id ) { |
1820 | return *it; | 1822 | return *it; |
1821 | } | 1823 | } |
1822 | } | 1824 | } |
1823 | return Address(); | 1825 | return Address(); |
1824 | } | 1826 | } |
1825 | 1827 | ||
1826 | void Addressee::insertCategory( const QString &c ) | 1828 | void Addressee::insertCategory( const QString &c ) |
1827 | { | 1829 | { |
1828 | detach(); | 1830 | detach(); |
1829 | mData->empty = false; | 1831 | mData->empty = false; |
1830 | 1832 | ||
1831 | if ( mData->categories.contains( c ) ) return; | 1833 | if ( mData->categories.contains( c ) ) return; |
1832 | 1834 | ||
1833 | mData->categories.append( c ); | 1835 | mData->categories.append( c ); |
1834 | } | 1836 | } |
1835 | 1837 | ||
1836 | void Addressee::removeCategory( const QString &c ) | 1838 | void Addressee::removeCategory( const QString &c ) |
1837 | { | 1839 | { |
1838 | detach(); | 1840 | detach(); |
1839 | 1841 | ||
1840 | QStringList::Iterator it = mData->categories.find( c ); | 1842 | QStringList::Iterator it = mData->categories.find( c ); |
1841 | if ( it == mData->categories.end() ) return; | 1843 | if ( it == mData->categories.end() ) return; |
1842 | 1844 | ||
1843 | mData->categories.remove( it ); | 1845 | mData->categories.remove( it ); |
1844 | } | 1846 | } |
1845 | 1847 | ||
1846 | bool Addressee::hasCategory( const QString &c ) const | 1848 | bool Addressee::hasCategory( const QString &c ) const |
1847 | { | 1849 | { |
1848 | return ( mData->categories.contains( c ) ); | 1850 | return ( mData->categories.contains( c ) ); |
1849 | } | 1851 | } |
1850 | 1852 | ||
1851 | void Addressee::setCategories( const QStringList &c ) | 1853 | void Addressee::setCategories( const QStringList &c ) |
1852 | { | 1854 | { |
1853 | detach(); | 1855 | detach(); |
1854 | mData->empty = false; | 1856 | mData->empty = false; |
1855 | 1857 | ||
1856 | mData->categories = c; | 1858 | mData->categories = c; |
1857 | } | 1859 | } |
1858 | 1860 | ||
1859 | QStringList Addressee::categories() const | 1861 | QStringList Addressee::categories() const |
1860 | { | 1862 | { |
1861 | return mData->categories; | 1863 | return mData->categories; |
1862 | } | 1864 | } |
1863 | 1865 | ||
1864 | void Addressee::insertCustom( const QString &app, const QString &name, | 1866 | void Addressee::insertCustom( const QString &app, const QString &name, |
1865 | const QString &value ) | 1867 | const QString &value ) |
1866 | { | 1868 | { |
1867 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1869 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1868 | 1870 | ||
1869 | detach(); | 1871 | detach(); |
1870 | mData->empty = false; | 1872 | mData->empty = false; |
1871 | 1873 | ||
1872 | QString qualifiedName = app + "-" + name + ":"; | 1874 | QString qualifiedName = app + "-" + name + ":"; |
1873 | 1875 | ||
1874 | QStringList::Iterator it; | 1876 | QStringList::Iterator it; |
1875 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1877 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1876 | if ( (*it).startsWith( qualifiedName ) ) { | 1878 | if ( (*it).startsWith( qualifiedName ) ) { |
1877 | (*it) = qualifiedName + value; | 1879 | (*it) = qualifiedName + value; |
1878 | return; | 1880 | return; |
1879 | } | 1881 | } |
1880 | } | 1882 | } |
1881 | mData->custom.append( qualifiedName + value ); | 1883 | mData->custom.append( qualifiedName + value ); |
1882 | } | 1884 | } |
1883 | 1885 | ||
1884 | void Addressee::removeCustom( const QString &app, const QString &name) | 1886 | void Addressee::removeCustom( const QString &app, const QString &name) |
1885 | { | 1887 | { |
1886 | detach(); | 1888 | detach(); |
1887 | 1889 | ||
1888 | QString qualifiedName = app + "-" + name + ":"; | 1890 | QString qualifiedName = app + "-" + name + ":"; |
1889 | 1891 | ||
1890 | QStringList::Iterator it; | 1892 | QStringList::Iterator it; |
1891 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1893 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1892 | if ( (*it).startsWith( qualifiedName ) ) { | 1894 | if ( (*it).startsWith( qualifiedName ) ) { |
1893 | mData->custom.remove( it ); | 1895 | mData->custom.remove( it ); |
1894 | return; | 1896 | return; |
1895 | } | 1897 | } |
1896 | } | 1898 | } |
1897 | } | 1899 | } |
1898 | 1900 | ||
1899 | QString Addressee::custom( const QString &app, const QString &name ) const | 1901 | QString Addressee::custom( const QString &app, const QString &name ) const |
1900 | { | 1902 | { |
1901 | QString qualifiedName = app + "-" + name + ":"; | 1903 | QString qualifiedName = app + "-" + name + ":"; |
1902 | QString value; | 1904 | QString value; |
1903 | 1905 | ||
1904 | QStringList::ConstIterator it; | 1906 | QStringList::ConstIterator it; |
1905 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1907 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1906 | if ( (*it).startsWith( qualifiedName ) ) { | 1908 | if ( (*it).startsWith( qualifiedName ) ) { |
1907 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1909 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1908 | break; | 1910 | break; |
1909 | } | 1911 | } |
1910 | } | 1912 | } |
1911 | 1913 | ||
1912 | return value; | 1914 | return value; |
1913 | } | 1915 | } |
1914 | 1916 | ||
1915 | void Addressee::setCustoms( const QStringList &l ) | 1917 | void Addressee::setCustoms( const QStringList &l ) |
1916 | { | 1918 | { |
1917 | detach(); | 1919 | detach(); |
1918 | mData->empty = false; | 1920 | mData->empty = false; |
1919 | 1921 | ||
1920 | mData->custom = l; | 1922 | mData->custom = l; |
1921 | } | 1923 | } |
1922 | 1924 | ||
1923 | QStringList Addressee::customs() const | 1925 | QStringList Addressee::customs() const |
1924 | { | 1926 | { |
1925 | return mData->custom; | 1927 | return mData->custom; |
1926 | } | 1928 | } |
1927 | 1929 | ||
1928 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1930 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1929 | QString &email) | 1931 | QString &email) |
1930 | { | 1932 | { |
1931 | int startPos, endPos, len; | 1933 | int startPos, endPos, len; |
1932 | QString partA, partB, result; | 1934 | QString partA, partB, result; |
1933 | char endCh = '>'; | 1935 | char endCh = '>'; |
1934 | 1936 | ||
1935 | startPos = rawEmail.find('<'); | 1937 | startPos = rawEmail.find('<'); |
1936 | if (startPos < 0) | 1938 | if (startPos < 0) |
1937 | { | 1939 | { |
1938 | startPos = rawEmail.find('('); | 1940 | startPos = rawEmail.find('('); |
1939 | endCh = ')'; | 1941 | endCh = ')'; |
1940 | } | 1942 | } |
1941 | if (startPos < 0) | 1943 | if (startPos < 0) |
1942 | { | 1944 | { |
1943 | // We couldn't find any separators, so we assume the whole string | 1945 | // We couldn't find any separators, so we assume the whole string |
1944 | // is the email address | 1946 | // is the email address |
1945 | email = rawEmail; | 1947 | email = rawEmail; |
1946 | fullName = ""; | 1948 | fullName = ""; |
1947 | } | 1949 | } |
1948 | else | 1950 | else |
1949 | { | 1951 | { |
1950 | // We have a start position, try to find an end | 1952 | // We have a start position, try to find an end |
1951 | endPos = rawEmail.find(endCh, startPos+1); | 1953 | endPos = rawEmail.find(endCh, startPos+1); |
1952 | 1954 | ||
1953 | if (endPos < 0) | 1955 | if (endPos < 0) |
1954 | { | 1956 | { |
1955 | // We couldn't find the end of the email address. We can only | 1957 | // We couldn't find the end of the email address. We can only |
1956 | // assume the entire string is the email address. | 1958 | // assume the entire string is the email address. |
1957 | email = rawEmail; | 1959 | email = rawEmail; |
1958 | fullName = ""; | 1960 | fullName = ""; |
1959 | } | 1961 | } |
1960 | else | 1962 | else |
1961 | { | 1963 | { |
1962 | // We have a start and end to the email address | 1964 | // We have a start and end to the email address |
1963 | 1965 | ||
1964 | // Grab the name part | 1966 | // Grab the name part |
1965 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1967 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1966 | 1968 | ||
1967 | // grab the email part | 1969 | // grab the email part |
1968 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1970 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1969 | 1971 | ||
1970 | // Check that we do not have any extra characters on the end of the | 1972 | // Check that we do not have any extra characters on the end of the |
1971 | // strings | 1973 | // strings |
1972 | len = fullName.length(); | 1974 | len = fullName.length(); |
1973 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1975 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1974 | fullName = fullName.mid(1, len-2); | 1976 | fullName = fullName.mid(1, len-2); |
1975 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1977 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1976 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1977 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1979 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1978 | fullName = fullName.mid(1, len-2); | 1980 | fullName = fullName.mid(1, len-2); |
1979 | } | 1981 | } |
1980 | } | 1982 | } |
1981 | } | 1983 | } |
1982 | 1984 | ||
1983 | void Addressee::setResource( Resource *resource ) | 1985 | void Addressee::setResource( Resource *resource ) |
1984 | { | 1986 | { |
1985 | detach(); | 1987 | detach(); |
1986 | mData->resource = resource; | 1988 | mData->resource = resource; |
1987 | } | 1989 | } |
1988 | 1990 | ||
1989 | Resource *Addressee::resource() const | 1991 | Resource *Addressee::resource() const |
1990 | { | 1992 | { |
1991 | return mData->resource; | 1993 | return mData->resource; |
1992 | } | 1994 | } |
1993 | 1995 | ||
1994 | //US | 1996 | //US |
1995 | QString Addressee::resourceLabel() | 1997 | QString Addressee::resourceLabel() |
1996 | { | 1998 | { |
1997 | return i18n("Resource"); | 1999 | return i18n("Resource"); |
1998 | } | 2000 | } |
1999 | QString Addressee::categoryLabel() | 2001 | QString Addressee::categoryLabel() |
2000 | { | 2002 | { |
2001 | return i18n("Category"); | 2003 | return i18n("Category"); |
2002 | } | 2004 | } |
2003 | 2005 | ||
2004 | void Addressee::setChanged( bool value ) | 2006 | void Addressee::setChanged( bool value ) |
2005 | { | 2007 | { |
2006 | detach(); | 2008 | detach(); |
2007 | mData->changed = value; | 2009 | mData->changed = value; |
2008 | } | 2010 | } |
2009 | 2011 | ||
2010 | bool Addressee::changed() const | 2012 | bool Addressee::changed() const |
2011 | { | 2013 | { |
2012 | return mData->changed; | 2014 | return mData->changed; |
2013 | } | 2015 | } |
2014 | 2016 | ||
2015 | void Addressee::setTagged( bool value ) | 2017 | void Addressee::setTagged( bool value ) |
2016 | { | 2018 | { |
2017 | detach(); | 2019 | detach(); |
2018 | mData->tagged = value; | 2020 | mData->tagged = value; |
2019 | } | 2021 | } |
2020 | 2022 | ||
2021 | bool Addressee::tagged() const | 2023 | bool Addressee::tagged() const |
2022 | { | 2024 | { |
2023 | return mData->tagged; | 2025 | return mData->tagged; |
2024 | } | 2026 | } |
2025 | 2027 | ||
2026 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2028 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2027 | { | 2029 | { |
2028 | if (!a.mData) return s; | 2030 | if (!a.mData) return s; |
2029 | 2031 | ||
2030 | s << a.uid(); | 2032 | s << a.uid(); |
2031 | 2033 | ||
2032 | s << a.mData->name; | 2034 | s << a.mData->name; |
2033 | s << a.mData->formattedName; | 2035 | s << a.mData->formattedName; |
2034 | s << a.mData->familyName; | 2036 | s << a.mData->familyName; |
2035 | s << a.mData->givenName; | 2037 | s << a.mData->givenName; |
2036 | s << a.mData->additionalName; | 2038 | s << a.mData->additionalName; |
2037 | s << a.mData->prefix; | 2039 | s << a.mData->prefix; |
2038 | s << a.mData->suffix; | 2040 | s << a.mData->suffix; |
2039 | s << a.mData->nickName; | 2041 | s << a.mData->nickName; |
2040 | s << a.mData->birthday; | 2042 | s << a.mData->birthday; |
2041 | s << a.mData->mailer; | 2043 | s << a.mData->mailer; |
2042 | s << a.mData->timeZone; | 2044 | s << a.mData->timeZone; |
2043 | s << a.mData->geo; | 2045 | s << a.mData->geo; |
2044 | s << a.mData->title; | 2046 | s << a.mData->title; |
2045 | s << a.mData->role; | 2047 | s << a.mData->role; |
2046 | s << a.mData->organization; | 2048 | s << a.mData->organization; |
2047 | s << a.mData->note; | 2049 | s << a.mData->note; |
2048 | s << a.mData->productId; | 2050 | s << a.mData->productId; |
2049 | s << a.mData->revision; | 2051 | s << a.mData->revision; |
2050 | s << a.mData->sortString; | 2052 | s << a.mData->sortString; |
2051 | s << a.mData->url; | 2053 | s << a.mData->url; |
2052 | s << a.mData->secrecy; | 2054 | s << a.mData->secrecy; |
2053 | s << a.mData->logo; | 2055 | s << a.mData->logo; |
2054 | s << a.mData->photo; | 2056 | s << a.mData->photo; |
2055 | s << a.mData->sound; | 2057 | s << a.mData->sound; |
2056 | s << a.mData->agent; | 2058 | s << a.mData->agent; |
2057 | s << a.mData->phoneNumbers; | 2059 | s << a.mData->phoneNumbers; |
2058 | s << a.mData->addresses; | 2060 | s << a.mData->addresses; |
2059 | s << a.mData->emails; | 2061 | s << a.mData->emails; |
2060 | s << a.mData->categories; | 2062 | s << a.mData->categories; |
2061 | s << a.mData->custom; | 2063 | s << a.mData->custom; |
2062 | s << a.mData->keys; | 2064 | s << a.mData->keys; |
2063 | return s; | 2065 | return s; |
2064 | } | 2066 | } |
2065 | 2067 | ||
2066 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2068 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2067 | { | 2069 | { |
2068 | if (!a.mData) return s; | 2070 | if (!a.mData) return s; |
2069 | 2071 | ||
2070 | s >> a.mData->uid; | 2072 | s >> a.mData->uid; |
2071 | 2073 | ||
2072 | s >> a.mData->name; | 2074 | s >> a.mData->name; |
2073 | s >> a.mData->formattedName; | 2075 | s >> a.mData->formattedName; |
2074 | s >> a.mData->familyName; | 2076 | s >> a.mData->familyName; |
2075 | s >> a.mData->givenName; | 2077 | s >> a.mData->givenName; |
2076 | s >> a.mData->additionalName; | 2078 | s >> a.mData->additionalName; |
2077 | s >> a.mData->prefix; | 2079 | s >> a.mData->prefix; |
2078 | s >> a.mData->suffix; | 2080 | s >> a.mData->suffix; |
2079 | s >> a.mData->nickName; | 2081 | s >> a.mData->nickName; |
2080 | s >> a.mData->birthday; | 2082 | s >> a.mData->birthday; |
2081 | s >> a.mData->mailer; | 2083 | s >> a.mData->mailer; |
2082 | s >> a.mData->timeZone; | 2084 | s >> a.mData->timeZone; |
2083 | s >> a.mData->geo; | 2085 | s >> a.mData->geo; |
2084 | s >> a.mData->title; | 2086 | s >> a.mData->title; |
2085 | s >> a.mData->role; | 2087 | s >> a.mData->role; |
2086 | s >> a.mData->organization; | 2088 | s >> a.mData->organization; |
2087 | s >> a.mData->note; | 2089 | s >> a.mData->note; |
2088 | s >> a.mData->productId; | 2090 | s >> a.mData->productId; |
2089 | s >> a.mData->revision; | 2091 | s >> a.mData->revision; |
2090 | s >> a.mData->sortString; | 2092 | s >> a.mData->sortString; |
2091 | s >> a.mData->url; | 2093 | s >> a.mData->url; |
2092 | s >> a.mData->secrecy; | 2094 | s >> a.mData->secrecy; |
2093 | s >> a.mData->logo; | 2095 | s >> a.mData->logo; |
2094 | s >> a.mData->photo; | 2096 | s >> a.mData->photo; |
2095 | s >> a.mData->sound; | 2097 | s >> a.mData->sound; |
2096 | s >> a.mData->agent; | 2098 | s >> a.mData->agent; |
2097 | s >> a.mData->phoneNumbers; | 2099 | s >> a.mData->phoneNumbers; |
2098 | s >> a.mData->addresses; | 2100 | s >> a.mData->addresses; |
2099 | s >> a.mData->emails; | 2101 | s >> a.mData->emails; |
2100 | s >> a.mData->categories; | 2102 | s >> a.mData->categories; |
2101 | s >> a.mData->custom; | 2103 | s >> a.mData->custom; |
2102 | s >> a.mData->keys; | 2104 | s >> a.mData->keys; |
2103 | 2105 | ||
2104 | a.mData->empty = false; | 2106 | a.mData->empty = false; |
2105 | 2107 | ||
2106 | return s; | 2108 | return s; |
2107 | } | 2109 | } |
2108 | bool matchBinaryPattern( int value, int pattern ) | 2110 | bool matchBinaryPattern( int value, int pattern ) |
2109 | { | 2111 | { |
2110 | /** | 2112 | /** |
2111 | We want to match all telephonnumbers/addresses which have the bits in the | 2113 | We want to match all telephonnumbers/addresses which have the bits in the |
2112 | pattern set. More are allowed. | 2114 | pattern set. More are allowed. |
2113 | if pattern == 0 we have a special handling, then we want only those with | 2115 | if pattern == 0 we have a special handling, then we want only those with |
2114 | exactly no bit set. | 2116 | exactly no bit set. |
2115 | */ | 2117 | */ |
2116 | if ( pattern == 0 ) | 2118 | if ( pattern == 0 ) |
2117 | return ( value == 0 ); | 2119 | return ( value == 0 ); |
2118 | else | 2120 | else |
2119 | return ( pattern == ( pattern & value ) ); | 2121 | return ( pattern == ( pattern & value ) ); |
2120 | } | 2122 | } |
2121 | 2123 | ||
2122 | bool matchBinaryPatternP( int value, int pattern ) | 2124 | bool matchBinaryPatternP( int value, int pattern ) |
2123 | { | 2125 | { |
2124 | 2126 | ||
2125 | if ( pattern == 0 ) | 2127 | if ( pattern == 0 ) |
2126 | return ( value == 0 ); | 2128 | return ( value == 0 ); |
2127 | else | 2129 | else |
2128 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2130 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2129 | } | 2131 | } |
2130 | bool matchBinaryPatternA( int value, int pattern ) | 2132 | bool matchBinaryPatternA( int value, int pattern ) |
2131 | { | 2133 | { |
2132 | 2134 | ||
2133 | if ( pattern == 0 ) | 2135 | if ( pattern == 0 ) |
2134 | return ( value == 0 ); | 2136 | return ( value == 0 ); |
2135 | else | 2137 | else |
2136 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 2138 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
2137 | } | 2139 | } |
diff --git a/kabc/picture.cpp b/kabc/picture.cpp index 6a34b98..57aa297 100644 --- a/kabc/picture.cpp +++ b/kabc/picture.cpp | |||
@@ -1,141 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "picture.h" | 28 | #include "picture.h" |
29 | 29 | ||
30 | using namespace KABC; | 30 | using namespace KABC; |
31 | 31 | ||
32 | Picture::Picture() | 32 | Picture::Picture() |
33 | : mIntern( false ) | 33 | : mIntern( false ) |
34 | { | 34 | { |
35 | mUndefined = true; | 35 | mUndefined = true; |
36 | } | 36 | } |
37 | 37 | ||
38 | Picture::Picture( const QString &url ) | 38 | Picture::Picture( const QString &url ) |
39 | : mUrl( url ), mIntern( false ) | 39 | : mUrl( url ), mIntern( false ) |
40 | { | 40 | { |
41 | mUndefined = false; | 41 | mUndefined = false; |
42 | } | 42 | } |
43 | 43 | ||
44 | Picture::Picture( const QImage &data ) | 44 | Picture::Picture( const QImage &data ) |
45 | : mData( data ), mIntern( true ) | 45 | : mData( data ), mIntern( true ) |
46 | { | 46 | { |
47 | mUndefined = false; | 47 | mUndefined = false; |
48 | } | 48 | } |
49 | 49 | ||
50 | Picture::~Picture() | 50 | Picture::~Picture() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | bool Picture::operator==( const Picture &p ) const | 54 | bool Picture::operator==( const Picture &p ) const |
55 | { | 55 | { |
56 | if ( mIntern != p.mIntern ) return false; | 56 | //qDebug("compare PIC "); |
57 | 57 | if ( mUndefined && p.mUndefined ) { | |
58 | //qDebug("compare PIC true 1 "); | ||
59 | return true; | ||
60 | } | ||
61 | if ( mUndefined || p.mUndefined ) { | ||
62 | //qDebug("compare PIC false 1"); | ||
63 | return false; | ||
64 | } | ||
65 | // now we should deal with two defined pics! | ||
66 | if ( mIntern != p.mIntern ) { | ||
67 | //qDebug("compare PIC false 2"); | ||
68 | return false; | ||
69 | } | ||
58 | if ( mIntern ) { | 70 | if ( mIntern ) { |
59 | if ( mData != p.mData ) | 71 | //qDebug("mIntern "); |
72 | if ( mData.isNull() && p.mData.isNull() ) { | ||
73 | //qDebug("compare PIC true 2 "); | ||
74 | return true; | ||
75 | } | ||
76 | if ( mData.isNull() || p.mData.isNull() ){ | ||
77 | //qDebug("compare PIC false 3-1"); | ||
78 | |||
79 | return false; | ||
80 | } | ||
81 | if ( mData != p.mData ) { | ||
82 | //qDebug("compare PIC false 3"); | ||
60 | return false; | 83 | return false; |
84 | } | ||
61 | } else { | 85 | } else { |
62 | if ( mUrl != p.mUrl ) | 86 | if ( mUrl != p.mUrl ) { |
63 | return false; | 87 | //qDebug("compare PIC false 4"); |
88 | return false; | ||
89 | } | ||
64 | } | 90 | } |
65 | 91 | //qDebug("compare PIC true "); | |
66 | return true; | 92 | return true; |
67 | } | 93 | } |
68 | 94 | ||
69 | bool Picture::operator!=( const Picture &p ) const | 95 | bool Picture::operator!=( const Picture &p ) const |
70 | { | 96 | { |
71 | return !( p == *this ); | 97 | return !( p == *this ); |
72 | } | 98 | } |
73 | 99 | ||
74 | void Picture::setUrl( const QString &url ) | 100 | void Picture::setUrl( const QString &url ) |
75 | { | 101 | { |
76 | mUrl = url; | 102 | mUrl = url; |
77 | mIntern = false; | 103 | mIntern = false; |
78 | mUndefined = false; | 104 | mUndefined = false; |
79 | } | 105 | } |
80 | 106 | ||
81 | void Picture::setData( const QImage &data ) | 107 | void Picture::setData( const QImage &data ) |
82 | { | 108 | { |
83 | mData = data; | 109 | mData = data; |
84 | mIntern = true; | 110 | mIntern = true; |
85 | mUndefined = false; | 111 | mUndefined = false; |
86 | } | 112 | } |
87 | 113 | ||
88 | void Picture::setType( const QString &type ) | 114 | void Picture::setType( const QString &type ) |
89 | { | 115 | { |
90 | mType = type; | 116 | mType = type; |
91 | } | 117 | } |
92 | 118 | ||
93 | bool Picture::isIntern() const | 119 | bool Picture::isIntern() const |
94 | { | 120 | { |
95 | return mIntern; | 121 | return mIntern; |
96 | } | 122 | } |
97 | 123 | ||
98 | QString Picture::url() const | 124 | QString Picture::url() const |
99 | { | 125 | { |
100 | return mUrl; | 126 | return mUrl; |
101 | } | 127 | } |
102 | 128 | ||
103 | QImage Picture::data() const | 129 | QImage Picture::data() const |
104 | { | 130 | { |
105 | return mData; | 131 | return mData; |
106 | } | 132 | } |
107 | QPixmap Picture::pixmap() const | 133 | QPixmap Picture::pixmap() const |
108 | { | 134 | { |
109 | QPixmap p; | 135 | QPixmap p; |
110 | p.convertFromImage ( mData ); | 136 | p.convertFromImage ( mData ); |
111 | return p; | 137 | return p; |
112 | } | 138 | } |
113 | 139 | ||
114 | QString Picture::type() const | 140 | QString Picture::type() const |
115 | { | 141 | { |
116 | return mType; | 142 | return mType; |
117 | } | 143 | } |
118 | bool Picture::undefined() const | 144 | bool Picture::undefined() const |
119 | { | 145 | { |
120 | return mUndefined; | 146 | return mUndefined; |
121 | } | 147 | } |
122 | 148 | ||
123 | 149 | ||
124 | QString Picture::asString() const | 150 | QString Picture::asString() const |
125 | { | 151 | { |
126 | if ( mIntern ) | 152 | if ( mIntern ) |
127 | return "intern picture"; | 153 | return "intern picture"; |
128 | else | 154 | else |
129 | return mUrl; | 155 | return mUrl; |
130 | } | 156 | } |
131 | 157 | ||
132 | QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) | 158 | QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) |
133 | { | 159 | { |
134 | return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; | 160 | return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; |
135 | } | 161 | } |
136 | 162 | ||
137 | QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) | 163 | QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) |
138 | { | 164 | { |
139 | s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; | 165 | s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; |
140 | return s; | 166 | return s; |
141 | } | 167 | } |
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index c368172..2f88cde 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -1,321 +1,349 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1999 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1999 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <VCardAdrParam.h> | 30 | #include <VCardAdrParam.h> |
31 | #include <VCardAgentParam.h> | 31 | #include <VCardAgentParam.h> |
32 | #include <VCardDateParam.h> | 32 | #include <VCardDateParam.h> |
33 | #include <VCardEmailParam.h> | 33 | #include <VCardEmailParam.h> |
34 | #include <VCardImageParam.h> | 34 | #include <VCardImageParam.h> |
35 | #include <VCardSourceParam.h> | 35 | #include <VCardSourceParam.h> |
36 | #include <VCardTelParam.h> | 36 | #include <VCardTelParam.h> |
37 | #include <VCardTextBinParam.h> | 37 | #include <VCardTextBinParam.h> |
38 | #include <VCardTextParam.h> | 38 | #include <VCardTextParam.h> |
39 | 39 | ||
40 | #include <VCardAdrValue.h> | 40 | #include <VCardAdrValue.h> |
41 | #include <VCardAgentValue.h> | 41 | #include <VCardAgentValue.h> |
42 | #include <VCardDateValue.h> | 42 | #include <VCardDateValue.h> |
43 | #include <VCardImageValue.h> | 43 | #include <VCardImageValue.h> |
44 | #include <VCardTextValue.h> | 44 | #include <VCardTextValue.h> |
45 | #include <VCardTextBinValue.h> | 45 | #include <VCardTextBinValue.h> |
46 | #include <VCardLangValue.h> | 46 | #include <VCardLangValue.h> |
47 | #include <VCardNValue.h> | 47 | #include <VCardNValue.h> |
48 | #include <VCardURIValue.h> | 48 | #include <VCardURIValue.h> |
49 | #include <VCardSoundValue.h> | 49 | #include <VCardSoundValue.h> |
50 | #include <VCardClassValue.h> | 50 | #include <VCardClassValue.h> |
51 | #include <VCardFloatValue.h> | 51 | #include <VCardFloatValue.h> |
52 | #include <VCardOrgValue.h> | 52 | #include <VCardOrgValue.h> |
53 | #include <VCardTelValue.h> | 53 | #include <VCardTelValue.h> |
54 | #include <VCardTextListValue.h> | 54 | #include <VCardTextListValue.h> |
55 | #include <VCardUTCValue.h> | 55 | #include <VCardUTCValue.h> |
56 | #include <VCardGeoValue.h> | 56 | #include <VCardGeoValue.h> |
57 | 57 | ||
58 | #include <VCardRToken.h> | 58 | #include <VCardRToken.h> |
59 | #include <VCardContentLine.h> | 59 | #include <VCardContentLine.h> |
60 | 60 | ||
61 | #include <VCardEntity.h> | 61 | #include <VCardEntity.h> |
62 | #include <VCardEnum.h> | 62 | #include <VCardEnum.h> |
63 | #include <VCardDefines.h> | 63 | #include <VCardDefines.h> |
64 | 64 | ||
65 | using namespace VCARD; | 65 | using namespace VCARD; |
66 | 66 | ||
67 | ContentLine::ContentLine() | 67 | ContentLine::ContentLine() |
68 | :Entity(), | 68 | :Entity(), |
69 | value_(0), | 69 | value_(0), |
70 | paramType_( ParamUnknown ), | 70 | paramType_( ParamUnknown ), |
71 | valueType_( ValueUnknown ), | 71 | valueType_( ValueUnknown ), |
72 | entityType_( EntityUnknown ) | 72 | entityType_( EntityUnknown ) |
73 | { | 73 | { |
74 | paramList_.setAutoDelete( TRUE ); | 74 | paramList_.setAutoDelete( TRUE ); |
75 | } | 75 | } |
76 | 76 | ||
77 | ContentLine::ContentLine(const ContentLine & x) | 77 | ContentLine::ContentLine(const ContentLine & x) |
78 | :Entity(x), | 78 | :Entity(x), |
79 | group_ (x.group_), | 79 | group_ (x.group_), |
80 | name_ (x.name_), | 80 | name_ (x.name_), |
81 | /*US paramList_(x.paramList_),*/ | 81 | /*US paramList_(x.paramList_),*/ |
82 | value_(x.value_->clone()), | 82 | value_(x.value_->clone()), |
83 | paramType_(x.paramType_), | 83 | paramType_(x.paramType_), |
84 | valueType_(x.valueType_), | 84 | valueType_(x.valueType_), |
85 | entityType_(x.entityType_) | 85 | entityType_(x.entityType_) |
86 | { | 86 | { |
87 | paramList_.setAutoDelete( TRUE ); | 87 | paramList_.setAutoDelete( TRUE ); |
88 | 88 | ||
89 | 89 | ||
90 | ParamListIterator it(x.paramList_); | 90 | ParamListIterator it(x.paramList_); |
91 | for (; it.current(); ++it) | 91 | for (; it.current(); ++it) |
92 | { | 92 | { |
93 | Param *p = new Param; | 93 | Param *p = new Param; |
94 | p->setName( it.current()->name() ); | 94 | p->setName( it.current()->name() ); |
95 | p->setValue( it.current()->value() ); | 95 | p->setValue( it.current()->value() ); |
96 | paramList_.append(p); | 96 | paramList_.append(p); |
97 | } | 97 | } |
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | ContentLine::ContentLine(const QCString & s) | 101 | ContentLine::ContentLine(const QCString & s) |
102 | :Entity(s), | 102 | :Entity(s), |
103 | value_(0), | 103 | value_(0), |
104 | paramType_( ParamUnknown ), | 104 | paramType_( ParamUnknown ), |
105 | valueType_( ValueUnknown ), | 105 | valueType_( ValueUnknown ), |
106 | entityType_( EntityUnknown ) | 106 | entityType_( EntityUnknown ) |
107 | { | 107 | { |
108 | paramList_.setAutoDelete( TRUE ); | 108 | paramList_.setAutoDelete( TRUE ); |
109 | } | 109 | } |
110 | 110 | ||
111 | ContentLine & | 111 | ContentLine & |
112 | ContentLine::operator = (ContentLine & x) | 112 | ContentLine::operator = (ContentLine & x) |
113 | { | 113 | { |
114 | if (*this == x) return *this; | 114 | if (*this == x) return *this; |
115 | 115 | ||
116 | ParamListIterator it(x.paramList_); | 116 | ParamListIterator it(x.paramList_); |
117 | for (; it.current(); ++it) | 117 | for (; it.current(); ++it) |
118 | { | 118 | { |
119 | Param *p = new Param; | 119 | Param *p = new Param; |
120 | p->setName( it.current()->name() ); | 120 | p->setName( it.current()->name() ); |
121 | p->setValue( it.current()->value() ); | 121 | p->setValue( it.current()->value() ); |
122 | paramList_.append(p); | 122 | paramList_.append(p); |
123 | } | 123 | } |
124 | 124 | ||
125 | value_ = x.value_->clone(); | 125 | value_ = x.value_->clone(); |
126 | 126 | ||
127 | Entity::operator = (x); | 127 | Entity::operator = (x); |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | ContentLine & | 131 | ContentLine & |
132 | ContentLine::operator = (const QCString & s) | 132 | ContentLine::operator = (const QCString & s) |
133 | { | 133 | { |
134 | Entity::operator = (s); | 134 | Entity::operator = (s); |
135 | delete value_; | 135 | delete value_; |
136 | value_ = 0; | 136 | value_ = 0; |
137 | return *this; | 137 | return *this; |
138 | } | 138 | } |
139 | 139 | ||
140 | bool | 140 | bool |
141 | ContentLine::operator == (ContentLine & x) | 141 | ContentLine::operator == (ContentLine & x) |
142 | { | 142 | { |
143 | x.parse(); | 143 | x.parse(); |
144 | 144 | ||
145 | QPtrListIterator<Param> it(x.paramList()); | 145 | QPtrListIterator<Param> it(x.paramList()); |
146 | 146 | ||
147 | if (!paramList_.find(it.current())) | 147 | if (!paramList_.find(it.current())) |
148 | return false; | 148 | return false; |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | ContentLine::~ContentLine() | 153 | ContentLine::~ContentLine() |
154 | { | 154 | { |
155 | delete value_; | 155 | delete value_; |
156 | value_ = 0; | 156 | value_ = 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | void | 159 | void |
160 | ContentLine::_parse() | 160 | ContentLine::_parse() |
161 | { | 161 | { |
162 | vDebug("parse"); | 162 | vDebug("parse"); |
163 | 163 | ||
164 | // Unqote newlines | 164 | // Unqote newlines |
165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); | 165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); |
166 | 166 | ||
167 | int split = strRep_.find(':'); | 167 | int split = strRep_.find(':'); |
168 | 168 | ||
169 | if (split == -1) { // invalid content line | 169 | if (split == -1) { // invalid content line |
170 | vDebug("No ':'"); | 170 | vDebug("No ':'"); |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | 173 | ||
174 | QCString firstPart(strRep_.left(split)); | 174 | QCString firstPart(strRep_.left(split)); |
175 | QCString valuePart(strRep_.mid(split + 1)); | 175 | QCString valuePart(strRep_.mid(split + 1)); |
176 | 176 | ||
177 | split = firstPart.find('.'); | 177 | split = firstPart.find('.'); |
178 | 178 | ||
179 | if (split != -1) { | 179 | if (split != -1) { |
180 | group_ = firstPart.left(split); | 180 | group_ = firstPart.left(split); |
181 | firstPart= firstPart.mid(split + 1); | 181 | firstPart= firstPart.mid(split + 1); |
182 | } | 182 | } |
183 | 183 | ||
184 | vDebug("Group == " + group_); | 184 | vDebug("Group == " + group_); |
185 | vDebug("firstPart == " + firstPart); | 185 | vDebug("firstPart == " + firstPart); |
186 | vDebug("valuePart == " + valuePart); | 186 | vDebug("valuePart == " + valuePart); |
187 | 187 | ||
188 | // Now we have the group, the name and param list together and the value. | 188 | // Now we have the group, the name and param list together and the value. |
189 | 189 | ||
190 | QStrList l; | 190 | QStrList l; |
191 | 191 | ||
192 | RTokenise(firstPart, ";", l); | 192 | RTokenise(firstPart, ";", l); |
193 | 193 | ||
194 | if (l.count() == 0) {// invalid - no name ! | 194 | if (l.count() == 0) {// invalid - no name ! |
195 | vDebug("No name for this content line !"); | 195 | vDebug("No name for this content line !"); |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | name_ = l.at(0); | 199 | name_ = l.at(0); |
200 | 200 | ||
201 | // Now we have the name, so the rest of 'l' is the params. | 201 | // Now we have the name, so the rest of 'l' is the params. |
202 | // Remove the name part. | 202 | // Remove the name part. |
203 | l.remove(0u); | 203 | l.remove(0u); |
204 | 204 | ||
205 | entityType_= EntityNameToEntityType(name_); | 205 | entityType_= EntityNameToEntityType(name_); |
206 | paramType_= EntityTypeToParamType(entityType_); | 206 | paramType_= EntityTypeToParamType(entityType_); |
207 | 207 | ||
208 | unsigned int i = 0; | 208 | unsigned int i = 0; |
209 | 209 | ||
210 | // For each parameter, create a new parameter of the correct type. | 210 | // For each parameter, create a new parameter of the correct type. |
211 | 211 | ||
212 | QStrListIterator it(l); | 212 | QStrListIterator it(l); |
213 | 213 | ||
214 | for (; it.current(); ++it, i++) { | 214 | for (; it.current(); ++it, i++) { |
215 | 215 | ||
216 | QCString str = *it; | 216 | QCString str = *it; |
217 | 217 | ||
218 | split = str.find("="); | 218 | split = str.find("="); |
219 | if (split < 0 ) { | 219 | if (split < 0 ) { |
220 | vDebug("No '=' in paramter."); | 220 | vDebug("No '=' in paramter."); |
221 | continue; | 221 | continue; |
222 | } | 222 | } |
223 | 223 | ||
224 | QCString paraName = str.left(split); | 224 | QCString paraName = str.left(split); |
225 | QCString paraValue = str.mid(split + 1); | 225 | QCString paraValue = str.mid(split + 1); |
226 | 226 | ||
227 | QStrList paraValues; | 227 | QStrList paraValues; |
228 | RTokenise(paraValue, ",", paraValues); | 228 | RTokenise(paraValue, ",", paraValues); |
229 | 229 | ||
230 | QStrListIterator it2( paraValues ); | 230 | QStrListIterator it2( paraValues ); |
231 | 231 | ||
232 | for(; it2.current(); ++it2) { | 232 | for(; it2.current(); ++it2) { |
233 | 233 | ||
234 | Param *p = new Param; | 234 | Param *p = new Param; |
235 | p->setName( paraName ); | 235 | p->setName( paraName ); |
236 | p->setValue( *it2 ); | 236 | p->setValue( *it2 ); |
237 | 237 | ||
238 | paramList_.append(p); | 238 | paramList_.append(p); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | // Create a new value of the correct type. | 242 | // Create a new value of the correct type. |
243 | 243 | ||
244 | valueType_ = EntityTypeToValueType(entityType_); | 244 | valueType_ = EntityTypeToValueType(entityType_); |
245 | 245 | ||
246 | //kdDebug(5710) << "valueType: " << valueType_ << endl; | 246 | //kdDebug(5710) << "valueType: " << valueType_ << endl; |
247 | 247 | ||
248 | switch (valueType_) { | 248 | switch (valueType_) { |
249 | 249 | ||
250 | case ValueSound: value_ = new SoundValue;break; | 250 | case ValueSound: value_ = new SoundValue;break; |
251 | case ValueAgent: value_ = new AgentValue;break; | 251 | case ValueAgent: value_ = new AgentValue;break; |
252 | case ValueAddress: value_ = new AdrValue; break; | 252 | case ValueAddress: value_ = new AdrValue; break; |
253 | case ValueTel: value_ = new TelValue; break; | 253 | case ValueTel: value_ = new TelValue; break; |
254 | case ValueTextBin: value_ = new TextBinValue;break; | 254 | case ValueTextBin: value_ = new TextBinValue;break; |
255 | case ValueOrg: value_ = new OrgValue; break; | 255 | case ValueOrg: value_ = new OrgValue; break; |
256 | case ValueN: value_ = new NValue; break; | 256 | case ValueN: value_ = new NValue; break; |
257 | case ValueUTC: value_ = new UTCValue; break; | 257 | case ValueUTC: value_ = new UTCValue; break; |
258 | case ValueURI: value_ = new URIValue; break; | 258 | case ValueURI: value_ = new URIValue; break; |
259 | case ValueClass: value_ = new ClassValue;break; | 259 | case ValueClass: value_ = new ClassValue;break; |
260 | case ValueFloat: value_ = new FloatValue;break; | 260 | case ValueFloat: value_ = new FloatValue;break; |
261 | case ValueImage: value_ = new ImageValue;break; | 261 | case ValueImage: value_ = new ImageValue;break; |
262 | case ValueDate: value_ = new DateValue; break; | 262 | case ValueDate: value_ = new DateValue; break; |
263 | case ValueTextList: value_ = new TextListValue;break; | 263 | case ValueTextList: value_ = new TextListValue;break; |
264 | case ValueGeo: value_ = new GeoValue; break; | 264 | case ValueGeo: value_ = new GeoValue; break; |
265 | case ValueText: | 265 | case ValueText: |
266 | case ValueUnknown: | 266 | case ValueUnknown: |
267 | default: value_ = new TextValue; break; | 267 | default: value_ = new TextValue; break; |
268 | } | 268 | } |
269 | 269 | ||
270 | *value_ = valuePart; | 270 | *value_ = valuePart; |
271 | } | 271 | } |
272 | 272 | ||
273 | void | 273 | void |
274 | ContentLine::_assemble() | 274 | ContentLine::_assemble() |
275 | { | 275 | { |
276 | //strRep_.truncate(0); | ||
277 | QString line; | ||
278 | if (!group_.isEmpty()) | ||
279 | line = group_ + '.'; | ||
280 | line += name_; | ||
281 | ParamListIterator it(paramList_); | ||
282 | for (; it.current(); ++it) | ||
283 | line += ";" + it.current()->asString(); | ||
284 | |||
285 | if (value_ != 0) | ||
286 | line += ":" + value_->asString(); | ||
287 | |||
288 | line = line.replace( QRegExp( "\n" ), "\\n" ); | ||
289 | |||
290 | // Fold lines longer than 72 chars | ||
291 | const int maxLen = 72; | ||
292 | uint cursor = 0; | ||
293 | QString cut; | ||
294 | while( line.length() > ( cursor + 1 ) * maxLen ) { | ||
295 | cut += line.mid( cursor * maxLen, maxLen ); | ||
296 | cut += "\r\n "; | ||
297 | ++cursor; | ||
298 | } | ||
299 | cut += line.mid( cursor * maxLen ); | ||
300 | strRep_ = cut.latin1(); | ||
301 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | ||
302 | #if 0 | ||
276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 303 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
277 | strRep_.truncate(0); | 304 | strRep_.truncate(0); |
278 | 305 | ||
279 | QCString line; | 306 | QCString line; |
280 | 307 | ||
281 | if (!group_.isEmpty()) | 308 | if (!group_.isEmpty()) |
282 | line += group_ + '.'; | 309 | line += group_ + '.'; |
283 | 310 | ||
284 | line += name_; | 311 | line += name_; |
285 | 312 | ||
286 | vDebug("Adding parameters"); | 313 | vDebug("Adding parameters"); |
287 | ParamListIterator it(paramList_); | 314 | ParamListIterator it(paramList_); |
288 | 315 | ||
289 | for (; it.current(); ++it) | 316 | for (; it.current(); ++it) |
290 | line += ";" + it.current()->asString(); | 317 | line += ";" + it.current()->asString(); |
291 | 318 | ||
292 | vDebug("Adding value"); | 319 | vDebug("Adding value"); |
293 | if (value_ != 0) | 320 | if (value_ != 0) |
294 | line += ":" + value_->asString(); | 321 | line += ":" + value_->asString(); |
295 | else | 322 | else |
296 | vDebug("No value"); | 323 | vDebug("No value"); |
297 | 324 | ||
298 | // Quote newlines | 325 | // Quote newlines |
299 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 326 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
300 | 327 | ||
301 | // Fold lines longer than 72 chars | 328 | // Fold lines longer than 72 chars |
302 | const int maxLen = 72; | 329 | const int maxLen = 72; |
303 | uint cursor = 0; | 330 | uint cursor = 0; |
304 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 331 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
305 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 332 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
306 | strRep_ += "\r\n "; | 333 | strRep_ += "\r\n "; |
307 | ++cursor; | 334 | ++cursor; |
308 | } | 335 | } |
309 | strRep_ += line.mid( cursor * maxLen ); | 336 | strRep_ += line.mid( cursor * maxLen ); |
310 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 337 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
338 | #endif | ||
311 | } | 339 | } |
312 | 340 | ||
313 | void | 341 | void |
314 | ContentLine::clear() | 342 | ContentLine::clear() |
315 | { | 343 | { |
316 | group_.truncate(0); | 344 | group_.truncate(0); |
317 | name_.truncate(0); | 345 | name_.truncate(0); |
318 | paramList_.clear(); | 346 | paramList_.clear(); |
319 | delete value_; | 347 | delete value_; |
320 | value_ = 0; | 348 | value_ = 0; |
321 | } | 349 | } |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index bc80707..49bfe43 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -1,299 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qstringlist.h> | ||
27 | #include <qstring.h> | ||
28 | #include <qvaluelist.h> | ||
26 | 29 | ||
27 | #include <VCardEntity.h> | 30 | #include <VCardEntity.h> |
28 | #include <VCardVCard.h> | 31 | #include <VCardVCard.h> |
29 | #include <VCardContentLine.h> | 32 | #include <VCardContentLine.h> |
30 | #include <VCardRToken.h> | 33 | #include <VCardRToken.h> |
31 | 34 | ||
32 | #include <VCardDefines.h> | 35 | #include <VCardDefines.h> |
33 | 36 | ||
34 | using namespace VCARD; | 37 | using namespace VCARD; |
35 | 38 | ||
36 | VCard::VCard() | 39 | VCard::VCard() |
37 | :Entity() | 40 | :Entity() |
38 | { | 41 | { |
39 | contentLineList_.setAutoDelete( TRUE ); | 42 | contentLineList_.setAutoDelete( TRUE ); |
40 | } | 43 | } |
41 | 44 | ||
42 | VCard::VCard(const VCard & x) | 45 | VCard::VCard(const VCard & x) |
43 | :Entity(x), | 46 | :Entity(x), |
44 | group_(x.group_) | 47 | group_(x.group_) |
45 | { | 48 | { |
46 | contentLineList_.setAutoDelete( TRUE ); | 49 | contentLineList_.setAutoDelete( TRUE ); |
47 | 50 | ||
48 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 51 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
49 | for (; it.current(); ++it) { | 52 | for (; it.current(); ++it) { |
50 | ContentLine * c = new ContentLine(*it.current()); | 53 | ContentLine * c = new ContentLine(*it.current()); |
51 | contentLineList_.append(c); | 54 | contentLineList_.append(c); |
52 | } | 55 | } |
53 | 56 | ||
54 | } | 57 | } |
55 | 58 | ||
56 | VCard::VCard(const QCString & s) | 59 | VCard::VCard(const QCString & s) |
57 | :Entity(s) | 60 | :Entity(s) |
58 | { | 61 | { |
59 | contentLineList_.setAutoDelete( TRUE ); | 62 | contentLineList_.setAutoDelete( TRUE ); |
60 | } | 63 | } |
61 | 64 | ||
62 | VCard & | 65 | VCard & |
63 | VCard::operator = (VCard & x) | 66 | VCard::operator = (VCard & x) |
64 | { | 67 | { |
65 | if (*this == x) return *this; | 68 | if (*this == x) return *this; |
66 | 69 | ||
67 | group_ = x.group(); | 70 | group_ = x.group(); |
68 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 71 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
69 | for (; it.current(); ++it) { | 72 | for (; it.current(); ++it) { |
70 | ContentLine * c = new ContentLine(*it.current()); | 73 | ContentLine * c = new ContentLine(*it.current()); |
71 | contentLineList_.append(c); | 74 | contentLineList_.append(c); |
72 | } | 75 | } |
73 | 76 | ||
74 | Entity::operator = (x); | 77 | Entity::operator = (x); |
75 | return *this; | 78 | return *this; |
76 | } | 79 | } |
77 | 80 | ||
78 | VCard & | 81 | VCard & |
79 | VCard::operator = (const QCString & s) | 82 | VCard::operator = (const QCString & s) |
80 | { | 83 | { |
81 | Entity::operator = (s); | 84 | Entity::operator = (s); |
82 | return *this; | 85 | return *this; |
83 | } | 86 | } |
84 | 87 | ||
85 | bool | 88 | bool |
86 | VCard::operator == (VCard & x) | 89 | VCard::operator == (VCard & x) |
87 | { | 90 | { |
88 | x.parse(); | 91 | x.parse(); |
89 | return false; | 92 | return false; |
90 | } | 93 | } |
91 | 94 | ||
92 | VCard::~VCard() | 95 | VCard::~VCard() |
93 | { | 96 | { |
94 | } | 97 | } |
95 | 98 | ||
96 | void | 99 | void |
97 | VCard::_parse() | 100 | VCard::_parse() |
98 | { | 101 | { |
99 | vDebug("parse() called"); | 102 | |
100 | QStrList l; | 103 | QStringList l; |
104 | QStrList sl; | ||
101 | 105 | ||
102 | RTokenise(strRep_, "\r\n", l); | 106 | RTokenise(strRep_, "\r\n", sl); |
103 | 107 | ||
104 | if (l.count() < 3) { // Invalid VCARD ! | 108 | if (sl.count() < 3) { // Invalid VCARD ! |
105 | vDebug("Invalid vcard"); | 109 | //qDebug("invalid vcard "); |
106 | return; | 110 | return; |
107 | } | 111 | } |
108 | 112 | l = QStringList::fromStrList( sl ); | |
109 | // Get the first line | 113 | // Get the first line |
110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 114 | QString beginLine = l[0].stripWhiteSpace(); |
111 | |||
112 | vDebug("Begin line == \"" + beginLine + "\""); | ||
113 | 115 | ||
114 | // Remove extra blank lines | 116 | // Remove extra blank lines |
115 | while (QCString(l.last()).isEmpty()) | 117 | while (l.last().isEmpty()) |
116 | l.remove(l.last()); | 118 | l.remove(l.last()); |
117 | 119 | ||
118 | // Now we know this is the last line | 120 | // Now we know this is the last line |
119 | QCString endLine = l.last(); | 121 | QString endLine = l.last(); |
120 | 122 | ||
121 | // Trash the first and last lines as we have seen them. | 123 | // Trash the first and last lines as we have seen them. |
122 | l.remove(0u); | 124 | l.remove(l.first()); |
123 | l.remove(l.last()); | 125 | l.remove(l.last()); |
124 | 126 | ||
125 | /////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////// |
126 | // FIRST LINE | 128 | // FIRST LINE |
127 | 129 | ||
128 | int split = beginLine.find(':'); | 130 | int split = beginLine.find(':'); |
129 | 131 | ||
130 | if (split == -1) { // invalid, no BEGIN | 132 | if (split == -1) { // invalid, no BEGIN |
131 | vDebug("No split"); | 133 | vDebug("No split"); |
132 | return; | 134 | return; |
133 | } | 135 | } |
134 | 136 | ||
135 | QCString firstPart(beginLine.left(split)); | 137 | QString firstPart(beginLine.left(split)); |
136 | QCString valuePart(beginLine.mid(split + 1)); | 138 | QString valuePart(beginLine.mid(split + 1)); |
137 | 139 | ||
138 | split = firstPart.find('.'); | 140 | split = firstPart.find('.'); |
139 | 141 | ||
140 | if (split != -1) { | 142 | if (split != -1) { |
141 | group_ = firstPart.left(split); | 143 | group_ = firstPart.left(split); |
142 | firstPart= firstPart.right(firstPart.length() - split - 1); | 144 | firstPart= firstPart.right(firstPart.length() - split - 1); |
143 | } | 145 | } |
144 | 146 | ||
145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! |
146 | vDebug("No BEGIN"); | 148 | qDebug("no BEGIN in vcard "); |
147 | return; | 149 | return; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! |
151 | vDebug("No VCARD"); | 153 | qDebug("not a VCARD "); |
152 | return; | 154 | return; |
153 | } | 155 | } |
154 | 156 | ||
155 | /////////////////////////////////////////////////////////////// | 157 | /////////////////////////////////////////////////////////////// |
156 | // CONTENT LINES | 158 | // CONTENT LINES |
157 | // | 159 | // |
158 | vDebug("Content lines"); | 160 | vDebug("Content lines"); |
159 | 161 | ||
160 | // Handle folded lines. | 162 | // Handle folded lines. |
161 | 163 | ||
162 | QStrList refolded; | 164 | QStringList refolded; |
163 | |||
164 | QStrListIterator it(l); | ||
165 | 165 | ||
166 | QCString cur; | ||
167 | 166 | ||
168 | for (; it.current(); ++it) { | 167 | QStringList::Iterator it = l.begin(); |
169 | 168 | ||
170 | cur = it.current(); | 169 | QString cur; |
171 | 170 | ||
171 | for (; it != l.end(); ++it) { | ||
172 | cur = (*it); | ||
172 | ++it; | 173 | ++it; |
173 | 174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { | |
174 | while ( | 175 | cur += (*it) ; |
175 | it.current() && | ||
176 | it.current()[0] == ' '&& | ||
177 | strlen(it.current()) != 1) | ||
178 | { | ||
179 | cur += it.current() + 1; | ||
180 | ++it; | 176 | ++it; |
181 | } | 177 | } |
182 | |||
183 | --it; | 178 | --it; |
184 | |||
185 | refolded.append(cur); | 179 | refolded.append(cur); |
186 | } | 180 | } |
187 | 181 | QStringList::Iterator it2 = refolded.begin(); | |
188 | QStrListIterator it2(refolded); | 182 | for (; it2 != refolded.end(); ++it2) { |
189 | 183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); | |
190 | for (; it2.current(); ++it2) { | ||
191 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | ||
192 | ContentLine * cl = new ContentLine(it2.current()); | ||
193 | |||
194 | cl->parse(); | 184 | cl->parse(); |
195 | if (cl->value() == 0) | 185 | if (cl->value() == 0) |
196 | { | 186 | { |
197 | qDebug("Content line could not be parsed. Discarded: %s", it2.current()); | 187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); |
198 | delete cl; | 188 | delete cl; |
199 | } | 189 | } |
200 | else | 190 | else |
201 | contentLineList_.append(cl); | 191 | contentLineList_.append(cl); |
202 | } | 192 | } |
203 | 193 | ||
204 | /////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////// |
205 | // LAST LINE | 195 | // LAST LINE |
206 | 196 | ||
197 | |||
198 | // LR: sorry, but the remaining code in this method makes no sense | ||
199 | |||
200 | #if 0 | ||
207 | split = endLine.find(':'); | 201 | split = endLine.find(':'); |
208 | 202 | ||
209 | if (split == -1) // invalid, no END | 203 | if (split == -1) // invalid, no END |
210 | return; | 204 | return; |
211 | 205 | ||
212 | firstPart = endLine.left(split); | 206 | firstPart = endLine.left(split); |
213 | valuePart = endLine.right(firstPart.length() - split - 1); | 207 | valuePart = endLine.right(firstPart.length() - split - 1); |
214 | 208 | ||
215 | split = firstPart.find('.'); | 209 | split = firstPart.find('.'); |
216 | 210 | ||
217 | if (split != -1) { | 211 | if (split != -1) { |
218 | group_ = firstPart.left(split); | 212 | group_ = firstPart.left(split); |
219 | firstPart= firstPart.right(firstPart.length() - split - 1); | 213 | firstPart= firstPart.right(firstPart.length() - split - 1); |
220 | } | 214 | } |
221 | 215 | ||
222 | if (qstricmp(firstPart, "END") != 0) // No END ! | 216 | if (qstricmp(firstPart, "END") != 0) // No END ! |
223 | return; | 217 | return; |
224 | 218 | ||
225 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
226 | return; | 220 | return; |
221 | #endif | ||
227 | } | 222 | } |
228 | 223 | ||
229 | void | 224 | void |
230 | VCard::_assemble() | 225 | VCard::_assemble() |
231 | { | 226 | { |
232 | vDebug("Assembling vcard"); | 227 | vDebug("Assembling vcard"); |
233 | strRep_ = "BEGIN:VCARD\r\n"; | 228 | strRep_ = "BEGIN:VCARD\r\n"; |
234 | strRep_ += "VERSION:3.0\r\n"; | 229 | strRep_ += "VERSION:3.0\r\n"; |
235 | 230 | ||
236 | QPtrListIterator<ContentLine> it(contentLineList_); | 231 | QPtrListIterator<ContentLine> it(contentLineList_); |
237 | 232 | ||
238 | for (; it.current(); ++it) | 233 | for (; it.current(); ++it) |
239 | strRep_ += it.current()->asString() + "\r\n"; | 234 | strRep_ += it.current()->asString() + "\r\n"; |
240 | 235 | ||
241 | strRep_ += "END:VCARD\r\n"; | 236 | strRep_ += "END:VCARD\r\n"; |
242 | } | 237 | } |
243 | 238 | ||
244 | bool | 239 | bool |
245 | VCard::has(EntityType t) | 240 | VCard::has(EntityType t) |
246 | { | 241 | { |
247 | parse(); | 242 | parse(); |
248 | return contentLine(t) == 0 ? false : true; | 243 | return contentLine(t) == 0 ? false : true; |
249 | } | 244 | } |
250 | 245 | ||
251 | bool | 246 | bool |
252 | VCard::has(const QCString & s) | 247 | VCard::has(const QCString & s) |
253 | { | 248 | { |
254 | parse(); | 249 | parse(); |
255 | return contentLine(s) == 0 ? false : true; | 250 | return contentLine(s) == 0 ? false : true; |
256 | } | 251 | } |
257 | 252 | ||
258 | void | 253 | void |
259 | VCard::add(const ContentLine & cl) | 254 | VCard::add(const ContentLine & cl) |
260 | { | 255 | { |
261 | parse(); | 256 | parse(); |
262 | ContentLine * c = new ContentLine(cl); | 257 | ContentLine * c = new ContentLine(cl); |
263 | contentLineList_.append(c); | 258 | contentLineList_.append(c); |
264 | } | 259 | } |
265 | 260 | ||
266 | void | 261 | void |
267 | VCard::add(const QCString & s) | 262 | VCard::add(const QCString & s) |
268 | { | 263 | { |
269 | parse(); | 264 | parse(); |
270 | ContentLine * c = new ContentLine(s); | 265 | ContentLine * c = new ContentLine(s); |
271 | contentLineList_.append(c); | 266 | contentLineList_.append(c); |
272 | } | 267 | } |
273 | 268 | ||
274 | ContentLine * | 269 | ContentLine * |
275 | VCard::contentLine(EntityType t) | 270 | VCard::contentLine(EntityType t) |
276 | { | 271 | { |
277 | parse(); | 272 | parse(); |
278 | QPtrListIterator<ContentLine> it(contentLineList_); | 273 | QPtrListIterator<ContentLine> it(contentLineList_); |
279 | 274 | ||
280 | for (; it.current(); ++it) | 275 | for (; it.current(); ++it) |
281 | if (it.current()->entityType() == t) | 276 | if (it.current()->entityType() == t) |
282 | return it.current(); | 277 | return it.current(); |
283 | 278 | ||
284 | return 0; | 279 | return 0; |
285 | } | 280 | } |
286 | 281 | ||
287 | ContentLine * | 282 | ContentLine * |
288 | VCard::contentLine(const QCString & s) | 283 | VCard::contentLine(const QCString & s) |
289 | { | 284 | { |
290 | parse(); | 285 | parse(); |
291 | QPtrListIterator<ContentLine> it(contentLineList_); | 286 | QPtrListIterator<ContentLine> it(contentLineList_); |
292 | 287 | ||
293 | for (; it.current(); ++it) | 288 | for (; it.current(); ++it) |
294 | if (it.current()->entityType() == EntityNameToEntityType(s)) | 289 | if (it.current()->entityType() == EntityNameToEntityType(s)) |
295 | return it.current(); | 290 | return it.current(); |
296 | 291 | ||
297 | return 0; | 292 | return 0; |
298 | } | 293 | } |
299 | 294 | ||