-rw-r--r-- | libopie/pim/ocontact.cpp | 62 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 1 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 62 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 1 |
4 files changed, 126 insertions, 0 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index a63753e..6f648ac 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -763,384 +763,446 @@ QStringList OContact::emailList() const | |||
763 | 763 | ||
764 | QStringList r; | 764 | QStringList r; |
765 | if ( !emailStr.isEmpty() ) { | 765 | if ( !emailStr.isEmpty() ) { |
766 | qDebug(" emailstr "); | 766 | qDebug(" emailstr "); |
767 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 767 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
768 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 768 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
769 | r += (*it).simplifyWhiteSpace(); | 769 | r += (*it).simplifyWhiteSpace(); |
770 | } | 770 | } |
771 | 771 | ||
772 | return r; | 772 | return r; |
773 | } | 773 | } |
774 | 774 | ||
775 | /*! | 775 | /*! |
776 | \overload | 776 | \overload |
777 | 777 | ||
778 | Generates the string for the contact to be filed as from the first, | 778 | Generates the string for the contact to be filed as from the first, |
779 | middle and last name of the contact. | 779 | middle and last name of the contact. |
780 | */ | 780 | */ |
781 | void OContact::setFileAs() | 781 | void OContact::setFileAs() |
782 | { | 782 | { |
783 | QString lastName, firstName, middleName, fileas; | 783 | QString lastName, firstName, middleName, fileas; |
784 | 784 | ||
785 | lastName = find( Qtopia::LastName ); | 785 | lastName = find( Qtopia::LastName ); |
786 | firstName = find( Qtopia::FirstName ); | 786 | firstName = find( Qtopia::FirstName ); |
787 | middleName = find( Qtopia::MiddleName ); | 787 | middleName = find( Qtopia::MiddleName ); |
788 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 788 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
789 | && !middleName.isEmpty() ) | 789 | && !middleName.isEmpty() ) |
790 | fileas = lastName + ", " + firstName + " " + middleName; | 790 | fileas = lastName + ", " + firstName + " " + middleName; |
791 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 791 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
792 | fileas = lastName + ", " + firstName; | 792 | fileas = lastName + ", " + firstName; |
793 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 793 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
794 | !middleName.isEmpty() ) | 794 | !middleName.isEmpty() ) |
795 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 795 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
796 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 796 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
797 | + lastName; | 797 | + lastName; |
798 | 798 | ||
799 | replace( Qtopia::FileAs, fileas ); | 799 | replace( Qtopia::FileAs, fileas ); |
800 | } | 800 | } |
801 | 801 | ||
802 | /*! | 802 | /*! |
803 | \internal | 803 | \internal |
804 | Appends the contact information to \a buf. | 804 | Appends the contact information to \a buf. |
805 | */ | 805 | */ |
806 | void OContact::save( QString &buf ) const | 806 | void OContact::save( QString &buf ) const |
807 | { | 807 | { |
808 | static const QStringList SLFIELDS = fields(); | 808 | static const QStringList SLFIELDS = fields(); |
809 | // I'm expecting "<Contact " in front of this... | 809 | // I'm expecting "<Contact " in front of this... |
810 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 810 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
811 | it != mMap.end(); ++it ) { | 811 | it != mMap.end(); ++it ) { |
812 | const QString &value = it.data(); | 812 | const QString &value = it.data(); |
813 | int key = it.key(); | 813 | int key = it.key(); |
814 | if ( !value.isEmpty() ) { | 814 | if ( !value.isEmpty() ) { |
815 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 815 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
816 | continue; | 816 | continue; |
817 | 817 | ||
818 | key -= Qtopia::AddressCategory+1; | 818 | key -= Qtopia::AddressCategory+1; |
819 | buf += SLFIELDS[key]; | 819 | buf += SLFIELDS[key]; |
820 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 820 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
821 | } | 821 | } |
822 | } | 822 | } |
823 | buf += customToXml(); | 823 | buf += customToXml(); |
824 | if ( categories().count() > 0 ) | 824 | if ( categories().count() > 0 ) |
825 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 825 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
826 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 826 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
827 | // You need to close this yourself | 827 | // You need to close this yourself |
828 | } | 828 | } |
829 | 829 | ||
830 | /*! | 830 | /*! |
831 | \internal | 831 | \internal |
832 | Returns the list of fields belonging to a contact | 832 | Returns the list of fields belonging to a contact |
833 | */ | 833 | */ |
834 | QStringList OContact::fields() | 834 | QStringList OContact::fields() |
835 | { | 835 | { |
836 | QStringList list; | 836 | QStringList list; |
837 | 837 | ||
838 | list.append( "Title" ); // Not Used! | 838 | list.append( "Title" ); // Not Used! |
839 | list.append( "FirstName" ); | 839 | list.append( "FirstName" ); |
840 | list.append( "MiddleName" ); | 840 | list.append( "MiddleName" ); |
841 | list.append( "LastName" ); | 841 | list.append( "LastName" ); |
842 | list.append( "Suffix" ); | 842 | list.append( "Suffix" ); |
843 | list.append( "FileAs" ); | 843 | list.append( "FileAs" ); |
844 | 844 | ||
845 | list.append( "JobTitle" ); | 845 | list.append( "JobTitle" ); |
846 | list.append( "Department" ); | 846 | list.append( "Department" ); |
847 | list.append( "Company" ); | 847 | list.append( "Company" ); |
848 | list.append( "BusinessPhone" ); | 848 | list.append( "BusinessPhone" ); |
849 | list.append( "BusinessFax" ); | 849 | list.append( "BusinessFax" ); |
850 | list.append( "BusinessMobile" ); | 850 | list.append( "BusinessMobile" ); |
851 | 851 | ||
852 | list.append( "DefaultEmail" ); | 852 | list.append( "DefaultEmail" ); |
853 | list.append( "Emails" ); | 853 | list.append( "Emails" ); |
854 | 854 | ||
855 | list.append( "HomePhone" ); | 855 | list.append( "HomePhone" ); |
856 | list.append( "HomeFax" ); | 856 | list.append( "HomeFax" ); |
857 | list.append( "HomeMobile" ); | 857 | list.append( "HomeMobile" ); |
858 | 858 | ||
859 | list.append( "BusinessStreet" ); | 859 | list.append( "BusinessStreet" ); |
860 | list.append( "BusinessCity" ); | 860 | list.append( "BusinessCity" ); |
861 | list.append( "BusinessState" ); | 861 | list.append( "BusinessState" ); |
862 | list.append( "BusinessZip" ); | 862 | list.append( "BusinessZip" ); |
863 | list.append( "BusinessCountry" ); | 863 | list.append( "BusinessCountry" ); |
864 | list.append( "BusinessPager" ); | 864 | list.append( "BusinessPager" ); |
865 | list.append( "BusinessWebPage" ); | 865 | list.append( "BusinessWebPage" ); |
866 | 866 | ||
867 | list.append( "Office" ); | 867 | list.append( "Office" ); |
868 | list.append( "Profession" ); | 868 | list.append( "Profession" ); |
869 | list.append( "Assistant" ); | 869 | list.append( "Assistant" ); |
870 | list.append( "Manager" ); | 870 | list.append( "Manager" ); |
871 | 871 | ||
872 | list.append( "HomeStreet" ); | 872 | list.append( "HomeStreet" ); |
873 | list.append( "HomeCity" ); | 873 | list.append( "HomeCity" ); |
874 | list.append( "HomeState" ); | 874 | list.append( "HomeState" ); |
875 | list.append( "HomeZip" ); | 875 | list.append( "HomeZip" ); |
876 | list.append( "HomeCountry" ); | 876 | list.append( "HomeCountry" ); |
877 | list.append( "HomeWebPage" ); | 877 | list.append( "HomeWebPage" ); |
878 | 878 | ||
879 | list.append( "Spouse" ); | 879 | list.append( "Spouse" ); |
880 | list.append( "Gender" ); | 880 | list.append( "Gender" ); |
881 | list.append( "Birthday" ); | 881 | list.append( "Birthday" ); |
882 | list.append( "Anniversary" ); | 882 | list.append( "Anniversary" ); |
883 | list.append( "Nickname" ); | 883 | list.append( "Nickname" ); |
884 | list.append( "Children" ); | 884 | list.append( "Children" ); |
885 | 885 | ||
886 | list.append( "Notes" ); | 886 | list.append( "Notes" ); |
887 | list.append( "Groups" ); | 887 | list.append( "Groups" ); |
888 | 888 | ||
889 | return list; | 889 | return list; |
890 | } | 890 | } |
891 | 891 | ||
892 | /*! | 892 | /*! |
893 | \internal | 893 | \internal |
894 | Returns a translated list of field names for a contact. | 894 | Returns a translated list of field names for a contact. |
895 | */ | 895 | */ |
896 | QStringList OContact::trfields() | 896 | QStringList OContact::trfields() |
897 | { | 897 | { |
898 | QStringList list; | 898 | QStringList list; |
899 | 899 | ||
900 | list.append( QObject::tr( "Name Title") ); | 900 | list.append( QObject::tr( "Name Title") ); |
901 | list.append( QObject::tr( "First Name" ) ); | 901 | list.append( QObject::tr( "First Name" ) ); |
902 | list.append( QObject::tr( "Middle Name" ) ); | 902 | list.append( QObject::tr( "Middle Name" ) ); |
903 | list.append( QObject::tr( "Last Name" ) ); | 903 | list.append( QObject::tr( "Last Name" ) ); |
904 | list.append( QObject::tr( "Suffix" ) ); | 904 | list.append( QObject::tr( "Suffix" ) ); |
905 | list.append( QObject::tr( "File As" ) ); | 905 | list.append( QObject::tr( "File As" ) ); |
906 | 906 | ||
907 | list.append( QObject::tr( "Job Title" ) ); | 907 | list.append( QObject::tr( "Job Title" ) ); |
908 | list.append( QObject::tr( "Department" ) ); | 908 | list.append( QObject::tr( "Department" ) ); |
909 | list.append( QObject::tr( "Company" ) ); | 909 | list.append( QObject::tr( "Company" ) ); |
910 | list.append( QObject::tr( "Business Phone" ) ); | 910 | list.append( QObject::tr( "Business Phone" ) ); |
911 | list.append( QObject::tr( "Business Fax" ) ); | 911 | list.append( QObject::tr( "Business Fax" ) ); |
912 | list.append( QObject::tr( "Business Mobile" ) ); | 912 | list.append( QObject::tr( "Business Mobile" ) ); |
913 | 913 | ||
914 | list.append( QObject::tr( "Default Email" ) ); | 914 | list.append( QObject::tr( "Default Email" ) ); |
915 | list.append( QObject::tr( "Emails" ) ); | 915 | list.append( QObject::tr( "Emails" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Home Phone" ) ); | 917 | list.append( QObject::tr( "Home Phone" ) ); |
918 | list.append( QObject::tr( "Home Fax" ) ); | 918 | list.append( QObject::tr( "Home Fax" ) ); |
919 | list.append( QObject::tr( "Home Mobile" ) ); | 919 | list.append( QObject::tr( "Home Mobile" ) ); |
920 | 920 | ||
921 | list.append( QObject::tr( "Business Street" ) ); | 921 | list.append( QObject::tr( "Business Street" ) ); |
922 | list.append( QObject::tr( "Business City" ) ); | 922 | list.append( QObject::tr( "Business City" ) ); |
923 | list.append( QObject::tr( "Business State" ) ); | 923 | list.append( QObject::tr( "Business State" ) ); |
924 | list.append( QObject::tr( "Business Zip" ) ); | 924 | list.append( QObject::tr( "Business Zip" ) ); |
925 | list.append( QObject::tr( "Business Country" ) ); | 925 | list.append( QObject::tr( "Business Country" ) ); |
926 | list.append( QObject::tr( "Business Pager" ) ); | 926 | list.append( QObject::tr( "Business Pager" ) ); |
927 | list.append( QObject::tr( "Business WebPage" ) ); | 927 | list.append( QObject::tr( "Business WebPage" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Office" ) ); | 929 | list.append( QObject::tr( "Office" ) ); |
930 | list.append( QObject::tr( "Profession" ) ); | 930 | list.append( QObject::tr( "Profession" ) ); |
931 | list.append( QObject::tr( "Assistant" ) ); | 931 | list.append( QObject::tr( "Assistant" ) ); |
932 | list.append( QObject::tr( "Manager" ) ); | 932 | list.append( QObject::tr( "Manager" ) ); |
933 | 933 | ||
934 | list.append( QObject::tr( "Home Street" ) ); | 934 | list.append( QObject::tr( "Home Street" ) ); |
935 | list.append( QObject::tr( "Home City" ) ); | 935 | list.append( QObject::tr( "Home City" ) ); |
936 | list.append( QObject::tr( "Home State" ) ); | 936 | list.append( QObject::tr( "Home State" ) ); |
937 | list.append( QObject::tr( "Home Zip" ) ); | 937 | list.append( QObject::tr( "Home Zip" ) ); |
938 | list.append( QObject::tr( "Home Country" ) ); | 938 | list.append( QObject::tr( "Home Country" ) ); |
939 | list.append( QObject::tr( "Home Web Page" ) ); | 939 | list.append( QObject::tr( "Home Web Page" ) ); |
940 | 940 | ||
941 | list.append( QObject::tr( "Spouse" ) ); | 941 | list.append( QObject::tr( "Spouse" ) ); |
942 | list.append( QObject::tr( "Gender" ) ); | 942 | list.append( QObject::tr( "Gender" ) ); |
943 | list.append( QObject::tr( "Birthday" ) ); | 943 | list.append( QObject::tr( "Birthday" ) ); |
944 | list.append( QObject::tr( "Anniversary" ) ); | 944 | list.append( QObject::tr( "Anniversary" ) ); |
945 | list.append( QObject::tr( "Nickname" ) ); | 945 | list.append( QObject::tr( "Nickname" ) ); |
946 | list.append( QObject::tr( "Children" ) ); | 946 | list.append( QObject::tr( "Children" ) ); |
947 | 947 | ||
948 | list.append( QObject::tr( "Notes" ) ); | 948 | list.append( QObject::tr( "Notes" ) ); |
949 | list.append( QObject::tr( "Groups" ) ); | 949 | list.append( QObject::tr( "Groups" ) ); |
950 | 950 | ||
951 | return list; | 951 | return list; |
952 | } | 952 | } |
953 | 953 | ||
954 | /*! | 954 | /*! |
955 | \internal | ||
956 | Returns an untranslated list of field names for a contact. | ||
957 | */ | ||
958 | QStringList OContact::untrfields() | ||
959 | { | ||
960 | QStringList list; | ||
961 | |||
962 | list.append( "Name Title" ); | ||
963 | list.append( "First Name" ); | ||
964 | list.append( "Middle Name" ); | ||
965 | list.append( "Last Name" ); | ||
966 | list.append( "Suffix" ); | ||
967 | list.append( "File As" ); | ||
968 | |||
969 | list.append( "Job Title" ); | ||
970 | list.append( "Department" ); | ||
971 | list.append( "Company" ); | ||
972 | list.append( "Business Phone" ); | ||
973 | list.append( "Business Fax" ); | ||
974 | list.append( "Business Mobile" ); | ||
975 | |||
976 | list.append( "Default Email" ); | ||
977 | list.append( "Emails" ); | ||
978 | |||
979 | list.append( "Home Phone" ); | ||
980 | list.append( "Home Fax" ); | ||
981 | list.append( "Home Mobile" ); | ||
982 | |||
983 | list.append( "Business Street" ); | ||
984 | list.append( "Business City" ); | ||
985 | list.append( "Business State" ); | ||
986 | list.append( "Business Zip" ); | ||
987 | list.append( "Business Country" ); | ||
988 | list.append( "Business Pager" ); | ||
989 | list.append( "Business WebPage" ); | ||
990 | |||
991 | list.append( "Office" ); | ||
992 | list.append( "Profession" ); | ||
993 | list.append( "Assistant" ); | ||
994 | list.append( "Manager" ); | ||
995 | |||
996 | list.append( "Home Street" ); | ||
997 | list.append( "Home City" ); | ||
998 | list.append( "Home State" ); | ||
999 | list.append( "Home Zip" ); | ||
1000 | list.append( "Home Country" ); | ||
1001 | list.append( "Home Web Page" ); | ||
1002 | |||
1003 | list.append( "Spouse" ); | ||
1004 | list.append( "Gender" ); | ||
1005 | list.append( "Birthday" ); | ||
1006 | list.append( "Anniversary" ); | ||
1007 | list.append( "Nickname" ); | ||
1008 | list.append( "Children" ); | ||
1009 | |||
1010 | list.append( "Notes" ); | ||
1011 | list.append( "Groups" ); | ||
1012 | |||
1013 | return list; | ||
1014 | } | ||
1015 | |||
1016 | /*! | ||
955 | Sets the list of email address for contact to those contained in \a str. | 1017 | Sets the list of email address for contact to those contained in \a str. |
956 | Email address should be separated by ';'s. | 1018 | Email address should be separated by ';'s. |
957 | */ | 1019 | */ |
958 | void OContact::setEmails( const QString &str ) | 1020 | void OContact::setEmails( const QString &str ) |
959 | { | 1021 | { |
960 | replace( Qtopia::Emails, str ); | 1022 | replace( Qtopia::Emails, str ); |
961 | if ( str.isEmpty() ) | 1023 | if ( str.isEmpty() ) |
962 | setDefaultEmail( QString::null ); | 1024 | setDefaultEmail( QString::null ); |
963 | } | 1025 | } |
964 | 1026 | ||
965 | /*! | 1027 | /*! |
966 | Sets the list of children for the contact to those contained in \a str. | 1028 | Sets the list of children for the contact to those contained in \a str. |
967 | */ | 1029 | */ |
968 | void OContact::setChildren( const QString &str ) | 1030 | void OContact::setChildren( const QString &str ) |
969 | { | 1031 | { |
970 | replace( Qtopia::Children, str ); | 1032 | replace( Qtopia::Children, str ); |
971 | } | 1033 | } |
972 | 1034 | ||
973 | // vcard conversion code | 1035 | // vcard conversion code |
974 | /*! | 1036 | /*! |
975 | \internal | 1037 | \internal |
976 | */ | 1038 | */ |
977 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1039 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
978 | { | 1040 | { |
979 | VObject *ret = 0; | 1041 | VObject *ret = 0; |
980 | if ( o && !value.isEmpty() ) | 1042 | if ( o && !value.isEmpty() ) |
981 | ret = addPropValue( o, prop, value.latin1() ); | 1043 | ret = addPropValue( o, prop, value.latin1() ); |
982 | return ret; | 1044 | return ret; |
983 | } | 1045 | } |
984 | 1046 | ||
985 | /*! | 1047 | /*! |
986 | \internal | 1048 | \internal |
987 | */ | 1049 | */ |
988 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1050 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
989 | { | 1051 | { |
990 | VObject *ret = 0; | 1052 | VObject *ret = 0; |
991 | if ( o ) | 1053 | if ( o ) |
992 | ret = addProp( o, prop ); | 1054 | ret = addProp( o, prop ); |
993 | return ret; | 1055 | return ret; |
994 | } | 1056 | } |
995 | 1057 | ||
996 | /*! | 1058 | /*! |
997 | \internal | 1059 | \internal |
998 | */ | 1060 | */ |
999 | static VObject *createVObject( const OContact &c ) | 1061 | static VObject *createVObject( const OContact &c ) |
1000 | { | 1062 | { |
1001 | VObject *vcard = newVObject( VCCardProp ); | 1063 | VObject *vcard = newVObject( VCCardProp ); |
1002 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1064 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1003 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1065 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1004 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1066 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1005 | 1067 | ||
1006 | // full name | 1068 | // full name |
1007 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1069 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1008 | 1070 | ||
1009 | // name properties | 1071 | // name properties |
1010 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1072 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1011 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1073 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1012 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1074 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1013 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1075 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1014 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1076 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1015 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1077 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1016 | 1078 | ||
1017 | // home properties | 1079 | // home properties |
1018 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1080 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1019 | safeAddProp( home_adr, VCHomeProp ); | 1081 | safeAddProp( home_adr, VCHomeProp ); |
1020 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1082 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1021 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1083 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1022 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1084 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1023 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1085 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1024 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1086 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1025 | 1087 | ||
1026 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1088 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1027 | safeAddProp( home_phone, VCHomeProp ); | 1089 | safeAddProp( home_phone, VCHomeProp ); |
1028 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1090 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1029 | safeAddProp( home_phone, VCHomeProp ); | 1091 | safeAddProp( home_phone, VCHomeProp ); |
1030 | safeAddProp( home_phone, VCCellularProp ); | 1092 | safeAddProp( home_phone, VCCellularProp ); |
1031 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1093 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1032 | safeAddProp( home_phone, VCHomeProp ); | 1094 | safeAddProp( home_phone, VCHomeProp ); |
1033 | safeAddProp( home_phone, VCFaxProp ); | 1095 | safeAddProp( home_phone, VCFaxProp ); |
1034 | 1096 | ||
1035 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1097 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1036 | safeAddProp( url, VCHomeProp ); | 1098 | safeAddProp( url, VCHomeProp ); |
1037 | 1099 | ||
1038 | // work properties | 1100 | // work properties |
1039 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1101 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1040 | safeAddProp( work_adr, VCWorkProp ); | 1102 | safeAddProp( work_adr, VCWorkProp ); |
1041 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1103 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1042 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1104 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1043 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1105 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1044 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1106 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1045 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1107 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1046 | 1108 | ||
1047 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1109 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1048 | safeAddProp( work_phone, VCWorkProp ); | 1110 | safeAddProp( work_phone, VCWorkProp ); |
1049 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1111 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1050 | safeAddProp( work_phone, VCWorkProp ); | 1112 | safeAddProp( work_phone, VCWorkProp ); |
1051 | safeAddProp( work_phone, VCCellularProp ); | 1113 | safeAddProp( work_phone, VCCellularProp ); |
1052 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1114 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1053 | safeAddProp( work_phone, VCWorkProp ); | 1115 | safeAddProp( work_phone, VCWorkProp ); |
1054 | safeAddProp( work_phone, VCFaxProp ); | 1116 | safeAddProp( work_phone, VCFaxProp ); |
1055 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1117 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1056 | safeAddProp( work_phone, VCWorkProp ); | 1118 | safeAddProp( work_phone, VCWorkProp ); |
1057 | safeAddProp( work_phone, VCPagerProp ); | 1119 | safeAddProp( work_phone, VCPagerProp ); |
1058 | 1120 | ||
1059 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1121 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1060 | safeAddProp( url, VCWorkProp ); | 1122 | safeAddProp( url, VCWorkProp ); |
1061 | 1123 | ||
1062 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1124 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1063 | safeAddProp( title, VCWorkProp ); | 1125 | safeAddProp( title, VCWorkProp ); |
1064 | 1126 | ||
1065 | 1127 | ||
1066 | QStringList emails = c.emailList(); | 1128 | QStringList emails = c.emailList(); |
1067 | emails.prepend( c.defaultEmail() ); | 1129 | emails.prepend( c.defaultEmail() ); |
1068 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1130 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1069 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1131 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1070 | safeAddProp( email, VCInternetProp ); | 1132 | safeAddProp( email, VCInternetProp ); |
1071 | } | 1133 | } |
1072 | 1134 | ||
1073 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1135 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1074 | 1136 | ||
1075 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); |
1076 | 1138 | ||
1077 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1139 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1078 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1140 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1079 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1141 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1080 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1142 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1081 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1143 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1082 | } | 1144 | } |
1083 | 1145 | ||
1084 | // some values we have to export as custom fields | 1146 | // some values we have to export as custom fields |
1085 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1147 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1086 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1087 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1149 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1088 | 1150 | ||
1089 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1151 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1090 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1152 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1091 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); | 1153 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); |
1092 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1154 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1093 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1155 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1094 | 1156 | ||
1095 | return vcard; | 1157 | return vcard; |
1096 | } | 1158 | } |
1097 | 1159 | ||
1098 | 1160 | ||
1099 | /*! | 1161 | /*! |
1100 | \internal | 1162 | \internal |
1101 | */ | 1163 | */ |
1102 | static OContact parseVObject( VObject *obj ) | 1164 | static OContact parseVObject( VObject *obj ) |
1103 | { | 1165 | { |
1104 | OContact c; | 1166 | OContact c; |
1105 | 1167 | ||
1106 | VObjectIterator it; | 1168 | VObjectIterator it; |
1107 | initPropIterator( &it, obj ); | 1169 | initPropIterator( &it, obj ); |
1108 | while( moreIteration( &it ) ) { | 1170 | while( moreIteration( &it ) ) { |
1109 | VObject *o = nextVObject( &it ); | 1171 | VObject *o = nextVObject( &it ); |
1110 | QCString name = vObjectName( o ); | 1172 | QCString name = vObjectName( o ); |
1111 | QCString value = vObjectStringZValue( o ); | 1173 | QCString value = vObjectStringZValue( o ); |
1112 | if ( name == VCNameProp ) { | 1174 | if ( name == VCNameProp ) { |
1113 | VObjectIterator nit; | 1175 | VObjectIterator nit; |
1114 | initPropIterator( &nit, o ); | 1176 | initPropIterator( &nit, o ); |
1115 | while( moreIteration( &nit ) ) { | 1177 | while( moreIteration( &nit ) ) { |
1116 | VObject *o = nextVObject( &nit ); | 1178 | VObject *o = nextVObject( &nit ); |
1117 | QCString name = vObjectTypeInfo( o ); | 1179 | QCString name = vObjectTypeInfo( o ); |
1118 | QString value = vObjectStringZValue( o ); | 1180 | QString value = vObjectStringZValue( o ); |
1119 | if ( name == VCNamePrefixesProp ) | 1181 | if ( name == VCNamePrefixesProp ) |
1120 | c.setTitle( value ); | 1182 | c.setTitle( value ); |
1121 | else if ( name == VCNameSuffixesProp ) | 1183 | else if ( name == VCNameSuffixesProp ) |
1122 | c.setSuffix( value ); | 1184 | c.setSuffix( value ); |
1123 | else if ( name == VCFamilyNameProp ) | 1185 | else if ( name == VCFamilyNameProp ) |
1124 | c.setLastName( value ); | 1186 | c.setLastName( value ); |
1125 | else if ( name == VCGivenNameProp ) | 1187 | else if ( name == VCGivenNameProp ) |
1126 | c.setFirstName( value ); | 1188 | c.setFirstName( value ); |
1127 | else if ( name == VCAdditionalNamesProp ) | 1189 | else if ( name == VCAdditionalNamesProp ) |
1128 | c.setMiddleName( value ); | 1190 | c.setMiddleName( value ); |
1129 | } | 1191 | } |
1130 | } | 1192 | } |
1131 | else if ( name == VCAdrProp ) { | 1193 | else if ( name == VCAdrProp ) { |
1132 | bool work = TRUE; // default address is work address | 1194 | bool work = TRUE; // default address is work address |
1133 | QString street; | 1195 | QString street; |
1134 | QString city; | 1196 | QString city; |
1135 | QString region; | 1197 | QString region; |
1136 | QString postal; | 1198 | QString postal; |
1137 | QString country; | 1199 | QString country; |
1138 | 1200 | ||
1139 | VObjectIterator nit; | 1201 | VObjectIterator nit; |
1140 | initPropIterator( &nit, o ); | 1202 | initPropIterator( &nit, o ); |
1141 | while( moreIteration( &nit ) ) { | 1203 | while( moreIteration( &nit ) ) { |
1142 | VObject *o = nextVObject( &nit ); | 1204 | VObject *o = nextVObject( &nit ); |
1143 | QCString name = vObjectName( o ); | 1205 | QCString name = vObjectName( o ); |
1144 | QString value = vObjectStringZValue( o ); | 1206 | QString value = vObjectStringZValue( o ); |
1145 | if ( name == VCHomeProp ) | 1207 | if ( name == VCHomeProp ) |
1146 | work = FALSE; | 1208 | work = FALSE; |
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 756c87d..f916cf2 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -1,314 +1,315 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __OCONTACT_H__ | 21 | #ifndef __OCONTACT_H__ |
22 | #define __OCONTACT_H__ | 22 | #define __OCONTACT_H__ |
23 | 23 | ||
24 | #include <opie/opimrecord.h> | 24 | #include <opie/opimrecord.h> |
25 | #include <qpe/recordfields.h> | 25 | #include <qpe/recordfields.h> |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) | 35 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) |
36 | class QPC_EXPORT OContact : public OPimRecord | 36 | class QPC_EXPORT OContact : public OPimRecord |
37 | { | 37 | { |
38 | friend class DataSet; | 38 | friend class DataSet; |
39 | public: | 39 | public: |
40 | OContact(); | 40 | OContact(); |
41 | OContact( const QMap<int, QString> &fromMap ); | 41 | OContact( const QMap<int, QString> &fromMap ); |
42 | virtual ~OContact(); | 42 | virtual ~OContact(); |
43 | 43 | ||
44 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); | 44 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); |
45 | static void writeVCard( const QString &filename, const OContact &c ); | 45 | static void writeVCard( const QString &filename, const OContact &c ); |
46 | static QValueList<OContact> readVCard( const QString &filename ); | 46 | static QValueList<OContact> readVCard( const QString &filename ); |
47 | 47 | ||
48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
49 | 49 | ||
50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
56 | void setFileAs(); | 56 | void setFileAs(); |
57 | 57 | ||
58 | // default email address | 58 | // default email address |
59 | void setDefaultEmail( const QString &v ); | 59 | void setDefaultEmail( const QString &v ); |
60 | // inserts email to list and ensure's doesn't already exist | 60 | // inserts email to list and ensure's doesn't already exist |
61 | void insertEmail( const QString &v ); | 61 | void insertEmail( const QString &v ); |
62 | void removeEmail( const QString &v ); | 62 | void removeEmail( const QString &v ); |
63 | void clearEmails(); | 63 | void clearEmails(); |
64 | void insertEmails( const QStringList &v ); | 64 | void insertEmails( const QStringList &v ); |
65 | 65 | ||
66 | // home | 66 | // home |
67 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 67 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
68 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 68 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
69 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 69 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
70 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 70 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
71 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 71 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
72 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 72 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
73 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 73 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
74 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 74 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
75 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 75 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
76 | 76 | ||
77 | // business | 77 | // business |
78 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 78 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
79 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 79 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
80 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 80 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
81 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 81 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
82 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 82 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
83 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 83 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
84 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 84 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
85 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 85 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
86 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 86 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
87 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 87 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
88 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 88 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
89 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 89 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
90 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 90 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
91 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 91 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
92 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 92 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
93 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 93 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
94 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 94 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
95 | 95 | ||
96 | // personal | 96 | // personal |
97 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 97 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
98 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 98 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
99 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } | 99 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } |
100 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } | 100 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } |
101 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 101 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
102 | void setChildren( const QString &v ); | 102 | void setChildren( const QString &v ); |
103 | 103 | ||
104 | // other | 104 | // other |
105 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 105 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
106 | 106 | ||
107 | bool match( const QString ®exp ) const; | 107 | bool match( const QString ®exp ) const; |
108 | 108 | ||
109 | // DON'T ATTEMPT TO USE THIS | 109 | // DON'T ATTEMPT TO USE THIS |
110 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | 110 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE |
111 | bool match( const QRegExp ®exp ) const; | 111 | bool match( const QRegExp ®exp ) const; |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | // // custom | 114 | // // custom |
115 | // void setCustomField( const QString &key, const QString &v ) | 115 | // void setCustomField( const QString &key, const QString &v ) |
116 | // { replace(Custom- + key, v ); } | 116 | // { replace(Custom- + key, v ); } |
117 | 117 | ||
118 | // name | 118 | // name |
119 | QString fullName() const; | 119 | QString fullName() const; |
120 | QString title() const { return find( Qtopia::Title ); } | 120 | QString title() const { return find( Qtopia::Title ); } |
121 | QString firstName() const { return find( Qtopia::FirstName ); } | 121 | QString firstName() const { return find( Qtopia::FirstName ); } |
122 | QString middleName() const { return find( Qtopia::MiddleName ); } | 122 | QString middleName() const { return find( Qtopia::MiddleName ); } |
123 | QString lastName() const { return find( Qtopia::LastName ); } | 123 | QString lastName() const { return find( Qtopia::LastName ); } |
124 | QString suffix() const { return find( Qtopia::Suffix ); } | 124 | QString suffix() const { return find( Qtopia::Suffix ); } |
125 | QString fileAs() const { return find( Qtopia::FileAs ); } | 125 | QString fileAs() const { return find( Qtopia::FileAs ); } |
126 | 126 | ||
127 | 127 | ||
128 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 128 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
129 | QStringList emailList() const; | 129 | QStringList emailList() const; |
130 | 130 | ||
131 | // home | 131 | // home |
132 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 132 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
133 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 133 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
134 | QString homeState() const { return find( Qtopia::HomeState ); } | 134 | QString homeState() const { return find( Qtopia::HomeState ); } |
135 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 135 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
136 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 136 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
137 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 137 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
138 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 138 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
139 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 139 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
140 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 140 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
141 | /** Multi line string containing all non-empty address info in the form | 141 | /** Multi line string containing all non-empty address info in the form |
142 | * Street | 142 | * Street |
143 | * City, State Zip | 143 | * City, State Zip |
144 | * Country | 144 | * Country |
145 | */ | 145 | */ |
146 | QString displayHomeAddress() const; | 146 | QString displayHomeAddress() const; |
147 | 147 | ||
148 | // business | 148 | // business |
149 | QString company() const { return find( Qtopia::Company ); } | 149 | QString company() const { return find( Qtopia::Company ); } |
150 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 150 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
151 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 151 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
152 | QString businessState() const { return find( Qtopia::BusinessState ); } | 152 | QString businessState() const { return find( Qtopia::BusinessState ); } |
153 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 153 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
154 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 154 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
155 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 155 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
156 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 156 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
157 | QString department() const { return find( Qtopia::Department ); } | 157 | QString department() const { return find( Qtopia::Department ); } |
158 | QString office() const { return find( Qtopia::Office ); } | 158 | QString office() const { return find( Qtopia::Office ); } |
159 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 159 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
160 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 160 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
161 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 161 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
162 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 162 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
163 | QString profession() const { return find( Qtopia::Profession ); } | 163 | QString profession() const { return find( Qtopia::Profession ); } |
164 | QString assistant() const { return find( Qtopia::Assistant ); } | 164 | QString assistant() const { return find( Qtopia::Assistant ); } |
165 | QString manager() const { return find( Qtopia::Manager ); } | 165 | QString manager() const { return find( Qtopia::Manager ); } |
166 | /** Multi line string containing all non-empty address info in the form | 166 | /** Multi line string containing all non-empty address info in the form |
167 | * Street | 167 | * Street |
168 | * City, State Zip | 168 | * City, State Zip |
169 | * Country | 169 | * Country |
170 | */ | 170 | */ |
171 | QString displayBusinessAddress() const; | 171 | QString displayBusinessAddress() const; |
172 | 172 | ||
173 | //personal | 173 | //personal |
174 | QString spouse() const { return find( Qtopia::Spouse ); } | 174 | QString spouse() const { return find( Qtopia::Spouse ); } |
175 | QString gender() const { return find( Qtopia::Gender ); } | 175 | QString gender() const { return find( Qtopia::Gender ); } |
176 | QString birthday() const { return find( Qtopia::Birthday ); } | 176 | QString birthday() const { return find( Qtopia::Birthday ); } |
177 | QString anniversary() const { return find( Qtopia::Anniversary ); } | 177 | QString anniversary() const { return find( Qtopia::Anniversary ); } |
178 | QString nickname() const { return find( Qtopia::Nickname ); } | 178 | QString nickname() const { return find( Qtopia::Nickname ); } |
179 | QString children() const { return find( Qtopia::Children ); } | 179 | QString children() const { return find( Qtopia::Children ); } |
180 | QStringList childrenList() const; | 180 | QStringList childrenList() const; |
181 | 181 | ||
182 | // other | 182 | // other |
183 | QString notes() const { return find( Qtopia::Notes ); } | 183 | QString notes() const { return find( Qtopia::Notes ); } |
184 | QString groups() const { return find( Qtopia::Groups ); } | 184 | QString groups() const { return find( Qtopia::Groups ); } |
185 | QStringList groupList() const; | 185 | QStringList groupList() const; |
186 | 186 | ||
187 | // // custom | 187 | // // custom |
188 | // const QString &customField( const QString &key ) | 188 | // const QString &customField( const QString &key ) |
189 | // { return find( Custom- + key ); } | 189 | // { return find( Custom- + key ); } |
190 | 190 | ||
191 | static QStringList fields(); | 191 | static QStringList fields(); |
192 | static QStringList trfields(); | 192 | static QStringList trfields(); |
193 | static QStringList untrfields(); | ||
193 | 194 | ||
194 | QString toRichText() const; | 195 | QString toRichText() const; |
195 | QMap<int, QString> toMap() const; | 196 | QMap<int, QString> toMap() const; |
196 | QString field( int key ) const { return find( key ); } | 197 | QString field( int key ) const { return find( key ); } |
197 | 198 | ||
198 | 199 | ||
199 | // journaling... | 200 | // journaling... |
200 | void saveJournal( journal_action action, const QString &key = QString::null ); | 201 | void saveJournal( journal_action action, const QString &key = QString::null ); |
201 | void save( QString &buf ) const; | 202 | void save( QString &buf ) const; |
202 | 203 | ||
203 | void setUid( int i ) | 204 | void setUid( int i ) |
204 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 205 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
205 | 206 | ||
206 | QString toShortText()const; | 207 | QString toShortText()const; |
207 | QString OContact::type()const; | 208 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 209 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 210 | class QString OContact::recordField(int) const; |
210 | 211 | ||
211 | // Why private ? (eilers,se) | 212 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 213 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 214 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 215 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 216 | QString emails() const { return find( Qtopia::Emails ); } |
216 | 217 | ||
217 | 218 | ||
218 | private: | 219 | private: |
219 | friend class AbEditor; | 220 | friend class AbEditor; |
220 | friend class AbTable; | 221 | friend class AbTable; |
221 | friend class AddressBookAccessPrivate; | 222 | friend class AddressBookAccessPrivate; |
222 | friend class XMLIO; | 223 | friend class XMLIO; |
223 | 224 | ||
224 | 225 | ||
225 | void insert( int key, const QString &value ); | 226 | void insert( int key, const QString &value ); |
226 | void replace( int key, const QString &value ); | 227 | void replace( int key, const QString &value ); |
227 | QString find( int key ) const; | 228 | QString find( int key ) const; |
228 | 229 | ||
229 | QString displayAddress( const QString &street, | 230 | QString displayAddress( const QString &street, |
230 | const QString &city, | 231 | const QString &city, |
231 | const QString &state, | 232 | const QString &state, |
232 | const QString &zip, | 233 | const QString &zip, |
233 | const QString &country ) const; | 234 | const QString &country ) const; |
234 | 235 | ||
235 | Qtopia::UidGen &uidGen() { return sUidGen; } | 236 | Qtopia::UidGen &uidGen() { return sUidGen; } |
236 | static Qtopia::UidGen sUidGen; | 237 | static Qtopia::UidGen sUidGen; |
237 | QMap<int, QString> mMap; | 238 | QMap<int, QString> mMap; |
238 | ContactPrivate *d; | 239 | ContactPrivate *d; |
239 | }; | 240 | }; |
240 | 241 | ||
241 | // these methods are inlined to keep binary compatability with Qtopia 1.5 | 242 | // these methods are inlined to keep binary compatability with Qtopia 1.5 |
242 | inline void OContact::insertEmail( const QString &v ) | 243 | inline void OContact::insertEmail( const QString &v ) |
243 | { | 244 | { |
244 | //qDebug("insertEmail %s", v.latin1()); | 245 | //qDebug("insertEmail %s", v.latin1()); |
245 | QString e = v.simplifyWhiteSpace(); | 246 | QString e = v.simplifyWhiteSpace(); |
246 | QString def = defaultEmail(); | 247 | QString def = defaultEmail(); |
247 | 248 | ||
248 | // if no default, set it as the default email and don't insert | 249 | // if no default, set it as the default email and don't insert |
249 | if ( def.isEmpty() ) { | 250 | if ( def.isEmpty() ) { |
250 | setDefaultEmail( e ); // will insert into the list for us | 251 | setDefaultEmail( e ); // will insert into the list for us |
251 | return; | 252 | return; |
252 | } | 253 | } |
253 | 254 | ||
254 | // otherwise, insert assuming doesn't already exist | 255 | // otherwise, insert assuming doesn't already exist |
255 | QString emailsStr = find( Qtopia::Emails ); | 256 | QString emailsStr = find( Qtopia::Emails ); |
256 | if ( emailsStr.contains( e )) | 257 | if ( emailsStr.contains( e )) |
257 | return; | 258 | return; |
258 | if ( !emailsStr.isEmpty() ) | 259 | if ( !emailsStr.isEmpty() ) |
259 | emailsStr += emailSeparator(); | 260 | emailsStr += emailSeparator(); |
260 | emailsStr += e; | 261 | emailsStr += e; |
261 | replace( Qtopia::Emails, emailsStr ); | 262 | replace( Qtopia::Emails, emailsStr ); |
262 | } | 263 | } |
263 | 264 | ||
264 | inline void OContact::removeEmail( const QString &v ) | 265 | inline void OContact::removeEmail( const QString &v ) |
265 | { | 266 | { |
266 | QString e = v.simplifyWhiteSpace(); | 267 | QString e = v.simplifyWhiteSpace(); |
267 | QString def = defaultEmail(); | 268 | QString def = defaultEmail(); |
268 | QString emailsStr = find( Qtopia::Emails ); | 269 | QString emailsStr = find( Qtopia::Emails ); |
269 | QStringList emails = emailList(); | 270 | QStringList emails = emailList(); |
270 | 271 | ||
271 | // otherwise, must first contain it | 272 | // otherwise, must first contain it |
272 | if ( !emailsStr.contains( e ) ) | 273 | if ( !emailsStr.contains( e ) ) |
273 | return; | 274 | return; |
274 | 275 | ||
275 | // remove it | 276 | // remove it |
276 | //qDebug(" removing email from list %s", e.latin1()); | 277 | //qDebug(" removing email from list %s", e.latin1()); |
277 | emails.remove( e ); | 278 | emails.remove( e ); |
278 | // reset the string | 279 | // reset the string |
279 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 280 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
280 | replace( Qtopia::Emails, emailsStr ); | 281 | replace( Qtopia::Emails, emailsStr ); |
281 | 282 | ||
282 | // if default, then replace the default email with the first one | 283 | // if default, then replace the default email with the first one |
283 | if ( def == e ) { | 284 | if ( def == e ) { |
284 | //qDebug("removeEmail is default; setting new default"); | 285 | //qDebug("removeEmail is default; setting new default"); |
285 | if ( !emails.count() ) | 286 | if ( !emails.count() ) |
286 | clearEmails(); | 287 | clearEmails(); |
287 | else // setDefaultEmail will remove e from the list | 288 | else // setDefaultEmail will remove e from the list |
288 | setDefaultEmail( emails.first() ); | 289 | setDefaultEmail( emails.first() ); |
289 | } | 290 | } |
290 | } | 291 | } |
291 | inline void OContact::clearEmails() | 292 | inline void OContact::clearEmails() |
292 | { | 293 | { |
293 | mMap.remove( Qtopia::DefaultEmail ); | 294 | mMap.remove( Qtopia::DefaultEmail ); |
294 | mMap.remove( Qtopia::Emails ); | 295 | mMap.remove( Qtopia::Emails ); |
295 | } | 296 | } |
296 | inline void OContact::setDefaultEmail( const QString &v ) | 297 | inline void OContact::setDefaultEmail( const QString &v ) |
297 | { | 298 | { |
298 | QString e = v.simplifyWhiteSpace(); | 299 | QString e = v.simplifyWhiteSpace(); |
299 | 300 | ||
300 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 301 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
301 | replace( Qtopia::DefaultEmail, e ); | 302 | replace( Qtopia::DefaultEmail, e ); |
302 | 303 | ||
303 | if ( !e.isEmpty() ) | 304 | if ( !e.isEmpty() ) |
304 | insertEmail( e ); | 305 | insertEmail( e ); |
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
308 | inline void OContact::insertEmails( const QStringList &v ) | 309 | inline void OContact::insertEmails( const QStringList &v ) |
309 | { | 310 | { |
310 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 311 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
311 | insertEmail( *it ); | 312 | insertEmail( *it ); |
312 | } | 313 | } |
313 | 314 | ||
314 | #endif | 315 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index a63753e..6f648ac 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -763,384 +763,446 @@ QStringList OContact::emailList() const | |||
763 | 763 | ||
764 | QStringList r; | 764 | QStringList r; |
765 | if ( !emailStr.isEmpty() ) { | 765 | if ( !emailStr.isEmpty() ) { |
766 | qDebug(" emailstr "); | 766 | qDebug(" emailstr "); |
767 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 767 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
768 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 768 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
769 | r += (*it).simplifyWhiteSpace(); | 769 | r += (*it).simplifyWhiteSpace(); |
770 | } | 770 | } |
771 | 771 | ||
772 | return r; | 772 | return r; |
773 | } | 773 | } |
774 | 774 | ||
775 | /*! | 775 | /*! |
776 | \overload | 776 | \overload |
777 | 777 | ||
778 | Generates the string for the contact to be filed as from the first, | 778 | Generates the string for the contact to be filed as from the first, |
779 | middle and last name of the contact. | 779 | middle and last name of the contact. |
780 | */ | 780 | */ |
781 | void OContact::setFileAs() | 781 | void OContact::setFileAs() |
782 | { | 782 | { |
783 | QString lastName, firstName, middleName, fileas; | 783 | QString lastName, firstName, middleName, fileas; |
784 | 784 | ||
785 | lastName = find( Qtopia::LastName ); | 785 | lastName = find( Qtopia::LastName ); |
786 | firstName = find( Qtopia::FirstName ); | 786 | firstName = find( Qtopia::FirstName ); |
787 | middleName = find( Qtopia::MiddleName ); | 787 | middleName = find( Qtopia::MiddleName ); |
788 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 788 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
789 | && !middleName.isEmpty() ) | 789 | && !middleName.isEmpty() ) |
790 | fileas = lastName + ", " + firstName + " " + middleName; | 790 | fileas = lastName + ", " + firstName + " " + middleName; |
791 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 791 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
792 | fileas = lastName + ", " + firstName; | 792 | fileas = lastName + ", " + firstName; |
793 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 793 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
794 | !middleName.isEmpty() ) | 794 | !middleName.isEmpty() ) |
795 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 795 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
796 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 796 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
797 | + lastName; | 797 | + lastName; |
798 | 798 | ||
799 | replace( Qtopia::FileAs, fileas ); | 799 | replace( Qtopia::FileAs, fileas ); |
800 | } | 800 | } |
801 | 801 | ||
802 | /*! | 802 | /*! |
803 | \internal | 803 | \internal |
804 | Appends the contact information to \a buf. | 804 | Appends the contact information to \a buf. |
805 | */ | 805 | */ |
806 | void OContact::save( QString &buf ) const | 806 | void OContact::save( QString &buf ) const |
807 | { | 807 | { |
808 | static const QStringList SLFIELDS = fields(); | 808 | static const QStringList SLFIELDS = fields(); |
809 | // I'm expecting "<Contact " in front of this... | 809 | // I'm expecting "<Contact " in front of this... |
810 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 810 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
811 | it != mMap.end(); ++it ) { | 811 | it != mMap.end(); ++it ) { |
812 | const QString &value = it.data(); | 812 | const QString &value = it.data(); |
813 | int key = it.key(); | 813 | int key = it.key(); |
814 | if ( !value.isEmpty() ) { | 814 | if ( !value.isEmpty() ) { |
815 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 815 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
816 | continue; | 816 | continue; |
817 | 817 | ||
818 | key -= Qtopia::AddressCategory+1; | 818 | key -= Qtopia::AddressCategory+1; |
819 | buf += SLFIELDS[key]; | 819 | buf += SLFIELDS[key]; |
820 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 820 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
821 | } | 821 | } |
822 | } | 822 | } |
823 | buf += customToXml(); | 823 | buf += customToXml(); |
824 | if ( categories().count() > 0 ) | 824 | if ( categories().count() > 0 ) |
825 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 825 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
826 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 826 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
827 | // You need to close this yourself | 827 | // You need to close this yourself |
828 | } | 828 | } |
829 | 829 | ||
830 | /*! | 830 | /*! |
831 | \internal | 831 | \internal |
832 | Returns the list of fields belonging to a contact | 832 | Returns the list of fields belonging to a contact |
833 | */ | 833 | */ |
834 | QStringList OContact::fields() | 834 | QStringList OContact::fields() |
835 | { | 835 | { |
836 | QStringList list; | 836 | QStringList list; |
837 | 837 | ||
838 | list.append( "Title" ); // Not Used! | 838 | list.append( "Title" ); // Not Used! |
839 | list.append( "FirstName" ); | 839 | list.append( "FirstName" ); |
840 | list.append( "MiddleName" ); | 840 | list.append( "MiddleName" ); |
841 | list.append( "LastName" ); | 841 | list.append( "LastName" ); |
842 | list.append( "Suffix" ); | 842 | list.append( "Suffix" ); |
843 | list.append( "FileAs" ); | 843 | list.append( "FileAs" ); |
844 | 844 | ||
845 | list.append( "JobTitle" ); | 845 | list.append( "JobTitle" ); |
846 | list.append( "Department" ); | 846 | list.append( "Department" ); |
847 | list.append( "Company" ); | 847 | list.append( "Company" ); |
848 | list.append( "BusinessPhone" ); | 848 | list.append( "BusinessPhone" ); |
849 | list.append( "BusinessFax" ); | 849 | list.append( "BusinessFax" ); |
850 | list.append( "BusinessMobile" ); | 850 | list.append( "BusinessMobile" ); |
851 | 851 | ||
852 | list.append( "DefaultEmail" ); | 852 | list.append( "DefaultEmail" ); |
853 | list.append( "Emails" ); | 853 | list.append( "Emails" ); |
854 | 854 | ||
855 | list.append( "HomePhone" ); | 855 | list.append( "HomePhone" ); |
856 | list.append( "HomeFax" ); | 856 | list.append( "HomeFax" ); |
857 | list.append( "HomeMobile" ); | 857 | list.append( "HomeMobile" ); |
858 | 858 | ||
859 | list.append( "BusinessStreet" ); | 859 | list.append( "BusinessStreet" ); |
860 | list.append( "BusinessCity" ); | 860 | list.append( "BusinessCity" ); |
861 | list.append( "BusinessState" ); | 861 | list.append( "BusinessState" ); |
862 | list.append( "BusinessZip" ); | 862 | list.append( "BusinessZip" ); |
863 | list.append( "BusinessCountry" ); | 863 | list.append( "BusinessCountry" ); |
864 | list.append( "BusinessPager" ); | 864 | list.append( "BusinessPager" ); |
865 | list.append( "BusinessWebPage" ); | 865 | list.append( "BusinessWebPage" ); |
866 | 866 | ||
867 | list.append( "Office" ); | 867 | list.append( "Office" ); |
868 | list.append( "Profession" ); | 868 | list.append( "Profession" ); |
869 | list.append( "Assistant" ); | 869 | list.append( "Assistant" ); |
870 | list.append( "Manager" ); | 870 | list.append( "Manager" ); |
871 | 871 | ||
872 | list.append( "HomeStreet" ); | 872 | list.append( "HomeStreet" ); |
873 | list.append( "HomeCity" ); | 873 | list.append( "HomeCity" ); |
874 | list.append( "HomeState" ); | 874 | list.append( "HomeState" ); |
875 | list.append( "HomeZip" ); | 875 | list.append( "HomeZip" ); |
876 | list.append( "HomeCountry" ); | 876 | list.append( "HomeCountry" ); |
877 | list.append( "HomeWebPage" ); | 877 | list.append( "HomeWebPage" ); |
878 | 878 | ||
879 | list.append( "Spouse" ); | 879 | list.append( "Spouse" ); |
880 | list.append( "Gender" ); | 880 | list.append( "Gender" ); |
881 | list.append( "Birthday" ); | 881 | list.append( "Birthday" ); |
882 | list.append( "Anniversary" ); | 882 | list.append( "Anniversary" ); |
883 | list.append( "Nickname" ); | 883 | list.append( "Nickname" ); |
884 | list.append( "Children" ); | 884 | list.append( "Children" ); |
885 | 885 | ||
886 | list.append( "Notes" ); | 886 | list.append( "Notes" ); |
887 | list.append( "Groups" ); | 887 | list.append( "Groups" ); |
888 | 888 | ||
889 | return list; | 889 | return list; |
890 | } | 890 | } |
891 | 891 | ||
892 | /*! | 892 | /*! |
893 | \internal | 893 | \internal |
894 | Returns a translated list of field names for a contact. | 894 | Returns a translated list of field names for a contact. |
895 | */ | 895 | */ |
896 | QStringList OContact::trfields() | 896 | QStringList OContact::trfields() |
897 | { | 897 | { |
898 | QStringList list; | 898 | QStringList list; |
899 | 899 | ||
900 | list.append( QObject::tr( "Name Title") ); | 900 | list.append( QObject::tr( "Name Title") ); |
901 | list.append( QObject::tr( "First Name" ) ); | 901 | list.append( QObject::tr( "First Name" ) ); |
902 | list.append( QObject::tr( "Middle Name" ) ); | 902 | list.append( QObject::tr( "Middle Name" ) ); |
903 | list.append( QObject::tr( "Last Name" ) ); | 903 | list.append( QObject::tr( "Last Name" ) ); |
904 | list.append( QObject::tr( "Suffix" ) ); | 904 | list.append( QObject::tr( "Suffix" ) ); |
905 | list.append( QObject::tr( "File As" ) ); | 905 | list.append( QObject::tr( "File As" ) ); |
906 | 906 | ||
907 | list.append( QObject::tr( "Job Title" ) ); | 907 | list.append( QObject::tr( "Job Title" ) ); |
908 | list.append( QObject::tr( "Department" ) ); | 908 | list.append( QObject::tr( "Department" ) ); |
909 | list.append( QObject::tr( "Company" ) ); | 909 | list.append( QObject::tr( "Company" ) ); |
910 | list.append( QObject::tr( "Business Phone" ) ); | 910 | list.append( QObject::tr( "Business Phone" ) ); |
911 | list.append( QObject::tr( "Business Fax" ) ); | 911 | list.append( QObject::tr( "Business Fax" ) ); |
912 | list.append( QObject::tr( "Business Mobile" ) ); | 912 | list.append( QObject::tr( "Business Mobile" ) ); |
913 | 913 | ||
914 | list.append( QObject::tr( "Default Email" ) ); | 914 | list.append( QObject::tr( "Default Email" ) ); |
915 | list.append( QObject::tr( "Emails" ) ); | 915 | list.append( QObject::tr( "Emails" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Home Phone" ) ); | 917 | list.append( QObject::tr( "Home Phone" ) ); |
918 | list.append( QObject::tr( "Home Fax" ) ); | 918 | list.append( QObject::tr( "Home Fax" ) ); |
919 | list.append( QObject::tr( "Home Mobile" ) ); | 919 | list.append( QObject::tr( "Home Mobile" ) ); |
920 | 920 | ||
921 | list.append( QObject::tr( "Business Street" ) ); | 921 | list.append( QObject::tr( "Business Street" ) ); |
922 | list.append( QObject::tr( "Business City" ) ); | 922 | list.append( QObject::tr( "Business City" ) ); |
923 | list.append( QObject::tr( "Business State" ) ); | 923 | list.append( QObject::tr( "Business State" ) ); |
924 | list.append( QObject::tr( "Business Zip" ) ); | 924 | list.append( QObject::tr( "Business Zip" ) ); |
925 | list.append( QObject::tr( "Business Country" ) ); | 925 | list.append( QObject::tr( "Business Country" ) ); |
926 | list.append( QObject::tr( "Business Pager" ) ); | 926 | list.append( QObject::tr( "Business Pager" ) ); |
927 | list.append( QObject::tr( "Business WebPage" ) ); | 927 | list.append( QObject::tr( "Business WebPage" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Office" ) ); | 929 | list.append( QObject::tr( "Office" ) ); |
930 | list.append( QObject::tr( "Profession" ) ); | 930 | list.append( QObject::tr( "Profession" ) ); |
931 | list.append( QObject::tr( "Assistant" ) ); | 931 | list.append( QObject::tr( "Assistant" ) ); |
932 | list.append( QObject::tr( "Manager" ) ); | 932 | list.append( QObject::tr( "Manager" ) ); |
933 | 933 | ||
934 | list.append( QObject::tr( "Home Street" ) ); | 934 | list.append( QObject::tr( "Home Street" ) ); |
935 | list.append( QObject::tr( "Home City" ) ); | 935 | list.append( QObject::tr( "Home City" ) ); |
936 | list.append( QObject::tr( "Home State" ) ); | 936 | list.append( QObject::tr( "Home State" ) ); |
937 | list.append( QObject::tr( "Home Zip" ) ); | 937 | list.append( QObject::tr( "Home Zip" ) ); |
938 | list.append( QObject::tr( "Home Country" ) ); | 938 | list.append( QObject::tr( "Home Country" ) ); |
939 | list.append( QObject::tr( "Home Web Page" ) ); | 939 | list.append( QObject::tr( "Home Web Page" ) ); |
940 | 940 | ||
941 | list.append( QObject::tr( "Spouse" ) ); | 941 | list.append( QObject::tr( "Spouse" ) ); |
942 | list.append( QObject::tr( "Gender" ) ); | 942 | list.append( QObject::tr( "Gender" ) ); |
943 | list.append( QObject::tr( "Birthday" ) ); | 943 | list.append( QObject::tr( "Birthday" ) ); |
944 | list.append( QObject::tr( "Anniversary" ) ); | 944 | list.append( QObject::tr( "Anniversary" ) ); |
945 | list.append( QObject::tr( "Nickname" ) ); | 945 | list.append( QObject::tr( "Nickname" ) ); |
946 | list.append( QObject::tr( "Children" ) ); | 946 | list.append( QObject::tr( "Children" ) ); |
947 | 947 | ||
948 | list.append( QObject::tr( "Notes" ) ); | 948 | list.append( QObject::tr( "Notes" ) ); |
949 | list.append( QObject::tr( "Groups" ) ); | 949 | list.append( QObject::tr( "Groups" ) ); |
950 | 950 | ||
951 | return list; | 951 | return list; |
952 | } | 952 | } |
953 | 953 | ||
954 | /*! | 954 | /*! |
955 | \internal | ||
956 | Returns an untranslated list of field names for a contact. | ||
957 | */ | ||
958 | QStringList OContact::untrfields() | ||
959 | { | ||
960 | QStringList list; | ||
961 | |||
962 | list.append( "Name Title" ); | ||
963 | list.append( "First Name" ); | ||
964 | list.append( "Middle Name" ); | ||
965 | list.append( "Last Name" ); | ||
966 | list.append( "Suffix" ); | ||
967 | list.append( "File As" ); | ||
968 | |||
969 | list.append( "Job Title" ); | ||
970 | list.append( "Department" ); | ||
971 | list.append( "Company" ); | ||
972 | list.append( "Business Phone" ); | ||
973 | list.append( "Business Fax" ); | ||
974 | list.append( "Business Mobile" ); | ||
975 | |||
976 | list.append( "Default Email" ); | ||
977 | list.append( "Emails" ); | ||
978 | |||
979 | list.append( "Home Phone" ); | ||
980 | list.append( "Home Fax" ); | ||
981 | list.append( "Home Mobile" ); | ||
982 | |||
983 | list.append( "Business Street" ); | ||
984 | list.append( "Business City" ); | ||
985 | list.append( "Business State" ); | ||
986 | list.append( "Business Zip" ); | ||
987 | list.append( "Business Country" ); | ||
988 | list.append( "Business Pager" ); | ||
989 | list.append( "Business WebPage" ); | ||
990 | |||
991 | list.append( "Office" ); | ||
992 | list.append( "Profession" ); | ||
993 | list.append( "Assistant" ); | ||
994 | list.append( "Manager" ); | ||
995 | |||
996 | list.append( "Home Street" ); | ||
997 | list.append( "Home City" ); | ||
998 | list.append( "Home State" ); | ||
999 | list.append( "Home Zip" ); | ||
1000 | list.append( "Home Country" ); | ||
1001 | list.append( "Home Web Page" ); | ||
1002 | |||
1003 | list.append( "Spouse" ); | ||
1004 | list.append( "Gender" ); | ||
1005 | list.append( "Birthday" ); | ||
1006 | list.append( "Anniversary" ); | ||
1007 | list.append( "Nickname" ); | ||
1008 | list.append( "Children" ); | ||
1009 | |||
1010 | list.append( "Notes" ); | ||
1011 | list.append( "Groups" ); | ||
1012 | |||
1013 | return list; | ||
1014 | } | ||
1015 | |||
1016 | /*! | ||
955 | Sets the list of email address for contact to those contained in \a str. | 1017 | Sets the list of email address for contact to those contained in \a str. |
956 | Email address should be separated by ';'s. | 1018 | Email address should be separated by ';'s. |
957 | */ | 1019 | */ |
958 | void OContact::setEmails( const QString &str ) | 1020 | void OContact::setEmails( const QString &str ) |
959 | { | 1021 | { |
960 | replace( Qtopia::Emails, str ); | 1022 | replace( Qtopia::Emails, str ); |
961 | if ( str.isEmpty() ) | 1023 | if ( str.isEmpty() ) |
962 | setDefaultEmail( QString::null ); | 1024 | setDefaultEmail( QString::null ); |
963 | } | 1025 | } |
964 | 1026 | ||
965 | /*! | 1027 | /*! |
966 | Sets the list of children for the contact to those contained in \a str. | 1028 | Sets the list of children for the contact to those contained in \a str. |
967 | */ | 1029 | */ |
968 | void OContact::setChildren( const QString &str ) | 1030 | void OContact::setChildren( const QString &str ) |
969 | { | 1031 | { |
970 | replace( Qtopia::Children, str ); | 1032 | replace( Qtopia::Children, str ); |
971 | } | 1033 | } |
972 | 1034 | ||
973 | // vcard conversion code | 1035 | // vcard conversion code |
974 | /*! | 1036 | /*! |
975 | \internal | 1037 | \internal |
976 | */ | 1038 | */ |
977 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1039 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
978 | { | 1040 | { |
979 | VObject *ret = 0; | 1041 | VObject *ret = 0; |
980 | if ( o && !value.isEmpty() ) | 1042 | if ( o && !value.isEmpty() ) |
981 | ret = addPropValue( o, prop, value.latin1() ); | 1043 | ret = addPropValue( o, prop, value.latin1() ); |
982 | return ret; | 1044 | return ret; |
983 | } | 1045 | } |
984 | 1046 | ||
985 | /*! | 1047 | /*! |
986 | \internal | 1048 | \internal |
987 | */ | 1049 | */ |
988 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1050 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
989 | { | 1051 | { |
990 | VObject *ret = 0; | 1052 | VObject *ret = 0; |
991 | if ( o ) | 1053 | if ( o ) |
992 | ret = addProp( o, prop ); | 1054 | ret = addProp( o, prop ); |
993 | return ret; | 1055 | return ret; |
994 | } | 1056 | } |
995 | 1057 | ||
996 | /*! | 1058 | /*! |
997 | \internal | 1059 | \internal |
998 | */ | 1060 | */ |
999 | static VObject *createVObject( const OContact &c ) | 1061 | static VObject *createVObject( const OContact &c ) |
1000 | { | 1062 | { |
1001 | VObject *vcard = newVObject( VCCardProp ); | 1063 | VObject *vcard = newVObject( VCCardProp ); |
1002 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1064 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1003 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1065 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1004 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1066 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1005 | 1067 | ||
1006 | // full name | 1068 | // full name |
1007 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1069 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1008 | 1070 | ||
1009 | // name properties | 1071 | // name properties |
1010 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1072 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1011 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1073 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1012 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1074 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1013 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1075 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1014 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1076 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1015 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1077 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1016 | 1078 | ||
1017 | // home properties | 1079 | // home properties |
1018 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1080 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1019 | safeAddProp( home_adr, VCHomeProp ); | 1081 | safeAddProp( home_adr, VCHomeProp ); |
1020 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1082 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1021 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1083 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1022 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1084 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1023 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1085 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1024 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1086 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1025 | 1087 | ||
1026 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1088 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1027 | safeAddProp( home_phone, VCHomeProp ); | 1089 | safeAddProp( home_phone, VCHomeProp ); |
1028 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1090 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1029 | safeAddProp( home_phone, VCHomeProp ); | 1091 | safeAddProp( home_phone, VCHomeProp ); |
1030 | safeAddProp( home_phone, VCCellularProp ); | 1092 | safeAddProp( home_phone, VCCellularProp ); |
1031 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1093 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1032 | safeAddProp( home_phone, VCHomeProp ); | 1094 | safeAddProp( home_phone, VCHomeProp ); |
1033 | safeAddProp( home_phone, VCFaxProp ); | 1095 | safeAddProp( home_phone, VCFaxProp ); |
1034 | 1096 | ||
1035 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1097 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1036 | safeAddProp( url, VCHomeProp ); | 1098 | safeAddProp( url, VCHomeProp ); |
1037 | 1099 | ||
1038 | // work properties | 1100 | // work properties |
1039 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1101 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1040 | safeAddProp( work_adr, VCWorkProp ); | 1102 | safeAddProp( work_adr, VCWorkProp ); |
1041 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1103 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1042 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1104 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1043 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1105 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1044 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1106 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1045 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1107 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1046 | 1108 | ||
1047 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1109 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1048 | safeAddProp( work_phone, VCWorkProp ); | 1110 | safeAddProp( work_phone, VCWorkProp ); |
1049 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1111 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1050 | safeAddProp( work_phone, VCWorkProp ); | 1112 | safeAddProp( work_phone, VCWorkProp ); |
1051 | safeAddProp( work_phone, VCCellularProp ); | 1113 | safeAddProp( work_phone, VCCellularProp ); |
1052 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1114 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1053 | safeAddProp( work_phone, VCWorkProp ); | 1115 | safeAddProp( work_phone, VCWorkProp ); |
1054 | safeAddProp( work_phone, VCFaxProp ); | 1116 | safeAddProp( work_phone, VCFaxProp ); |
1055 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1117 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1056 | safeAddProp( work_phone, VCWorkProp ); | 1118 | safeAddProp( work_phone, VCWorkProp ); |
1057 | safeAddProp( work_phone, VCPagerProp ); | 1119 | safeAddProp( work_phone, VCPagerProp ); |
1058 | 1120 | ||
1059 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1121 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1060 | safeAddProp( url, VCWorkProp ); | 1122 | safeAddProp( url, VCWorkProp ); |
1061 | 1123 | ||
1062 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1124 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1063 | safeAddProp( title, VCWorkProp ); | 1125 | safeAddProp( title, VCWorkProp ); |
1064 | 1126 | ||
1065 | 1127 | ||
1066 | QStringList emails = c.emailList(); | 1128 | QStringList emails = c.emailList(); |
1067 | emails.prepend( c.defaultEmail() ); | 1129 | emails.prepend( c.defaultEmail() ); |
1068 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1130 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1069 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1131 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1070 | safeAddProp( email, VCInternetProp ); | 1132 | safeAddProp( email, VCInternetProp ); |
1071 | } | 1133 | } |
1072 | 1134 | ||
1073 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1135 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1074 | 1136 | ||
1075 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); |
1076 | 1138 | ||
1077 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1139 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1078 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1140 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1079 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1141 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1080 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1142 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1081 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1143 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1082 | } | 1144 | } |
1083 | 1145 | ||
1084 | // some values we have to export as custom fields | 1146 | // some values we have to export as custom fields |
1085 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1147 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1086 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1087 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1149 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1088 | 1150 | ||
1089 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1151 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1090 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1152 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1091 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); | 1153 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); |
1092 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1154 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1093 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1155 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1094 | 1156 | ||
1095 | return vcard; | 1157 | return vcard; |
1096 | } | 1158 | } |
1097 | 1159 | ||
1098 | 1160 | ||
1099 | /*! | 1161 | /*! |
1100 | \internal | 1162 | \internal |
1101 | */ | 1163 | */ |
1102 | static OContact parseVObject( VObject *obj ) | 1164 | static OContact parseVObject( VObject *obj ) |
1103 | { | 1165 | { |
1104 | OContact c; | 1166 | OContact c; |
1105 | 1167 | ||
1106 | VObjectIterator it; | 1168 | VObjectIterator it; |
1107 | initPropIterator( &it, obj ); | 1169 | initPropIterator( &it, obj ); |
1108 | while( moreIteration( &it ) ) { | 1170 | while( moreIteration( &it ) ) { |
1109 | VObject *o = nextVObject( &it ); | 1171 | VObject *o = nextVObject( &it ); |
1110 | QCString name = vObjectName( o ); | 1172 | QCString name = vObjectName( o ); |
1111 | QCString value = vObjectStringZValue( o ); | 1173 | QCString value = vObjectStringZValue( o ); |
1112 | if ( name == VCNameProp ) { | 1174 | if ( name == VCNameProp ) { |
1113 | VObjectIterator nit; | 1175 | VObjectIterator nit; |
1114 | initPropIterator( &nit, o ); | 1176 | initPropIterator( &nit, o ); |
1115 | while( moreIteration( &nit ) ) { | 1177 | while( moreIteration( &nit ) ) { |
1116 | VObject *o = nextVObject( &nit ); | 1178 | VObject *o = nextVObject( &nit ); |
1117 | QCString name = vObjectTypeInfo( o ); | 1179 | QCString name = vObjectTypeInfo( o ); |
1118 | QString value = vObjectStringZValue( o ); | 1180 | QString value = vObjectStringZValue( o ); |
1119 | if ( name == VCNamePrefixesProp ) | 1181 | if ( name == VCNamePrefixesProp ) |
1120 | c.setTitle( value ); | 1182 | c.setTitle( value ); |
1121 | else if ( name == VCNameSuffixesProp ) | 1183 | else if ( name == VCNameSuffixesProp ) |
1122 | c.setSuffix( value ); | 1184 | c.setSuffix( value ); |
1123 | else if ( name == VCFamilyNameProp ) | 1185 | else if ( name == VCFamilyNameProp ) |
1124 | c.setLastName( value ); | 1186 | c.setLastName( value ); |
1125 | else if ( name == VCGivenNameProp ) | 1187 | else if ( name == VCGivenNameProp ) |
1126 | c.setFirstName( value ); | 1188 | c.setFirstName( value ); |
1127 | else if ( name == VCAdditionalNamesProp ) | 1189 | else if ( name == VCAdditionalNamesProp ) |
1128 | c.setMiddleName( value ); | 1190 | c.setMiddleName( value ); |
1129 | } | 1191 | } |
1130 | } | 1192 | } |
1131 | else if ( name == VCAdrProp ) { | 1193 | else if ( name == VCAdrProp ) { |
1132 | bool work = TRUE; // default address is work address | 1194 | bool work = TRUE; // default address is work address |
1133 | QString street; | 1195 | QString street; |
1134 | QString city; | 1196 | QString city; |
1135 | QString region; | 1197 | QString region; |
1136 | QString postal; | 1198 | QString postal; |
1137 | QString country; | 1199 | QString country; |
1138 | 1200 | ||
1139 | VObjectIterator nit; | 1201 | VObjectIterator nit; |
1140 | initPropIterator( &nit, o ); | 1202 | initPropIterator( &nit, o ); |
1141 | while( moreIteration( &nit ) ) { | 1203 | while( moreIteration( &nit ) ) { |
1142 | VObject *o = nextVObject( &nit ); | 1204 | VObject *o = nextVObject( &nit ); |
1143 | QCString name = vObjectName( o ); | 1205 | QCString name = vObjectName( o ); |
1144 | QString value = vObjectStringZValue( o ); | 1206 | QString value = vObjectStringZValue( o ); |
1145 | if ( name == VCHomeProp ) | 1207 | if ( name == VCHomeProp ) |
1146 | work = FALSE; | 1208 | work = FALSE; |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 756c87d..f916cf2 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -1,314 +1,315 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __OCONTACT_H__ | 21 | #ifndef __OCONTACT_H__ |
22 | #define __OCONTACT_H__ | 22 | #define __OCONTACT_H__ |
23 | 23 | ||
24 | #include <opie/opimrecord.h> | 24 | #include <opie/opimrecord.h> |
25 | #include <qpe/recordfields.h> | 25 | #include <qpe/recordfields.h> |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) | 35 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) |
36 | class QPC_EXPORT OContact : public OPimRecord | 36 | class QPC_EXPORT OContact : public OPimRecord |
37 | { | 37 | { |
38 | friend class DataSet; | 38 | friend class DataSet; |
39 | public: | 39 | public: |
40 | OContact(); | 40 | OContact(); |
41 | OContact( const QMap<int, QString> &fromMap ); | 41 | OContact( const QMap<int, QString> &fromMap ); |
42 | virtual ~OContact(); | 42 | virtual ~OContact(); |
43 | 43 | ||
44 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); | 44 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); |
45 | static void writeVCard( const QString &filename, const OContact &c ); | 45 | static void writeVCard( const QString &filename, const OContact &c ); |
46 | static QValueList<OContact> readVCard( const QString &filename ); | 46 | static QValueList<OContact> readVCard( const QString &filename ); |
47 | 47 | ||
48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
49 | 49 | ||
50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
56 | void setFileAs(); | 56 | void setFileAs(); |
57 | 57 | ||
58 | // default email address | 58 | // default email address |
59 | void setDefaultEmail( const QString &v ); | 59 | void setDefaultEmail( const QString &v ); |
60 | // inserts email to list and ensure's doesn't already exist | 60 | // inserts email to list and ensure's doesn't already exist |
61 | void insertEmail( const QString &v ); | 61 | void insertEmail( const QString &v ); |
62 | void removeEmail( const QString &v ); | 62 | void removeEmail( const QString &v ); |
63 | void clearEmails(); | 63 | void clearEmails(); |
64 | void insertEmails( const QStringList &v ); | 64 | void insertEmails( const QStringList &v ); |
65 | 65 | ||
66 | // home | 66 | // home |
67 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 67 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
68 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 68 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
69 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 69 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
70 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 70 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
71 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 71 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
72 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 72 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
73 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 73 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
74 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 74 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
75 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 75 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
76 | 76 | ||
77 | // business | 77 | // business |
78 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 78 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
79 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 79 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
80 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 80 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
81 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 81 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
82 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 82 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
83 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 83 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
84 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 84 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
85 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 85 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
86 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 86 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
87 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 87 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
88 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 88 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
89 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 89 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
90 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 90 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
91 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 91 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
92 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 92 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
93 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 93 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
94 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 94 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
95 | 95 | ||
96 | // personal | 96 | // personal |
97 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 97 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
98 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 98 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
99 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } | 99 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } |
100 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } | 100 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } |
101 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 101 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
102 | void setChildren( const QString &v ); | 102 | void setChildren( const QString &v ); |
103 | 103 | ||
104 | // other | 104 | // other |
105 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 105 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
106 | 106 | ||
107 | bool match( const QString ®exp ) const; | 107 | bool match( const QString ®exp ) const; |
108 | 108 | ||
109 | // DON'T ATTEMPT TO USE THIS | 109 | // DON'T ATTEMPT TO USE THIS |
110 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | 110 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE |
111 | bool match( const QRegExp ®exp ) const; | 111 | bool match( const QRegExp ®exp ) const; |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | // // custom | 114 | // // custom |
115 | // void setCustomField( const QString &key, const QString &v ) | 115 | // void setCustomField( const QString &key, const QString &v ) |
116 | // { replace(Custom- + key, v ); } | 116 | // { replace(Custom- + key, v ); } |
117 | 117 | ||
118 | // name | 118 | // name |
119 | QString fullName() const; | 119 | QString fullName() const; |
120 | QString title() const { return find( Qtopia::Title ); } | 120 | QString title() const { return find( Qtopia::Title ); } |
121 | QString firstName() const { return find( Qtopia::FirstName ); } | 121 | QString firstName() const { return find( Qtopia::FirstName ); } |
122 | QString middleName() const { return find( Qtopia::MiddleName ); } | 122 | QString middleName() const { return find( Qtopia::MiddleName ); } |
123 | QString lastName() const { return find( Qtopia::LastName ); } | 123 | QString lastName() const { return find( Qtopia::LastName ); } |
124 | QString suffix() const { return find( Qtopia::Suffix ); } | 124 | QString suffix() const { return find( Qtopia::Suffix ); } |
125 | QString fileAs() const { return find( Qtopia::FileAs ); } | 125 | QString fileAs() const { return find( Qtopia::FileAs ); } |
126 | 126 | ||
127 | 127 | ||
128 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 128 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
129 | QStringList emailList() const; | 129 | QStringList emailList() const; |
130 | 130 | ||
131 | // home | 131 | // home |
132 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 132 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
133 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 133 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
134 | QString homeState() const { return find( Qtopia::HomeState ); } | 134 | QString homeState() const { return find( Qtopia::HomeState ); } |
135 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 135 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
136 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 136 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
137 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 137 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
138 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 138 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
139 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 139 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
140 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 140 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
141 | /** Multi line string containing all non-empty address info in the form | 141 | /** Multi line string containing all non-empty address info in the form |
142 | * Street | 142 | * Street |
143 | * City, State Zip | 143 | * City, State Zip |
144 | * Country | 144 | * Country |
145 | */ | 145 | */ |
146 | QString displayHomeAddress() const; | 146 | QString displayHomeAddress() const; |
147 | 147 | ||
148 | // business | 148 | // business |
149 | QString company() const { return find( Qtopia::Company ); } | 149 | QString company() const { return find( Qtopia::Company ); } |
150 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 150 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
151 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 151 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
152 | QString businessState() const { return find( Qtopia::BusinessState ); } | 152 | QString businessState() const { return find( Qtopia::BusinessState ); } |
153 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 153 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
154 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 154 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
155 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 155 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
156 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 156 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
157 | QString department() const { return find( Qtopia::Department ); } | 157 | QString department() const { return find( Qtopia::Department ); } |
158 | QString office() const { return find( Qtopia::Office ); } | 158 | QString office() const { return find( Qtopia::Office ); } |
159 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 159 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
160 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 160 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
161 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 161 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
162 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 162 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
163 | QString profession() const { return find( Qtopia::Profession ); } | 163 | QString profession() const { return find( Qtopia::Profession ); } |
164 | QString assistant() const { return find( Qtopia::Assistant ); } | 164 | QString assistant() const { return find( Qtopia::Assistant ); } |
165 | QString manager() const { return find( Qtopia::Manager ); } | 165 | QString manager() const { return find( Qtopia::Manager ); } |
166 | /** Multi line string containing all non-empty address info in the form | 166 | /** Multi line string containing all non-empty address info in the form |
167 | * Street | 167 | * Street |
168 | * City, State Zip | 168 | * City, State Zip |
169 | * Country | 169 | * Country |
170 | */ | 170 | */ |
171 | QString displayBusinessAddress() const; | 171 | QString displayBusinessAddress() const; |
172 | 172 | ||
173 | //personal | 173 | //personal |
174 | QString spouse() const { return find( Qtopia::Spouse ); } | 174 | QString spouse() const { return find( Qtopia::Spouse ); } |
175 | QString gender() const { return find( Qtopia::Gender ); } | 175 | QString gender() const { return find( Qtopia::Gender ); } |
176 | QString birthday() const { return find( Qtopia::Birthday ); } | 176 | QString birthday() const { return find( Qtopia::Birthday ); } |
177 | QString anniversary() const { return find( Qtopia::Anniversary ); } | 177 | QString anniversary() const { return find( Qtopia::Anniversary ); } |
178 | QString nickname() const { return find( Qtopia::Nickname ); } | 178 | QString nickname() const { return find( Qtopia::Nickname ); } |
179 | QString children() const { return find( Qtopia::Children ); } | 179 | QString children() const { return find( Qtopia::Children ); } |
180 | QStringList childrenList() const; | 180 | QStringList childrenList() const; |
181 | 181 | ||
182 | // other | 182 | // other |
183 | QString notes() const { return find( Qtopia::Notes ); } | 183 | QString notes() const { return find( Qtopia::Notes ); } |
184 | QString groups() const { return find( Qtopia::Groups ); } | 184 | QString groups() const { return find( Qtopia::Groups ); } |
185 | QStringList groupList() const; | 185 | QStringList groupList() const; |
186 | 186 | ||
187 | // // custom | 187 | // // custom |
188 | // const QString &customField( const QString &key ) | 188 | // const QString &customField( const QString &key ) |
189 | // { return find( Custom- + key ); } | 189 | // { return find( Custom- + key ); } |
190 | 190 | ||
191 | static QStringList fields(); | 191 | static QStringList fields(); |
192 | static QStringList trfields(); | 192 | static QStringList trfields(); |
193 | static QStringList untrfields(); | ||
193 | 194 | ||
194 | QString toRichText() const; | 195 | QString toRichText() const; |
195 | QMap<int, QString> toMap() const; | 196 | QMap<int, QString> toMap() const; |
196 | QString field( int key ) const { return find( key ); } | 197 | QString field( int key ) const { return find( key ); } |
197 | 198 | ||
198 | 199 | ||
199 | // journaling... | 200 | // journaling... |
200 | void saveJournal( journal_action action, const QString &key = QString::null ); | 201 | void saveJournal( journal_action action, const QString &key = QString::null ); |
201 | void save( QString &buf ) const; | 202 | void save( QString &buf ) const; |
202 | 203 | ||
203 | void setUid( int i ) | 204 | void setUid( int i ) |
204 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 205 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
205 | 206 | ||
206 | QString toShortText()const; | 207 | QString toShortText()const; |
207 | QString OContact::type()const; | 208 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 209 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 210 | class QString OContact::recordField(int) const; |
210 | 211 | ||
211 | // Why private ? (eilers,se) | 212 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 213 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 214 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 215 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 216 | QString emails() const { return find( Qtopia::Emails ); } |
216 | 217 | ||
217 | 218 | ||
218 | private: | 219 | private: |
219 | friend class AbEditor; | 220 | friend class AbEditor; |
220 | friend class AbTable; | 221 | friend class AbTable; |
221 | friend class AddressBookAccessPrivate; | 222 | friend class AddressBookAccessPrivate; |
222 | friend class XMLIO; | 223 | friend class XMLIO; |
223 | 224 | ||
224 | 225 | ||
225 | void insert( int key, const QString &value ); | 226 | void insert( int key, const QString &value ); |
226 | void replace( int key, const QString &value ); | 227 | void replace( int key, const QString &value ); |
227 | QString find( int key ) const; | 228 | QString find( int key ) const; |
228 | 229 | ||
229 | QString displayAddress( const QString &street, | 230 | QString displayAddress( const QString &street, |
230 | const QString &city, | 231 | const QString &city, |
231 | const QString &state, | 232 | const QString &state, |
232 | const QString &zip, | 233 | const QString &zip, |
233 | const QString &country ) const; | 234 | const QString &country ) const; |
234 | 235 | ||
235 | Qtopia::UidGen &uidGen() { return sUidGen; } | 236 | Qtopia::UidGen &uidGen() { return sUidGen; } |
236 | static Qtopia::UidGen sUidGen; | 237 | static Qtopia::UidGen sUidGen; |
237 | QMap<int, QString> mMap; | 238 | QMap<int, QString> mMap; |
238 | ContactPrivate *d; | 239 | ContactPrivate *d; |
239 | }; | 240 | }; |
240 | 241 | ||
241 | // these methods are inlined to keep binary compatability with Qtopia 1.5 | 242 | // these methods are inlined to keep binary compatability with Qtopia 1.5 |
242 | inline void OContact::insertEmail( const QString &v ) | 243 | inline void OContact::insertEmail( const QString &v ) |
243 | { | 244 | { |
244 | //qDebug("insertEmail %s", v.latin1()); | 245 | //qDebug("insertEmail %s", v.latin1()); |
245 | QString e = v.simplifyWhiteSpace(); | 246 | QString e = v.simplifyWhiteSpace(); |
246 | QString def = defaultEmail(); | 247 | QString def = defaultEmail(); |
247 | 248 | ||
248 | // if no default, set it as the default email and don't insert | 249 | // if no default, set it as the default email and don't insert |
249 | if ( def.isEmpty() ) { | 250 | if ( def.isEmpty() ) { |
250 | setDefaultEmail( e ); // will insert into the list for us | 251 | setDefaultEmail( e ); // will insert into the list for us |
251 | return; | 252 | return; |
252 | } | 253 | } |
253 | 254 | ||
254 | // otherwise, insert assuming doesn't already exist | 255 | // otherwise, insert assuming doesn't already exist |
255 | QString emailsStr = find( Qtopia::Emails ); | 256 | QString emailsStr = find( Qtopia::Emails ); |
256 | if ( emailsStr.contains( e )) | 257 | if ( emailsStr.contains( e )) |
257 | return; | 258 | return; |
258 | if ( !emailsStr.isEmpty() ) | 259 | if ( !emailsStr.isEmpty() ) |
259 | emailsStr += emailSeparator(); | 260 | emailsStr += emailSeparator(); |
260 | emailsStr += e; | 261 | emailsStr += e; |
261 | replace( Qtopia::Emails, emailsStr ); | 262 | replace( Qtopia::Emails, emailsStr ); |
262 | } | 263 | } |
263 | 264 | ||
264 | inline void OContact::removeEmail( const QString &v ) | 265 | inline void OContact::removeEmail( const QString &v ) |
265 | { | 266 | { |
266 | QString e = v.simplifyWhiteSpace(); | 267 | QString e = v.simplifyWhiteSpace(); |
267 | QString def = defaultEmail(); | 268 | QString def = defaultEmail(); |
268 | QString emailsStr = find( Qtopia::Emails ); | 269 | QString emailsStr = find( Qtopia::Emails ); |
269 | QStringList emails = emailList(); | 270 | QStringList emails = emailList(); |
270 | 271 | ||
271 | // otherwise, must first contain it | 272 | // otherwise, must first contain it |
272 | if ( !emailsStr.contains( e ) ) | 273 | if ( !emailsStr.contains( e ) ) |
273 | return; | 274 | return; |
274 | 275 | ||
275 | // remove it | 276 | // remove it |
276 | //qDebug(" removing email from list %s", e.latin1()); | 277 | //qDebug(" removing email from list %s", e.latin1()); |
277 | emails.remove( e ); | 278 | emails.remove( e ); |
278 | // reset the string | 279 | // reset the string |
279 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 280 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
280 | replace( Qtopia::Emails, emailsStr ); | 281 | replace( Qtopia::Emails, emailsStr ); |
281 | 282 | ||
282 | // if default, then replace the default email with the first one | 283 | // if default, then replace the default email with the first one |
283 | if ( def == e ) { | 284 | if ( def == e ) { |
284 | //qDebug("removeEmail is default; setting new default"); | 285 | //qDebug("removeEmail is default; setting new default"); |
285 | if ( !emails.count() ) | 286 | if ( !emails.count() ) |
286 | clearEmails(); | 287 | clearEmails(); |
287 | else // setDefaultEmail will remove e from the list | 288 | else // setDefaultEmail will remove e from the list |
288 | setDefaultEmail( emails.first() ); | 289 | setDefaultEmail( emails.first() ); |
289 | } | 290 | } |
290 | } | 291 | } |
291 | inline void OContact::clearEmails() | 292 | inline void OContact::clearEmails() |
292 | { | 293 | { |
293 | mMap.remove( Qtopia::DefaultEmail ); | 294 | mMap.remove( Qtopia::DefaultEmail ); |
294 | mMap.remove( Qtopia::Emails ); | 295 | mMap.remove( Qtopia::Emails ); |
295 | } | 296 | } |
296 | inline void OContact::setDefaultEmail( const QString &v ) | 297 | inline void OContact::setDefaultEmail( const QString &v ) |
297 | { | 298 | { |
298 | QString e = v.simplifyWhiteSpace(); | 299 | QString e = v.simplifyWhiteSpace(); |
299 | 300 | ||
300 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 301 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
301 | replace( Qtopia::DefaultEmail, e ); | 302 | replace( Qtopia::DefaultEmail, e ); |
302 | 303 | ||
303 | if ( !e.isEmpty() ) | 304 | if ( !e.isEmpty() ) |
304 | insertEmail( e ); | 305 | insertEmail( e ); |
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
308 | inline void OContact::insertEmails( const QStringList &v ) | 309 | inline void OContact::insertEmails( const QStringList &v ) |
309 | { | 310 | { |
310 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 311 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
311 | insertEmail( *it ); | 312 | insertEmail( *it ); |
312 | } | 313 | } |
313 | 314 | ||
314 | #endif | 315 | #endif |