-rw-r--r-- | libopie/pim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 5 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 5 |
4 files changed, 10 insertions, 2 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index a38b62b..aeb69ee 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -833,256 +833,257 @@ void OContact::setFileAs() | |||
833 | replace( Qtopia::FileAs, fileas ); | 833 | replace( Qtopia::FileAs, fileas ); |
834 | } | 834 | } |
835 | 835 | ||
836 | /*! | 836 | /*! |
837 | \internal | 837 | \internal |
838 | Appends the contact information to \a buf. | 838 | Appends the contact information to \a buf. |
839 | */ | 839 | */ |
840 | void OContact::save( QString &buf ) const | 840 | void OContact::save( QString &buf ) const |
841 | { | 841 | { |
842 | static const QStringList SLFIELDS = fields(); | 842 | static const QStringList SLFIELDS = fields(); |
843 | // I'm expecting "<Contact " in front of this... | 843 | // I'm expecting "<Contact " in front of this... |
844 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 844 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
845 | it != mMap.end(); ++it ) { | 845 | it != mMap.end(); ++it ) { |
846 | const QString &value = it.data(); | 846 | const QString &value = it.data(); |
847 | int key = it.key(); | 847 | int key = it.key(); |
848 | if ( !value.isEmpty() ) { | 848 | if ( !value.isEmpty() ) { |
849 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 849 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
850 | continue; | 850 | continue; |
851 | 851 | ||
852 | key -= Qtopia::AddressCategory+1; | 852 | key -= Qtopia::AddressCategory+1; |
853 | buf += SLFIELDS[key]; | 853 | buf += SLFIELDS[key]; |
854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
855 | } | 855 | } |
856 | } | 856 | } |
857 | buf += customToXml(); | 857 | buf += customToXml(); |
858 | if ( categories().count() > 0 ) | 858 | if ( categories().count() > 0 ) |
859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
861 | // You need to close this yourself | 861 | // You need to close this yourself |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | /*! | 865 | /*! |
866 | \internal | 866 | \internal |
867 | Returns the list of fields belonging to a contact | 867 | Returns the list of fields belonging to a contact |
868 | Never change order of this list ! It has to be regarding | 868 | Never change order of this list ! It has to be regarding |
869 | enum AddressBookFields !! | 869 | enum AddressBookFields !! |
870 | */ | 870 | */ |
871 | QStringList OContact::fields() | 871 | QStringList OContact::fields() |
872 | { | 872 | { |
873 | QStringList list; | 873 | QStringList list; |
874 | 874 | ||
875 | list.append( "Title" ); // Not Used! | 875 | list.append( "Title" ); // Not Used! |
876 | list.append( "FirstName" ); | 876 | list.append( "FirstName" ); |
877 | list.append( "MiddleName" ); | 877 | list.append( "MiddleName" ); |
878 | list.append( "LastName" ); | 878 | list.append( "LastName" ); |
879 | list.append( "Suffix" ); | 879 | list.append( "Suffix" ); |
880 | list.append( "FileAs" ); | 880 | list.append( "FileAs" ); |
881 | 881 | ||
882 | list.append( "JobTitle" ); | 882 | list.append( "JobTitle" ); |
883 | list.append( "Department" ); | 883 | list.append( "Department" ); |
884 | list.append( "Company" ); | 884 | list.append( "Company" ); |
885 | list.append( "BusinessPhone" ); | 885 | list.append( "BusinessPhone" ); |
886 | list.append( "BusinessFax" ); | 886 | list.append( "BusinessFax" ); |
887 | list.append( "BusinessMobile" ); | 887 | list.append( "BusinessMobile" ); |
888 | 888 | ||
889 | list.append( "DefaultEmail" ); | 889 | list.append( "DefaultEmail" ); |
890 | list.append( "Emails" ); | 890 | list.append( "Emails" ); |
891 | 891 | ||
892 | list.append( "HomePhone" ); | 892 | list.append( "HomePhone" ); |
893 | list.append( "HomeFax" ); | 893 | list.append( "HomeFax" ); |
894 | list.append( "HomeMobile" ); | 894 | list.append( "HomeMobile" ); |
895 | 895 | ||
896 | list.append( "BusinessStreet" ); | 896 | list.append( "BusinessStreet" ); |
897 | list.append( "BusinessCity" ); | 897 | list.append( "BusinessCity" ); |
898 | list.append( "BusinessState" ); | 898 | list.append( "BusinessState" ); |
899 | list.append( "BusinessZip" ); | 899 | list.append( "BusinessZip" ); |
900 | list.append( "BusinessCountry" ); | 900 | list.append( "BusinessCountry" ); |
901 | list.append( "BusinessPager" ); | 901 | list.append( "BusinessPager" ); |
902 | list.append( "BusinessWebPage" ); | 902 | list.append( "BusinessWebPage" ); |
903 | 903 | ||
904 | list.append( "Office" ); | 904 | list.append( "Office" ); |
905 | list.append( "Profession" ); | 905 | list.append( "Profession" ); |
906 | list.append( "Assistant" ); | 906 | list.append( "Assistant" ); |
907 | list.append( "Manager" ); | 907 | list.append( "Manager" ); |
908 | 908 | ||
909 | list.append( "HomeStreet" ); | 909 | list.append( "HomeStreet" ); |
910 | list.append( "HomeCity" ); | 910 | list.append( "HomeCity" ); |
911 | list.append( "HomeState" ); | 911 | list.append( "HomeState" ); |
912 | list.append( "HomeZip" ); | 912 | list.append( "HomeZip" ); |
913 | list.append( "HomeCountry" ); | 913 | list.append( "HomeCountry" ); |
914 | list.append( "HomeWebPage" ); | 914 | list.append( "HomeWebPage" ); |
915 | 915 | ||
916 | list.append( "Spouse" ); | 916 | list.append( "Spouse" ); |
917 | list.append( "Gender" ); | 917 | list.append( "Gender" ); |
918 | list.append( "Birthday" ); | 918 | list.append( "Birthday" ); |
919 | list.append( "Anniversary" ); | 919 | list.append( "Anniversary" ); |
920 | list.append( "Nickname" ); | 920 | list.append( "Nickname" ); |
921 | list.append( "Children" ); | 921 | list.append( "Children" ); |
922 | 922 | ||
923 | list.append( "Notes" ); | 923 | list.append( "Notes" ); |
924 | list.append( "Groups" ); | 924 | list.append( "Groups" ); |
925 | 925 | ||
926 | return list; | 926 | return list; |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | /*! | 930 | /*! |
931 | Sets the list of email address for contact to those contained in \a str. | 931 | Sets the list of email address for contact to those contained in \a str. |
932 | Email address should be separated by ';'s. | 932 | Email address should be separated by ';'s. |
933 | */ | 933 | */ |
934 | void OContact::setEmails( const QString &str ) | 934 | void OContact::setEmails( const QString &str ) |
935 | { | 935 | { |
936 | replace( Qtopia::Emails, str ); | 936 | replace( Qtopia::Emails, str ); |
937 | if ( str.isEmpty() ) | 937 | if ( str.isEmpty() ) |
938 | setDefaultEmail( QString::null ); | 938 | setDefaultEmail( QString::null ); |
939 | } | 939 | } |
940 | 940 | ||
941 | /*! | 941 | /*! |
942 | Sets the list of children for the contact to those contained in \a str. | 942 | Sets the list of children for the contact to those contained in \a str. |
943 | */ | 943 | */ |
944 | void OContact::setChildren( const QString &str ) | 944 | void OContact::setChildren( const QString &str ) |
945 | { | 945 | { |
946 | replace( Qtopia::Children, str ); | 946 | replace( Qtopia::Children, str ); |
947 | } | 947 | } |
948 | 948 | ||
949 | /*! | 949 | /*! |
950 | \overload | 950 | \overload |
951 | Returns TRUE if the contact matches the regular expression \a regexp. | 951 | Returns TRUE if the contact matches the regular expression \a regexp. |
952 | Otherwise returns FALSE. | 952 | Otherwise returns FALSE. |
953 | */ | 953 | */ |
954 | bool OContact::match( const QRegExp &r ) const | 954 | bool OContact::match( const QRegExp &r ) const |
955 | { | 955 | { |
956 | bool match; | 956 | bool match; |
957 | match = false; | 957 | match = false; |
958 | QMap<int, QString>::ConstIterator it; | 958 | QMap<int, QString>::ConstIterator it; |
959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
960 | if ( (*it).find( r ) > -1 ) { | 960 | if ( (*it).find( r ) > -1 ) { |
961 | setLastHitField( it.key() ); | ||
961 | match = true; | 962 | match = true; |
962 | break; | 963 | break; |
963 | } | 964 | } |
964 | } | 965 | } |
965 | return match; | 966 | return match; |
966 | } | 967 | } |
967 | 968 | ||
968 | 969 | ||
969 | QString OContact::toShortText() const | 970 | QString OContact::toShortText() const |
970 | { | 971 | { |
971 | return ( fullName() ); | 972 | return ( fullName() ); |
972 | } | 973 | } |
973 | QString OContact::type() const | 974 | QString OContact::type() const |
974 | { | 975 | { |
975 | return QString::fromLatin1( "OContact" ); | 976 | return QString::fromLatin1( "OContact" ); |
976 | } | 977 | } |
977 | 978 | ||
978 | // Definition is missing ! (se) | 979 | // Definition is missing ! (se) |
979 | QMap<QString,QString> OContact::toExtraMap() const | 980 | QMap<QString,QString> OContact::toExtraMap() const |
980 | { | 981 | { |
981 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 982 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
982 | QMap <QString,QString> useless; | 983 | QMap <QString,QString> useless; |
983 | return useless; | 984 | return useless; |
984 | } | 985 | } |
985 | 986 | ||
986 | class QString OContact::recordField( int pos ) const | 987 | class QString OContact::recordField( int pos ) const |
987 | { | 988 | { |
988 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 989 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
989 | return SLFIELDS[pos]; | 990 | return SLFIELDS[pos]; |
990 | } | 991 | } |
991 | 992 | ||
992 | // In future releases, we should store birthday and anniversary | 993 | // In future releases, we should store birthday and anniversary |
993 | // internally as QDate instead of QString ! | 994 | // internally as QDate instead of QString ! |
994 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 995 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
995 | 996 | ||
996 | /*! \fn void OContact::setBirthday( const QDate& date ) | 997 | /*! \fn void OContact::setBirthday( const QDate& date ) |
997 | Sets the birthday for the contact to \a date. If date is null | 998 | Sets the birthday for the contact to \a date. If date is null |
998 | the current stored date will be removed. | 999 | the current stored date will be removed. |
999 | */ | 1000 | */ |
1000 | void OContact::setBirthday( const QDate &v ) | 1001 | void OContact::setBirthday( const QDate &v ) |
1001 | { | 1002 | { |
1002 | if ( v.isNull() ){ | 1003 | if ( v.isNull() ){ |
1003 | qWarning( "Remove Birthday"); | 1004 | qWarning( "Remove Birthday"); |
1004 | replace( Qtopia::Birthday, QString::null ); | 1005 | replace( Qtopia::Birthday, QString::null ); |
1005 | return; | 1006 | return; |
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | if ( v.isValid() ) | 1009 | if ( v.isValid() ) |
1009 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1010 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1010 | 1011 | ||
1011 | } | 1012 | } |
1012 | 1013 | ||
1013 | 1014 | ||
1014 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1015 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1015 | Sets the anniversary of the contact to \a date. If date is | 1016 | Sets the anniversary of the contact to \a date. If date is |
1016 | null, the current stored date will be removed. | 1017 | null, the current stored date will be removed. |
1017 | */ | 1018 | */ |
1018 | void OContact::setAnniversary( const QDate &v ) | 1019 | void OContact::setAnniversary( const QDate &v ) |
1019 | { | 1020 | { |
1020 | if ( v.isNull() ){ | 1021 | if ( v.isNull() ){ |
1021 | qWarning( "Remove Anniversary"); | 1022 | qWarning( "Remove Anniversary"); |
1022 | replace( Qtopia::Anniversary, QString::null ); | 1023 | replace( Qtopia::Anniversary, QString::null ); |
1023 | return; | 1024 | return; |
1024 | } | 1025 | } |
1025 | 1026 | ||
1026 | if ( v.isValid() ) | 1027 | if ( v.isValid() ) |
1027 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1028 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | /*! \fn QDate OContact::birthday() const | 1031 | /*! \fn QDate OContact::birthday() const |
1031 | Returns the birthday of the contact. | 1032 | Returns the birthday of the contact. |
1032 | */ | 1033 | */ |
1033 | QDate OContact::birthday() const | 1034 | QDate OContact::birthday() const |
1034 | { | 1035 | { |
1035 | QString str = find( Qtopia::Birthday ); | 1036 | QString str = find( Qtopia::Birthday ); |
1036 | qWarning ("Birthday %s", str.latin1() ); | 1037 | qWarning ("Birthday %s", str.latin1() ); |
1037 | if ( !str.isEmpty() ) | 1038 | if ( !str.isEmpty() ) |
1038 | return OConversion::dateFromString ( str ); | 1039 | return OConversion::dateFromString ( str ); |
1039 | else | 1040 | else |
1040 | return QDate(); | 1041 | return QDate(); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | 1044 | ||
1044 | /*! \fn QDate OContact::anniversary() const | 1045 | /*! \fn QDate OContact::anniversary() const |
1045 | Returns the anniversary of the contact. | 1046 | Returns the anniversary of the contact. |
1046 | */ | 1047 | */ |
1047 | QDate OContact::anniversary() const | 1048 | QDate OContact::anniversary() const |
1048 | { | 1049 | { |
1049 | QDate empty; | 1050 | QDate empty; |
1050 | QString str = find( Qtopia::Anniversary ); | 1051 | QString str = find( Qtopia::Anniversary ); |
1051 | qWarning ("Anniversary %s", str.latin1() ); | 1052 | qWarning ("Anniversary %s", str.latin1() ); |
1052 | if ( !str.isEmpty() ) | 1053 | if ( !str.isEmpty() ) |
1053 | return OConversion::dateFromString ( str ); | 1054 | return OConversion::dateFromString ( str ); |
1054 | else | 1055 | else |
1055 | return empty; | 1056 | return empty; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | 1059 | ||
1059 | void OContact::insertEmail( const QString &v ) | 1060 | void OContact::insertEmail( const QString &v ) |
1060 | { | 1061 | { |
1061 | //qDebug("insertEmail %s", v.latin1()); | 1062 | //qDebug("insertEmail %s", v.latin1()); |
1062 | QString e = v.simplifyWhiteSpace(); | 1063 | QString e = v.simplifyWhiteSpace(); |
1063 | QString def = defaultEmail(); | 1064 | QString def = defaultEmail(); |
1064 | 1065 | ||
1065 | // if no default, set it as the default email and don't insert | 1066 | // if no default, set it as the default email and don't insert |
1066 | if ( def.isEmpty() ) { | 1067 | if ( def.isEmpty() ) { |
1067 | setDefaultEmail( e ); // will insert into the list for us | 1068 | setDefaultEmail( e ); // will insert into the list for us |
1068 | return; | 1069 | return; |
1069 | } | 1070 | } |
1070 | 1071 | ||
1071 | // otherwise, insert assuming doesn't already exist | 1072 | // otherwise, insert assuming doesn't already exist |
1072 | QString emailsStr = find( Qtopia::Emails ); | 1073 | QString emailsStr = find( Qtopia::Emails ); |
1073 | if ( emailsStr.contains( e )) | 1074 | if ( emailsStr.contains( e )) |
1074 | return; | 1075 | return; |
1075 | if ( !emailsStr.isEmpty() ) | 1076 | if ( !emailsStr.isEmpty() ) |
1076 | emailsStr += emailSeparator(); | 1077 | emailsStr += emailSeparator(); |
1077 | emailsStr += e; | 1078 | emailsStr += e; |
1078 | replace( Qtopia::Emails, emailsStr ); | 1079 | replace( Qtopia::Emails, emailsStr ); |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | void OContact::removeEmail( const QString &v ) | 1082 | void OContact::removeEmail( const QString &v ) |
1082 | { | 1083 | { |
1083 | QString e = v.simplifyWhiteSpace(); | 1084 | QString e = v.simplifyWhiteSpace(); |
1084 | QString def = defaultEmail(); | 1085 | QString def = defaultEmail(); |
1085 | QString emailsStr = find( Qtopia::Emails ); | 1086 | QString emailsStr = find( Qtopia::Emails ); |
1086 | QStringList emails = emailList(); | 1087 | QStringList emails = emailList(); |
1087 | 1088 | ||
1088 | // otherwise, must first contain it | 1089 | // otherwise, must first contain it |
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 0e6cbd2..f79f0f3 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -89,153 +89,156 @@ public: | |||
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 102 | ||
103 | // personal | 103 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 106 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 107 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 109 | void setChildren( const QString &v ); |
110 | 110 | ||
111 | // other | 111 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 113 | ||
114 | virtual bool match( const QRegExp ®exp ) const; | 114 | virtual bool match( const QRegExp ®exp ) const; |
115 | 115 | ||
116 | // // custom | 116 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
119 | 119 | ||
120 | // name | 120 | // name |
121 | QString fullName() const; | 121 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 128 | ||
129 | 129 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 131 | QStringList emailList() const; |
132 | 132 | ||
133 | // home | 133 | // home |
134 | /* | 134 | /* |
135 | * OPimAddress address(enum Location)const; | 135 | * OPimAddress address(enum Location)const; |
136 | * would be some how nicer... | 136 | * would be some how nicer... |
137 | * -zecke | 137 | * -zecke |
138 | */ | 138 | */ |
139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
140 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 140 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
141 | QString homeState() const { return find( Qtopia::HomeState ); } | 141 | QString homeState() const { return find( Qtopia::HomeState ); } |
142 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 142 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
144 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 144 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
145 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 145 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
148 | /** Multi line string containing all non-empty address info in the form | 148 | /** Multi line string containing all non-empty address info in the form |
149 | * Street | 149 | * Street |
150 | * City, State Zip | 150 | * City, State Zip |
151 | * Country | 151 | * Country |
152 | */ | 152 | */ |
153 | QString displayHomeAddress() const; | 153 | QString displayHomeAddress() const; |
154 | 154 | ||
155 | // business | 155 | // business |
156 | QString company() const { return find( Qtopia::Company ); } | 156 | QString company() const { return find( Qtopia::Company ); } |
157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
159 | QString businessState() const { return find( Qtopia::BusinessState ); } | 159 | QString businessState() const { return find( Qtopia::BusinessState ); } |
160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
164 | QString department() const { return find( Qtopia::Department ); } | 164 | QString department() const { return find( Qtopia::Department ); } |
165 | QString office() const { return find( Qtopia::Office ); } | 165 | QString office() const { return find( Qtopia::Office ); } |
166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
170 | QString profession() const { return find( Qtopia::Profession ); } | 170 | QString profession() const { return find( Qtopia::Profession ); } |
171 | QString assistant() const { return find( Qtopia::Assistant ); } | 171 | QString assistant() const { return find( Qtopia::Assistant ); } |
172 | QString manager() const { return find( Qtopia::Manager ); } | 172 | QString manager() const { return find( Qtopia::Manager ); } |
173 | /** Multi line string containing all non-empty address info in the form | 173 | /** Multi line string containing all non-empty address info in the form |
174 | * Street | 174 | * Street |
175 | * City, State Zip | 175 | * City, State Zip |
176 | * Country | 176 | * Country |
177 | */ | 177 | */ |
178 | QString displayBusinessAddress() const; | 178 | QString displayBusinessAddress() const; |
179 | 179 | ||
180 | //personal | 180 | //personal |
181 | QString spouse() const { return find( Qtopia::Spouse ); } | 181 | QString spouse() const { return find( Qtopia::Spouse ); } |
182 | QString gender() const { return find( Qtopia::Gender ); } | 182 | QString gender() const { return find( Qtopia::Gender ); } |
183 | QDate birthday() const; | 183 | QDate birthday() const; |
184 | QDate anniversary() const; | 184 | QDate anniversary() const; |
185 | QString nickname() const { return find( Qtopia::Nickname ); } | 185 | QString nickname() const { return find( Qtopia::Nickname ); } |
186 | QString children() const { return find( Qtopia::Children ); } | 186 | QString children() const { return find( Qtopia::Children ); } |
187 | QStringList childrenList() const; | 187 | QStringList childrenList() const; |
188 | 188 | ||
189 | // other | 189 | // other |
190 | QString notes() const { return find( Qtopia::Notes ); } | 190 | QString notes() const { return find( Qtopia::Notes ); } |
191 | QString groups() const { return find( Qtopia::Groups ); } | 191 | QString groups() const { return find( Qtopia::Groups ); } |
192 | QStringList groupList() const; | 192 | QStringList groupList() const; |
193 | 193 | ||
194 | // // custom | 194 | // // custom |
195 | // const QString &customField( const QString &key ) | 195 | // const QString &customField( const QString &key ) |
196 | // { return find( Custom- + key ); } | 196 | // { return find( Custom- + key ); } |
197 | 197 | ||
198 | 198 | ||
199 | QString toRichText() const; | 199 | QString toRichText() const; |
200 | QMap<int, QString> toMap() const; | 200 | QMap<int, QString> toMap() const; |
201 | QString field( int key ) const { return find( key ); } | 201 | QString field( int key ) const { return find( key ); } |
202 | 202 | ||
203 | 203 | ||
204 | void setUid( int i ); | 204 | void setUid( int i ); |
205 | 205 | ||
206 | QString toShortText()const; | 206 | QString toShortText()const; |
207 | QString OContact::type()const; | 207 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 208 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 209 | class QString OContact::recordField(int) const; |
210 | 210 | ||
211 | // Why private ? (eilers,se) | 211 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 212 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 213 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 214 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 215 | QString emails() const { return find( Qtopia::Emails ); } |
216 | static int rtti(); | 216 | static int rtti(); |
217 | 217 | int lastHitField() const {return m_lastHitField;}; | |
218 | protected: | ||
219 | mutable int m_lastHitField; | ||
220 | void setLastHitField(int i) const { m_lastHitField = i; }; | ||
218 | 221 | ||
219 | private: | 222 | private: |
220 | // The XML-Backend needs some access to the private functions | 223 | // The XML-Backend needs some access to the private functions |
221 | friend class OContactAccessBackend_XML; | 224 | friend class OContactAccessBackend_XML; |
222 | 225 | ||
223 | void insert( int key, const QString &value ); | 226 | void insert( int key, const QString &value ); |
224 | void replace( int key, const QString &value ); | 227 | void replace( int key, const QString &value ); |
225 | QString find( int key ) const; | 228 | QString find( int key ) const; |
226 | static QStringList fields(); | 229 | static QStringList fields(); |
227 | 230 | ||
228 | void save( QString &buf ) const; | 231 | void save( QString &buf ) const; |
229 | 232 | ||
230 | QString displayAddress( const QString &street, | 233 | QString displayAddress( const QString &street, |
231 | const QString &city, | 234 | const QString &city, |
232 | const QString &state, | 235 | const QString &state, |
233 | const QString &zip, | 236 | const QString &zip, |
234 | const QString &country ) const; | 237 | const QString &country ) const; |
235 | 238 | ||
236 | QMap<int, QString> mMap; | 239 | QMap<int, QString> mMap; |
237 | ContactPrivate *d; | 240 | ContactPrivate *d; |
238 | }; | 241 | }; |
239 | 242 | ||
240 | 243 | ||
241 | #endif | 244 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index a38b62b..aeb69ee 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -833,256 +833,257 @@ void OContact::setFileAs() | |||
833 | replace( Qtopia::FileAs, fileas ); | 833 | replace( Qtopia::FileAs, fileas ); |
834 | } | 834 | } |
835 | 835 | ||
836 | /*! | 836 | /*! |
837 | \internal | 837 | \internal |
838 | Appends the contact information to \a buf. | 838 | Appends the contact information to \a buf. |
839 | */ | 839 | */ |
840 | void OContact::save( QString &buf ) const | 840 | void OContact::save( QString &buf ) const |
841 | { | 841 | { |
842 | static const QStringList SLFIELDS = fields(); | 842 | static const QStringList SLFIELDS = fields(); |
843 | // I'm expecting "<Contact " in front of this... | 843 | // I'm expecting "<Contact " in front of this... |
844 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 844 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
845 | it != mMap.end(); ++it ) { | 845 | it != mMap.end(); ++it ) { |
846 | const QString &value = it.data(); | 846 | const QString &value = it.data(); |
847 | int key = it.key(); | 847 | int key = it.key(); |
848 | if ( !value.isEmpty() ) { | 848 | if ( !value.isEmpty() ) { |
849 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 849 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
850 | continue; | 850 | continue; |
851 | 851 | ||
852 | key -= Qtopia::AddressCategory+1; | 852 | key -= Qtopia::AddressCategory+1; |
853 | buf += SLFIELDS[key]; | 853 | buf += SLFIELDS[key]; |
854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 854 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
855 | } | 855 | } |
856 | } | 856 | } |
857 | buf += customToXml(); | 857 | buf += customToXml(); |
858 | if ( categories().count() > 0 ) | 858 | if ( categories().count() > 0 ) |
859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 859 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 860 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
861 | // You need to close this yourself | 861 | // You need to close this yourself |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | /*! | 865 | /*! |
866 | \internal | 866 | \internal |
867 | Returns the list of fields belonging to a contact | 867 | Returns the list of fields belonging to a contact |
868 | Never change order of this list ! It has to be regarding | 868 | Never change order of this list ! It has to be regarding |
869 | enum AddressBookFields !! | 869 | enum AddressBookFields !! |
870 | */ | 870 | */ |
871 | QStringList OContact::fields() | 871 | QStringList OContact::fields() |
872 | { | 872 | { |
873 | QStringList list; | 873 | QStringList list; |
874 | 874 | ||
875 | list.append( "Title" ); // Not Used! | 875 | list.append( "Title" ); // Not Used! |
876 | list.append( "FirstName" ); | 876 | list.append( "FirstName" ); |
877 | list.append( "MiddleName" ); | 877 | list.append( "MiddleName" ); |
878 | list.append( "LastName" ); | 878 | list.append( "LastName" ); |
879 | list.append( "Suffix" ); | 879 | list.append( "Suffix" ); |
880 | list.append( "FileAs" ); | 880 | list.append( "FileAs" ); |
881 | 881 | ||
882 | list.append( "JobTitle" ); | 882 | list.append( "JobTitle" ); |
883 | list.append( "Department" ); | 883 | list.append( "Department" ); |
884 | list.append( "Company" ); | 884 | list.append( "Company" ); |
885 | list.append( "BusinessPhone" ); | 885 | list.append( "BusinessPhone" ); |
886 | list.append( "BusinessFax" ); | 886 | list.append( "BusinessFax" ); |
887 | list.append( "BusinessMobile" ); | 887 | list.append( "BusinessMobile" ); |
888 | 888 | ||
889 | list.append( "DefaultEmail" ); | 889 | list.append( "DefaultEmail" ); |
890 | list.append( "Emails" ); | 890 | list.append( "Emails" ); |
891 | 891 | ||
892 | list.append( "HomePhone" ); | 892 | list.append( "HomePhone" ); |
893 | list.append( "HomeFax" ); | 893 | list.append( "HomeFax" ); |
894 | list.append( "HomeMobile" ); | 894 | list.append( "HomeMobile" ); |
895 | 895 | ||
896 | list.append( "BusinessStreet" ); | 896 | list.append( "BusinessStreet" ); |
897 | list.append( "BusinessCity" ); | 897 | list.append( "BusinessCity" ); |
898 | list.append( "BusinessState" ); | 898 | list.append( "BusinessState" ); |
899 | list.append( "BusinessZip" ); | 899 | list.append( "BusinessZip" ); |
900 | list.append( "BusinessCountry" ); | 900 | list.append( "BusinessCountry" ); |
901 | list.append( "BusinessPager" ); | 901 | list.append( "BusinessPager" ); |
902 | list.append( "BusinessWebPage" ); | 902 | list.append( "BusinessWebPage" ); |
903 | 903 | ||
904 | list.append( "Office" ); | 904 | list.append( "Office" ); |
905 | list.append( "Profession" ); | 905 | list.append( "Profession" ); |
906 | list.append( "Assistant" ); | 906 | list.append( "Assistant" ); |
907 | list.append( "Manager" ); | 907 | list.append( "Manager" ); |
908 | 908 | ||
909 | list.append( "HomeStreet" ); | 909 | list.append( "HomeStreet" ); |
910 | list.append( "HomeCity" ); | 910 | list.append( "HomeCity" ); |
911 | list.append( "HomeState" ); | 911 | list.append( "HomeState" ); |
912 | list.append( "HomeZip" ); | 912 | list.append( "HomeZip" ); |
913 | list.append( "HomeCountry" ); | 913 | list.append( "HomeCountry" ); |
914 | list.append( "HomeWebPage" ); | 914 | list.append( "HomeWebPage" ); |
915 | 915 | ||
916 | list.append( "Spouse" ); | 916 | list.append( "Spouse" ); |
917 | list.append( "Gender" ); | 917 | list.append( "Gender" ); |
918 | list.append( "Birthday" ); | 918 | list.append( "Birthday" ); |
919 | list.append( "Anniversary" ); | 919 | list.append( "Anniversary" ); |
920 | list.append( "Nickname" ); | 920 | list.append( "Nickname" ); |
921 | list.append( "Children" ); | 921 | list.append( "Children" ); |
922 | 922 | ||
923 | list.append( "Notes" ); | 923 | list.append( "Notes" ); |
924 | list.append( "Groups" ); | 924 | list.append( "Groups" ); |
925 | 925 | ||
926 | return list; | 926 | return list; |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | /*! | 930 | /*! |
931 | Sets the list of email address for contact to those contained in \a str. | 931 | Sets the list of email address for contact to those contained in \a str. |
932 | Email address should be separated by ';'s. | 932 | Email address should be separated by ';'s. |
933 | */ | 933 | */ |
934 | void OContact::setEmails( const QString &str ) | 934 | void OContact::setEmails( const QString &str ) |
935 | { | 935 | { |
936 | replace( Qtopia::Emails, str ); | 936 | replace( Qtopia::Emails, str ); |
937 | if ( str.isEmpty() ) | 937 | if ( str.isEmpty() ) |
938 | setDefaultEmail( QString::null ); | 938 | setDefaultEmail( QString::null ); |
939 | } | 939 | } |
940 | 940 | ||
941 | /*! | 941 | /*! |
942 | Sets the list of children for the contact to those contained in \a str. | 942 | Sets the list of children for the contact to those contained in \a str. |
943 | */ | 943 | */ |
944 | void OContact::setChildren( const QString &str ) | 944 | void OContact::setChildren( const QString &str ) |
945 | { | 945 | { |
946 | replace( Qtopia::Children, str ); | 946 | replace( Qtopia::Children, str ); |
947 | } | 947 | } |
948 | 948 | ||
949 | /*! | 949 | /*! |
950 | \overload | 950 | \overload |
951 | Returns TRUE if the contact matches the regular expression \a regexp. | 951 | Returns TRUE if the contact matches the regular expression \a regexp. |
952 | Otherwise returns FALSE. | 952 | Otherwise returns FALSE. |
953 | */ | 953 | */ |
954 | bool OContact::match( const QRegExp &r ) const | 954 | bool OContact::match( const QRegExp &r ) const |
955 | { | 955 | { |
956 | bool match; | 956 | bool match; |
957 | match = false; | 957 | match = false; |
958 | QMap<int, QString>::ConstIterator it; | 958 | QMap<int, QString>::ConstIterator it; |
959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
960 | if ( (*it).find( r ) > -1 ) { | 960 | if ( (*it).find( r ) > -1 ) { |
961 | setLastHitField( it.key() ); | ||
961 | match = true; | 962 | match = true; |
962 | break; | 963 | break; |
963 | } | 964 | } |
964 | } | 965 | } |
965 | return match; | 966 | return match; |
966 | } | 967 | } |
967 | 968 | ||
968 | 969 | ||
969 | QString OContact::toShortText() const | 970 | QString OContact::toShortText() const |
970 | { | 971 | { |
971 | return ( fullName() ); | 972 | return ( fullName() ); |
972 | } | 973 | } |
973 | QString OContact::type() const | 974 | QString OContact::type() const |
974 | { | 975 | { |
975 | return QString::fromLatin1( "OContact" ); | 976 | return QString::fromLatin1( "OContact" ); |
976 | } | 977 | } |
977 | 978 | ||
978 | // Definition is missing ! (se) | 979 | // Definition is missing ! (se) |
979 | QMap<QString,QString> OContact::toExtraMap() const | 980 | QMap<QString,QString> OContact::toExtraMap() const |
980 | { | 981 | { |
981 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 982 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
982 | QMap <QString,QString> useless; | 983 | QMap <QString,QString> useless; |
983 | return useless; | 984 | return useless; |
984 | } | 985 | } |
985 | 986 | ||
986 | class QString OContact::recordField( int pos ) const | 987 | class QString OContact::recordField( int pos ) const |
987 | { | 988 | { |
988 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 989 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
989 | return SLFIELDS[pos]; | 990 | return SLFIELDS[pos]; |
990 | } | 991 | } |
991 | 992 | ||
992 | // In future releases, we should store birthday and anniversary | 993 | // In future releases, we should store birthday and anniversary |
993 | // internally as QDate instead of QString ! | 994 | // internally as QDate instead of QString ! |
994 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 995 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
995 | 996 | ||
996 | /*! \fn void OContact::setBirthday( const QDate& date ) | 997 | /*! \fn void OContact::setBirthday( const QDate& date ) |
997 | Sets the birthday for the contact to \a date. If date is null | 998 | Sets the birthday for the contact to \a date. If date is null |
998 | the current stored date will be removed. | 999 | the current stored date will be removed. |
999 | */ | 1000 | */ |
1000 | void OContact::setBirthday( const QDate &v ) | 1001 | void OContact::setBirthday( const QDate &v ) |
1001 | { | 1002 | { |
1002 | if ( v.isNull() ){ | 1003 | if ( v.isNull() ){ |
1003 | qWarning( "Remove Birthday"); | 1004 | qWarning( "Remove Birthday"); |
1004 | replace( Qtopia::Birthday, QString::null ); | 1005 | replace( Qtopia::Birthday, QString::null ); |
1005 | return; | 1006 | return; |
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | if ( v.isValid() ) | 1009 | if ( v.isValid() ) |
1009 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1010 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1010 | 1011 | ||
1011 | } | 1012 | } |
1012 | 1013 | ||
1013 | 1014 | ||
1014 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1015 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1015 | Sets the anniversary of the contact to \a date. If date is | 1016 | Sets the anniversary of the contact to \a date. If date is |
1016 | null, the current stored date will be removed. | 1017 | null, the current stored date will be removed. |
1017 | */ | 1018 | */ |
1018 | void OContact::setAnniversary( const QDate &v ) | 1019 | void OContact::setAnniversary( const QDate &v ) |
1019 | { | 1020 | { |
1020 | if ( v.isNull() ){ | 1021 | if ( v.isNull() ){ |
1021 | qWarning( "Remove Anniversary"); | 1022 | qWarning( "Remove Anniversary"); |
1022 | replace( Qtopia::Anniversary, QString::null ); | 1023 | replace( Qtopia::Anniversary, QString::null ); |
1023 | return; | 1024 | return; |
1024 | } | 1025 | } |
1025 | 1026 | ||
1026 | if ( v.isValid() ) | 1027 | if ( v.isValid() ) |
1027 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1028 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | /*! \fn QDate OContact::birthday() const | 1031 | /*! \fn QDate OContact::birthday() const |
1031 | Returns the birthday of the contact. | 1032 | Returns the birthday of the contact. |
1032 | */ | 1033 | */ |
1033 | QDate OContact::birthday() const | 1034 | QDate OContact::birthday() const |
1034 | { | 1035 | { |
1035 | QString str = find( Qtopia::Birthday ); | 1036 | QString str = find( Qtopia::Birthday ); |
1036 | qWarning ("Birthday %s", str.latin1() ); | 1037 | qWarning ("Birthday %s", str.latin1() ); |
1037 | if ( !str.isEmpty() ) | 1038 | if ( !str.isEmpty() ) |
1038 | return OConversion::dateFromString ( str ); | 1039 | return OConversion::dateFromString ( str ); |
1039 | else | 1040 | else |
1040 | return QDate(); | 1041 | return QDate(); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | 1044 | ||
1044 | /*! \fn QDate OContact::anniversary() const | 1045 | /*! \fn QDate OContact::anniversary() const |
1045 | Returns the anniversary of the contact. | 1046 | Returns the anniversary of the contact. |
1046 | */ | 1047 | */ |
1047 | QDate OContact::anniversary() const | 1048 | QDate OContact::anniversary() const |
1048 | { | 1049 | { |
1049 | QDate empty; | 1050 | QDate empty; |
1050 | QString str = find( Qtopia::Anniversary ); | 1051 | QString str = find( Qtopia::Anniversary ); |
1051 | qWarning ("Anniversary %s", str.latin1() ); | 1052 | qWarning ("Anniversary %s", str.latin1() ); |
1052 | if ( !str.isEmpty() ) | 1053 | if ( !str.isEmpty() ) |
1053 | return OConversion::dateFromString ( str ); | 1054 | return OConversion::dateFromString ( str ); |
1054 | else | 1055 | else |
1055 | return empty; | 1056 | return empty; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | 1059 | ||
1059 | void OContact::insertEmail( const QString &v ) | 1060 | void OContact::insertEmail( const QString &v ) |
1060 | { | 1061 | { |
1061 | //qDebug("insertEmail %s", v.latin1()); | 1062 | //qDebug("insertEmail %s", v.latin1()); |
1062 | QString e = v.simplifyWhiteSpace(); | 1063 | QString e = v.simplifyWhiteSpace(); |
1063 | QString def = defaultEmail(); | 1064 | QString def = defaultEmail(); |
1064 | 1065 | ||
1065 | // if no default, set it as the default email and don't insert | 1066 | // if no default, set it as the default email and don't insert |
1066 | if ( def.isEmpty() ) { | 1067 | if ( def.isEmpty() ) { |
1067 | setDefaultEmail( e ); // will insert into the list for us | 1068 | setDefaultEmail( e ); // will insert into the list for us |
1068 | return; | 1069 | return; |
1069 | } | 1070 | } |
1070 | 1071 | ||
1071 | // otherwise, insert assuming doesn't already exist | 1072 | // otherwise, insert assuming doesn't already exist |
1072 | QString emailsStr = find( Qtopia::Emails ); | 1073 | QString emailsStr = find( Qtopia::Emails ); |
1073 | if ( emailsStr.contains( e )) | 1074 | if ( emailsStr.contains( e )) |
1074 | return; | 1075 | return; |
1075 | if ( !emailsStr.isEmpty() ) | 1076 | if ( !emailsStr.isEmpty() ) |
1076 | emailsStr += emailSeparator(); | 1077 | emailsStr += emailSeparator(); |
1077 | emailsStr += e; | 1078 | emailsStr += e; |
1078 | replace( Qtopia::Emails, emailsStr ); | 1079 | replace( Qtopia::Emails, emailsStr ); |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | void OContact::removeEmail( const QString &v ) | 1082 | void OContact::removeEmail( const QString &v ) |
1082 | { | 1083 | { |
1083 | QString e = v.simplifyWhiteSpace(); | 1084 | QString e = v.simplifyWhiteSpace(); |
1084 | QString def = defaultEmail(); | 1085 | QString def = defaultEmail(); |
1085 | QString emailsStr = find( Qtopia::Emails ); | 1086 | QString emailsStr = find( Qtopia::Emails ); |
1086 | QStringList emails = emailList(); | 1087 | QStringList emails = emailList(); |
1087 | 1088 | ||
1088 | // otherwise, must first contain it | 1089 | // otherwise, must first contain it |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 0e6cbd2..f79f0f3 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -89,153 +89,156 @@ public: | |||
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 102 | ||
103 | // personal | 103 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 106 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 107 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 109 | void setChildren( const QString &v ); |
110 | 110 | ||
111 | // other | 111 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 113 | ||
114 | virtual bool match( const QRegExp ®exp ) const; | 114 | virtual bool match( const QRegExp ®exp ) const; |
115 | 115 | ||
116 | // // custom | 116 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
119 | 119 | ||
120 | // name | 120 | // name |
121 | QString fullName() const; | 121 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 128 | ||
129 | 129 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 131 | QStringList emailList() const; |
132 | 132 | ||
133 | // home | 133 | // home |
134 | /* | 134 | /* |
135 | * OPimAddress address(enum Location)const; | 135 | * OPimAddress address(enum Location)const; |
136 | * would be some how nicer... | 136 | * would be some how nicer... |
137 | * -zecke | 137 | * -zecke |
138 | */ | 138 | */ |
139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
140 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 140 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
141 | QString homeState() const { return find( Qtopia::HomeState ); } | 141 | QString homeState() const { return find( Qtopia::HomeState ); } |
142 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 142 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
144 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 144 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
145 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 145 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
148 | /** Multi line string containing all non-empty address info in the form | 148 | /** Multi line string containing all non-empty address info in the form |
149 | * Street | 149 | * Street |
150 | * City, State Zip | 150 | * City, State Zip |
151 | * Country | 151 | * Country |
152 | */ | 152 | */ |
153 | QString displayHomeAddress() const; | 153 | QString displayHomeAddress() const; |
154 | 154 | ||
155 | // business | 155 | // business |
156 | QString company() const { return find( Qtopia::Company ); } | 156 | QString company() const { return find( Qtopia::Company ); } |
157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
159 | QString businessState() const { return find( Qtopia::BusinessState ); } | 159 | QString businessState() const { return find( Qtopia::BusinessState ); } |
160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
164 | QString department() const { return find( Qtopia::Department ); } | 164 | QString department() const { return find( Qtopia::Department ); } |
165 | QString office() const { return find( Qtopia::Office ); } | 165 | QString office() const { return find( Qtopia::Office ); } |
166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
170 | QString profession() const { return find( Qtopia::Profession ); } | 170 | QString profession() const { return find( Qtopia::Profession ); } |
171 | QString assistant() const { return find( Qtopia::Assistant ); } | 171 | QString assistant() const { return find( Qtopia::Assistant ); } |
172 | QString manager() const { return find( Qtopia::Manager ); } | 172 | QString manager() const { return find( Qtopia::Manager ); } |
173 | /** Multi line string containing all non-empty address info in the form | 173 | /** Multi line string containing all non-empty address info in the form |
174 | * Street | 174 | * Street |
175 | * City, State Zip | 175 | * City, State Zip |
176 | * Country | 176 | * Country |
177 | */ | 177 | */ |
178 | QString displayBusinessAddress() const; | 178 | QString displayBusinessAddress() const; |
179 | 179 | ||
180 | //personal | 180 | //personal |
181 | QString spouse() const { return find( Qtopia::Spouse ); } | 181 | QString spouse() const { return find( Qtopia::Spouse ); } |
182 | QString gender() const { return find( Qtopia::Gender ); } | 182 | QString gender() const { return find( Qtopia::Gender ); } |
183 | QDate birthday() const; | 183 | QDate birthday() const; |
184 | QDate anniversary() const; | 184 | QDate anniversary() const; |
185 | QString nickname() const { return find( Qtopia::Nickname ); } | 185 | QString nickname() const { return find( Qtopia::Nickname ); } |
186 | QString children() const { return find( Qtopia::Children ); } | 186 | QString children() const { return find( Qtopia::Children ); } |
187 | QStringList childrenList() const; | 187 | QStringList childrenList() const; |
188 | 188 | ||
189 | // other | 189 | // other |
190 | QString notes() const { return find( Qtopia::Notes ); } | 190 | QString notes() const { return find( Qtopia::Notes ); } |
191 | QString groups() const { return find( Qtopia::Groups ); } | 191 | QString groups() const { return find( Qtopia::Groups ); } |
192 | QStringList groupList() const; | 192 | QStringList groupList() const; |
193 | 193 | ||
194 | // // custom | 194 | // // custom |
195 | // const QString &customField( const QString &key ) | 195 | // const QString &customField( const QString &key ) |
196 | // { return find( Custom- + key ); } | 196 | // { return find( Custom- + key ); } |
197 | 197 | ||
198 | 198 | ||
199 | QString toRichText() const; | 199 | QString toRichText() const; |
200 | QMap<int, QString> toMap() const; | 200 | QMap<int, QString> toMap() const; |
201 | QString field( int key ) const { return find( key ); } | 201 | QString field( int key ) const { return find( key ); } |
202 | 202 | ||
203 | 203 | ||
204 | void setUid( int i ); | 204 | void setUid( int i ); |
205 | 205 | ||
206 | QString toShortText()const; | 206 | QString toShortText()const; |
207 | QString OContact::type()const; | 207 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 208 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 209 | class QString OContact::recordField(int) const; |
210 | 210 | ||
211 | // Why private ? (eilers,se) | 211 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 212 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 213 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 214 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 215 | QString emails() const { return find( Qtopia::Emails ); } |
216 | static int rtti(); | 216 | static int rtti(); |
217 | 217 | int lastHitField() const {return m_lastHitField;}; | |
218 | protected: | ||
219 | mutable int m_lastHitField; | ||
220 | void setLastHitField(int i) const { m_lastHitField = i; }; | ||
218 | 221 | ||
219 | private: | 222 | private: |
220 | // The XML-Backend needs some access to the private functions | 223 | // The XML-Backend needs some access to the private functions |
221 | friend class OContactAccessBackend_XML; | 224 | friend class OContactAccessBackend_XML; |
222 | 225 | ||
223 | void insert( int key, const QString &value ); | 226 | void insert( int key, const QString &value ); |
224 | void replace( int key, const QString &value ); | 227 | void replace( int key, const QString &value ); |
225 | QString find( int key ) const; | 228 | QString find( int key ) const; |
226 | static QStringList fields(); | 229 | static QStringList fields(); |
227 | 230 | ||
228 | void save( QString &buf ) const; | 231 | void save( QString &buf ) const; |
229 | 232 | ||
230 | QString displayAddress( const QString &street, | 233 | QString displayAddress( const QString &street, |
231 | const QString &city, | 234 | const QString &city, |
232 | const QString &state, | 235 | const QString &state, |
233 | const QString &zip, | 236 | const QString &zip, |
234 | const QString &country ) const; | 237 | const QString &country ) const; |
235 | 238 | ||
236 | QMap<int, QString> mMap; | 239 | QMap<int, QString> mMap; |
237 | ContactPrivate *d; | 240 | ContactPrivate *d; |
238 | }; | 241 | }; |
239 | 242 | ||
240 | 243 | ||
241 | #endif | 244 | #endif |