author | zecke <zecke> | 2003-05-14 14:41:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-14 14:41:47 (UTC) |
commit | cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7 (patch) (unidiff) | |
tree | a5496cd003388591cc4a5e323bb5c99646919b92 | |
parent | 3c4a67b8b8d3fb554c5259f9f5ca35c5c826b13c (diff) | |
download | opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.zip opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.tar.gz opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.tar.bz2 |
move lastHitField stuff into OPIMRecord
-rw-r--r-- | libopie/pim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 4 | ||||
-rw-r--r-- | libopie/pim/opimrecord.cpp | 8 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 15 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 15 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 4 |
8 files changed, 44 insertions, 12 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index aeb69ee..a7ca975 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -860,192 +860,193 @@ void OContact::save( QString &buf ) const | |||
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 | setLastHitField( -1 ); | ||
956 | bool match; | 957 | bool match; |
957 | match = false; | 958 | match = false; |
958 | QMap<int, QString>::ConstIterator it; | 959 | QMap<int, QString>::ConstIterator it; |
959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 960 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
960 | if ( (*it).find( r ) > -1 ) { | 961 | if ( (*it).find( r ) > -1 ) { |
961 | setLastHitField( it.key() ); | 962 | setLastHitField( it.key() ); |
962 | match = true; | 963 | match = true; |
963 | break; | 964 | break; |
964 | } | 965 | } |
965 | } | 966 | } |
966 | return match; | 967 | return match; |
967 | } | 968 | } |
968 | 969 | ||
969 | 970 | ||
970 | QString OContact::toShortText() const | 971 | QString OContact::toShortText() const |
971 | { | 972 | { |
972 | return ( fullName() ); | 973 | return ( fullName() ); |
973 | } | 974 | } |
974 | QString OContact::type() const | 975 | QString OContact::type() const |
975 | { | 976 | { |
976 | return QString::fromLatin1( "OContact" ); | 977 | return QString::fromLatin1( "OContact" ); |
977 | } | 978 | } |
978 | 979 | ||
979 | // Definition is missing ! (se) | 980 | // Definition is missing ! (se) |
980 | QMap<QString,QString> OContact::toExtraMap() const | 981 | QMap<QString,QString> OContact::toExtraMap() const |
981 | { | 982 | { |
982 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 983 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
983 | QMap <QString,QString> useless; | 984 | QMap <QString,QString> useless; |
984 | return useless; | 985 | return useless; |
985 | } | 986 | } |
986 | 987 | ||
987 | class QString OContact::recordField( int pos ) const | 988 | class QString OContact::recordField( int pos ) const |
988 | { | 989 | { |
989 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 990 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
990 | return SLFIELDS[pos]; | 991 | return SLFIELDS[pos]; |
991 | } | 992 | } |
992 | 993 | ||
993 | // In future releases, we should store birthday and anniversary | 994 | // In future releases, we should store birthday and anniversary |
994 | // internally as QDate instead of QString ! | 995 | // internally as QDate instead of QString ! |
995 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 996 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
996 | 997 | ||
997 | /*! \fn void OContact::setBirthday( const QDate& date ) | 998 | /*! \fn void OContact::setBirthday( const QDate& date ) |
998 | Sets the birthday for the contact to \a date. If date is null | 999 | Sets the birthday for the contact to \a date. If date is null |
999 | the current stored date will be removed. | 1000 | the current stored date will be removed. |
1000 | */ | 1001 | */ |
1001 | void OContact::setBirthday( const QDate &v ) | 1002 | void OContact::setBirthday( const QDate &v ) |
1002 | { | 1003 | { |
1003 | if ( v.isNull() ){ | 1004 | if ( v.isNull() ){ |
1004 | qWarning( "Remove Birthday"); | 1005 | qWarning( "Remove Birthday"); |
1005 | replace( Qtopia::Birthday, QString::null ); | 1006 | replace( Qtopia::Birthday, QString::null ); |
1006 | return; | 1007 | return; |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | if ( v.isValid() ) | 1010 | if ( v.isValid() ) |
1010 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1011 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1011 | 1012 | ||
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | 1015 | ||
1015 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1016 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1016 | Sets the anniversary of the contact to \a date. If date is | 1017 | Sets the anniversary of the contact to \a date. If date is |
1017 | null, the current stored date will be removed. | 1018 | null, the current stored date will be removed. |
1018 | */ | 1019 | */ |
1019 | void OContact::setAnniversary( const QDate &v ) | 1020 | void OContact::setAnniversary( const QDate &v ) |
1020 | { | 1021 | { |
1021 | if ( v.isNull() ){ | 1022 | if ( v.isNull() ){ |
1022 | qWarning( "Remove Anniversary"); | 1023 | qWarning( "Remove Anniversary"); |
1023 | replace( Qtopia::Anniversary, QString::null ); | 1024 | replace( Qtopia::Anniversary, QString::null ); |
1024 | return; | 1025 | return; |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | if ( v.isValid() ) | 1028 | if ( v.isValid() ) |
1028 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1029 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | /*! \fn QDate OContact::birthday() const | 1032 | /*! \fn QDate OContact::birthday() const |
1032 | Returns the birthday of the contact. | 1033 | Returns the birthday of the contact. |
1033 | */ | 1034 | */ |
1034 | QDate OContact::birthday() const | 1035 | QDate OContact::birthday() const |
1035 | { | 1036 | { |
1036 | QString str = find( Qtopia::Birthday ); | 1037 | QString str = find( Qtopia::Birthday ); |
1037 | qWarning ("Birthday %s", str.latin1() ); | 1038 | qWarning ("Birthday %s", str.latin1() ); |
1038 | if ( !str.isEmpty() ) | 1039 | if ( !str.isEmpty() ) |
1039 | return OConversion::dateFromString ( str ); | 1040 | return OConversion::dateFromString ( str ); |
1040 | else | 1041 | else |
1041 | return QDate(); | 1042 | return QDate(); |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | 1045 | ||
1045 | /*! \fn QDate OContact::anniversary() const | 1046 | /*! \fn QDate OContact::anniversary() const |
1046 | Returns the anniversary of the contact. | 1047 | Returns the anniversary of the contact. |
1047 | */ | 1048 | */ |
1048 | QDate OContact::anniversary() const | 1049 | QDate OContact::anniversary() const |
1049 | { | 1050 | { |
1050 | QDate empty; | 1051 | QDate empty; |
1051 | QString str = find( Qtopia::Anniversary ); | 1052 | QString str = find( Qtopia::Anniversary ); |
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index f79f0f3..dd2de17 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -121,124 +121,120 @@ public: | |||
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 | int lastHitField() const {return m_lastHitField;}; | ||
218 | protected: | ||
219 | mutable int m_lastHitField; | ||
220 | void setLastHitField(int i) const { m_lastHitField = i; }; | ||
221 | 217 | ||
222 | private: | 218 | private: |
223 | // The XML-Backend needs some access to the private functions | 219 | // The XML-Backend needs some access to the private functions |
224 | friend class OContactAccessBackend_XML; | 220 | friend class OContactAccessBackend_XML; |
225 | 221 | ||
226 | void insert( int key, const QString &value ); | 222 | void insert( int key, const QString &value ); |
227 | void replace( int key, const QString &value ); | 223 | void replace( int key, const QString &value ); |
228 | QString find( int key ) const; | 224 | QString find( int key ) const; |
229 | static QStringList fields(); | 225 | static QStringList fields(); |
230 | 226 | ||
231 | void save( QString &buf ) const; | 227 | void save( QString &buf ) const; |
232 | 228 | ||
233 | QString displayAddress( const QString &street, | 229 | QString displayAddress( const QString &street, |
234 | const QString &city, | 230 | const QString &city, |
235 | const QString &state, | 231 | const QString &state, |
236 | const QString &zip, | 232 | const QString &zip, |
237 | const QString &country ) const; | 233 | const QString &country ) const; |
238 | 234 | ||
239 | QMap<int, QString> mMap; | 235 | QMap<int, QString> mMap; |
240 | ContactPrivate *d; | 236 | ContactPrivate *d; |
241 | }; | 237 | }; |
242 | 238 | ||
243 | 239 | ||
244 | #endif | 240 | #endif |
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp index d45417a..9510357 100644 --- a/libopie/pim/opimrecord.cpp +++ b/libopie/pim/opimrecord.cpp | |||
@@ -1,166 +1,174 @@ | |||
1 | #include <qarray.h> | 1 | #include <qarray.h> |
2 | 2 | ||
3 | #include <qpe/categories.h> | 3 | #include <qpe/categories.h> |
4 | #include <qpe/categoryselect.h> | 4 | #include <qpe/categoryselect.h> |
5 | 5 | ||
6 | #include "opimrecord.h" | 6 | #include "opimrecord.h" |
7 | 7 | ||
8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
9 | 9 | ||
10 | 10 | ||
11 | OPimRecord::OPimRecord( int uid ) | 11 | OPimRecord::OPimRecord( int uid ) |
12 | : Qtopia::Record() { | 12 | : Qtopia::Record() { |
13 | 13 | ||
14 | m_lastHit = -1; | ||
14 | setUid( uid ); | 15 | setUid( uid ); |
15 | } | 16 | } |
16 | OPimRecord::~OPimRecord() { | 17 | OPimRecord::~OPimRecord() { |
17 | } | 18 | } |
18 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 19 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
19 | : Qtopia::Record( rec ) | 20 | : Qtopia::Record( rec ) |
20 | { | 21 | { |
21 | (*this) = rec; | 22 | (*this) = rec; |
22 | } | 23 | } |
23 | 24 | ||
24 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 25 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
25 | Qtopia::Record::operator=( rec ); | 26 | Qtopia::Record::operator=( rec ); |
26 | m_xrefman = rec.m_xrefman; | 27 | m_xrefman = rec.m_xrefman; |
28 | m_lastHit = rec.m_lastHit; | ||
27 | 29 | ||
28 | return *this; | 30 | return *this; |
29 | } | 31 | } |
30 | /* | 32 | /* |
31 | * category names | 33 | * category names |
32 | */ | 34 | */ |
33 | QStringList OPimRecord::categoryNames( const QString& appname ) const { | 35 | QStringList OPimRecord::categoryNames( const QString& appname ) const { |
34 | QStringList list; | 36 | QStringList list; |
35 | QArray<int> cats = categories(); | 37 | QArray<int> cats = categories(); |
36 | Categories catDB; | 38 | Categories catDB; |
37 | catDB.load( categoryFileName() ); | 39 | catDB.load( categoryFileName() ); |
38 | 40 | ||
39 | for (uint i = 0; i < cats.count(); i++ ) { | 41 | for (uint i = 0; i < cats.count(); i++ ) { |
40 | list << catDB.label( appname, cats[i] ); | 42 | list << catDB.label( appname, cats[i] ); |
41 | } | 43 | } |
42 | 44 | ||
43 | return list; | 45 | return list; |
44 | } | 46 | } |
45 | void OPimRecord::setCategoryNames( const QStringList& ) { | 47 | void OPimRecord::setCategoryNames( const QStringList& ) { |
46 | 48 | ||
47 | } | 49 | } |
48 | void OPimRecord::addCategoryName( const QString& ) { | 50 | void OPimRecord::addCategoryName( const QString& ) { |
49 | Categories catDB; | 51 | Categories catDB; |
50 | catDB.load( categoryFileName() ); | 52 | catDB.load( categoryFileName() ); |
51 | 53 | ||
52 | 54 | ||
53 | } | 55 | } |
54 | bool OPimRecord::isEmpty()const { | 56 | bool OPimRecord::isEmpty()const { |
55 | return ( uid() == 0 ); | 57 | return ( uid() == 0 ); |
56 | } | 58 | } |
57 | /*QString OPimRecord::crossToString()const { | 59 | /*QString OPimRecord::crossToString()const { |
58 | QString str; | 60 | QString str; |
59 | QMap<QString, QArray<int> >::ConstIterator it; | 61 | QMap<QString, QArray<int> >::ConstIterator it; |
60 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 62 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
61 | QArray<int> id = it.data(); | 63 | QArray<int> id = it.data(); |
62 | for ( uint i = 0; i < id.size(); ++i ) { | 64 | for ( uint i = 0; i < id.size(); ++i ) { |
63 | str += it.key() + "," + QString::number( i ) + ";"; | 65 | str += it.key() + "," + QString::number( i ) + ";"; |
64 | } | 66 | } |
65 | } | 67 | } |
66 | str = str.remove( str.length()-1, 1); // strip the ; | 68 | str = str.remove( str.length()-1, 1); // strip the ; |
67 | //qWarning("IDS " + str ); | 69 | //qWarning("IDS " + str ); |
68 | 70 | ||
69 | return str; | 71 | return str; |
70 | }*/ | 72 | }*/ |
71 | /* if uid = 1 assign a new one */ | 73 | /* if uid = 1 assign a new one */ |
72 | void OPimRecord::setUid( int uid ) { | 74 | void OPimRecord::setUid( int uid ) { |
73 | if ( uid == 1) | 75 | if ( uid == 1) |
74 | uid = uidGen().generate(); | 76 | uid = uidGen().generate(); |
75 | 77 | ||
76 | Qtopia::Record::setUid( uid ); | 78 | Qtopia::Record::setUid( uid ); |
77 | }; | 79 | }; |
78 | Qtopia::UidGen &OPimRecord::uidGen() { | 80 | Qtopia::UidGen &OPimRecord::uidGen() { |
79 | return m_uidGen; | 81 | return m_uidGen; |
80 | } | 82 | } |
81 | OPimXRefManager &OPimRecord::xrefmanager() { | 83 | OPimXRefManager &OPimRecord::xrefmanager() { |
82 | return m_xrefman; | 84 | return m_xrefman; |
83 | } | 85 | } |
84 | int OPimRecord::rtti(){ | 86 | int OPimRecord::rtti(){ |
85 | return 0; | 87 | return 0; |
86 | } | 88 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * now let's put our data into the stream | 91 | * now let's put our data into the stream |
90 | */ | 92 | */ |
91 | /* | 93 | /* |
92 | * First read UID | 94 | * First read UID |
93 | * Categories | 95 | * Categories |
94 | * XRef | 96 | * XRef |
95 | */ | 97 | */ |
96 | bool OPimRecord::loadFromStream( QDataStream& stream ) { | 98 | bool OPimRecord::loadFromStream( QDataStream& stream ) { |
97 | int Int; | 99 | int Int; |
98 | uint UInt; | 100 | uint UInt; |
99 | stream >> Int; | 101 | stream >> Int; |
100 | setUid(Int); | 102 | setUid(Int); |
101 | 103 | ||
102 | /** Categories */ | 104 | /** Categories */ |
103 | stream >> UInt; | 105 | stream >> UInt; |
104 | QArray<int> array(UInt); | 106 | QArray<int> array(UInt); |
105 | for (uint i = 0; i < UInt; i++ ) { | 107 | for (uint i = 0; i < UInt; i++ ) { |
106 | stream >> array[i]; | 108 | stream >> array[i]; |
107 | } | 109 | } |
108 | setCategories( array ); | 110 | setCategories( array ); |
109 | 111 | ||
110 | /* | 112 | /* |
111 | * now we do the X-Ref stuff | 113 | * now we do the X-Ref stuff |
112 | */ | 114 | */ |
113 | OPimXRef xref; | 115 | OPimXRef xref; |
114 | stream >> UInt; | 116 | stream >> UInt; |
115 | for ( uint i = 0; i < UInt; i++ ) { | 117 | for ( uint i = 0; i < UInt; i++ ) { |
116 | xref.setPartner( OPimXRef::One, partner( stream ) ); | 118 | xref.setPartner( OPimXRef::One, partner( stream ) ); |
117 | xref.setPartner( OPimXRef::Two, partner( stream ) ); | 119 | xref.setPartner( OPimXRef::Two, partner( stream ) ); |
118 | m_xrefman.add( xref ); | 120 | m_xrefman.add( xref ); |
119 | } | 121 | } |
120 | 122 | ||
121 | return true; | 123 | return true; |
122 | } | 124 | } |
123 | bool OPimRecord::saveToStream( QDataStream& stream )const { | 125 | bool OPimRecord::saveToStream( QDataStream& stream )const { |
124 | /** UIDs */ | 126 | /** UIDs */ |
125 | 127 | ||
126 | stream << uid(); | 128 | stream << uid(); |
127 | 129 | ||
128 | /** Categories */ | 130 | /** Categories */ |
129 | stream << categories().count(); | 131 | stream << categories().count(); |
130 | for ( uint i = 0; i < categories().count(); i++ ) { | 132 | for ( uint i = 0; i < categories().count(); i++ ) { |
131 | stream << categories()[i]; | 133 | stream << categories()[i]; |
132 | } | 134 | } |
133 | 135 | ||
134 | /* | 136 | /* |
135 | * first the XRef count | 137 | * first the XRef count |
136 | * then the xrefs | 138 | * then the xrefs |
137 | */ | 139 | */ |
138 | stream << m_xrefman.list().count(); | 140 | stream << m_xrefman.list().count(); |
139 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 141 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
140 | it != m_xrefman.list().end(); ++it ) { | 142 | it != m_xrefman.list().end(); ++it ) { |
141 | flush( (*it).partner( OPimXRef::One), stream ); | 143 | flush( (*it).partner( OPimXRef::One), stream ); |
142 | flush( (*it).partner( OPimXRef::Two), stream ); | 144 | flush( (*it).partner( OPimXRef::Two), stream ); |
143 | } | 145 | } |
144 | return true; | 146 | return true; |
145 | } | 147 | } |
146 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ | 148 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ |
147 | str << par.service(); | 149 | str << par.service(); |
148 | str << par.uid(); | 150 | str << par.uid(); |
149 | str << par.field(); | 151 | str << par.field(); |
150 | } | 152 | } |
151 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | 153 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { |
152 | OPimXRefPartner par; | 154 | OPimXRefPartner par; |
153 | QString str; | 155 | QString str; |
154 | int i; | 156 | int i; |
155 | 157 | ||
156 | stream >> str; | 158 | stream >> str; |
157 | par.setService( str ); | 159 | par.setService( str ); |
158 | 160 | ||
159 | stream >> i; | 161 | stream >> i; |
160 | par.setUid( i ); | 162 | par.setUid( i ); |
161 | 163 | ||
162 | stream >> i ; | 164 | stream >> i ; |
163 | par.setField( i ); | 165 | par.setField( i ); |
164 | 166 | ||
165 | return par; | 167 | return par; |
166 | } | 168 | } |
169 | void OPimRecord::setLastHitField( int lastHit )const { | ||
170 | m_lastHit = lastHit; | ||
171 | } | ||
172 | int OPimRecord::lastHitField()const{ | ||
173 | return m_lastHit; | ||
174 | } | ||
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index 6e7c0da..494c78e 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h | |||
@@ -1,140 +1,151 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qdatastream.h> | 4 | #include <qdatastream.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | 10 | ||
11 | #include <opie/opimxrefmanager.h> | 11 | #include <opie/opimxrefmanager.h> |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * This is the base class for | 14 | * This is the base class for |
15 | * all PIM Records | 15 | * all PIM Records |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | class OPimRecord : public Qtopia::Record { | 18 | class OPimRecord : public Qtopia::Record { |
19 | public: | 19 | public: |
20 | /** | 20 | /** |
21 | * c'tor | 21 | * c'tor |
22 | * uid of 0 isEmpty | 22 | * uid of 0 isEmpty |
23 | * uid of 1 will be assigned a new one | 23 | * uid of 1 will be assigned a new one |
24 | */ | 24 | */ |
25 | OPimRecord(int uid = 0); | 25 | OPimRecord(int uid = 0); |
26 | ~OPimRecord(); | 26 | ~OPimRecord(); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * copy c'tor | 29 | * copy c'tor |
30 | */ | 30 | */ |
31 | OPimRecord( const OPimRecord& rec ); | 31 | OPimRecord( const OPimRecord& rec ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * copy operator | 34 | * copy operator |
35 | */ | 35 | */ |
36 | OPimRecord &operator=( const OPimRecord& ); | 36 | OPimRecord &operator=( const OPimRecord& ); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * category names resolved | 39 | * category names resolved |
40 | */ | 40 | */ |
41 | QStringList categoryNames( const QString& appname )const; | 41 | QStringList categoryNames( const QString& appname )const; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * set category names they will be resolved | 44 | * set category names they will be resolved |
45 | */ | 45 | */ |
46 | void setCategoryNames( const QStringList& ); | 46 | void setCategoryNames( const QStringList& ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * addCategoryName adds a name | 49 | * addCategoryName adds a name |
50 | * to the internal category list | 50 | * to the internal category list |
51 | */ | 51 | */ |
52 | void addCategoryName( const QString& ); | 52 | void addCategoryName( const QString& ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * if a Record isEmpty | 55 | * if a Record isEmpty |
56 | * it's empty if it's 0 | 56 | * it's empty if it's 0 |
57 | */ | 57 | */ |
58 | virtual bool isEmpty()const; | 58 | virtual bool isEmpty()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * toRichText summary | 61 | * toRichText summary |
62 | */ | 62 | */ |
63 | virtual QString toRichText()const = 0; | 63 | virtual QString toRichText()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * a small one line summary | 66 | * a small one line summary |
67 | */ | 67 | */ |
68 | virtual QString toShortText()const = 0; | 68 | virtual QString toShortText()const = 0; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * the name of the Record | 71 | * the name of the Record |
72 | */ | 72 | */ |
73 | virtual QString type()const = 0; | 73 | virtual QString type()const = 0; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * matches the Records the regular expression? | 76 | * matches the Records the regular expression? |
77 | */ | 77 | */ |
78 | virtual bool match( const QString ®exp ) const | 78 | virtual bool match( const QString ®exp ) const |
79 | {return Qtopia::Record::match(QRegExp(regexp));}; | 79 | {setLastHitField( -1 ); |
80 | return Qtopia::Record::match(QRegExp(regexp));}; | ||
81 | |||
82 | /** | ||
83 | * if implemented this function returns which item has been | ||
84 | * last hit by the match() function. | ||
85 | * or -1 if not implemented or no hit has occured | ||
86 | */ | ||
87 | int lastHitField()const; | ||
80 | 88 | ||
81 | /** | 89 | /** |
82 | * converts the internal structure to a map | 90 | * converts the internal structure to a map |
83 | */ | 91 | */ |
84 | virtual QMap<int, QString> toMap()const = 0; | 92 | virtual QMap<int, QString> toMap()const = 0; |
85 | 93 | ||
86 | /** | 94 | /** |
87 | * key value representation of extra items | 95 | * key value representation of extra items |
88 | */ | 96 | */ |
89 | virtual QMap<QString, QString> toExtraMap()const = 0; | 97 | virtual QMap<QString, QString> toExtraMap()const = 0; |
90 | 98 | ||
91 | /** | 99 | /** |
92 | * the name for a recordField | 100 | * the name for a recordField |
93 | */ | 101 | */ |
94 | virtual QString recordField(int)const = 0; | 102 | virtual QString recordField(int)const = 0; |
95 | 103 | ||
96 | /** | 104 | /** |
97 | * returns a reference of the | 105 | * returns a reference of the |
98 | * Cross Reference Manager | 106 | * Cross Reference Manager |
99 | * Partner 'One' is THIS PIM RECORD! | 107 | * Partner 'One' is THIS PIM RECORD! |
100 | * 'Two' is the Partner where we link to | 108 | * 'Two' is the Partner where we link to |
101 | */ | 109 | */ |
102 | OPimXRefManager& xrefmanager(); | 110 | OPimXRefManager& xrefmanager(); |
103 | 111 | ||
104 | /** | 112 | /** |
105 | * set the uid | 113 | * set the uid |
106 | */ | 114 | */ |
107 | virtual void setUid( int uid ); | 115 | virtual void setUid( int uid ); |
108 | 116 | ||
109 | /* | 117 | /* |
110 | * used inside the Templates for casting | 118 | * used inside the Templates for casting |
111 | * REIMPLEMENT in your .... | 119 | * REIMPLEMENT in your .... |
112 | */ | 120 | */ |
113 | static int rtti(); | 121 | static int rtti(); |
114 | 122 | ||
115 | /** | 123 | /** |
116 | * some marshalling and de marshalling code | 124 | * some marshalling and de marshalling code |
117 | * saves the OPimRecord | 125 | * saves the OPimRecord |
118 | * to and from a DataStream | 126 | * to and from a DataStream |
119 | */ | 127 | */ |
120 | virtual bool loadFromStream(QDataStream& ); | 128 | virtual bool loadFromStream(QDataStream& ); |
121 | virtual bool saveToStream( QDataStream& stream )const; | 129 | virtual bool saveToStream( QDataStream& stream )const; |
122 | 130 | ||
123 | protected: | 131 | protected: |
132 | // need to be const cause it is called from const methods | ||
133 | mutable int m_lastHit; | ||
134 | void setLastHitField( int lastHit )const; | ||
124 | Qtopia::UidGen &uidGen(); | 135 | Qtopia::UidGen &uidGen(); |
125 | // QString crossToString()const; | 136 | // QString crossToString()const; |
126 | 137 | ||
127 | private: | 138 | private: |
128 | class OPimRecordPrivate; | 139 | class OPimRecordPrivate; |
129 | OPimRecordPrivate *d; | 140 | OPimRecordPrivate *d; |
130 | OPimXRefManager m_xrefman; | 141 | OPimXRefManager m_xrefman; |
131 | static Qtopia::UidGen m_uidGen; | 142 | static Qtopia::UidGen m_uidGen; |
132 | 143 | ||
133 | private: | 144 | private: |
134 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 145 | void flush( const OPimXRefPartner&, QDataStream& stream )const; |
135 | OPimXRefPartner partner( QDataStream& ); | 146 | OPimXRefPartner partner( QDataStream& ); |
136 | }; | 147 | }; |
137 | 148 | ||
138 | 149 | ||
139 | 150 | ||
140 | #endif | 151 | #endif |
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index d45417a..9510357 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,166 +1,174 @@ | |||
1 | #include <qarray.h> | 1 | #include <qarray.h> |
2 | 2 | ||
3 | #include <qpe/categories.h> | 3 | #include <qpe/categories.h> |
4 | #include <qpe/categoryselect.h> | 4 | #include <qpe/categoryselect.h> |
5 | 5 | ||
6 | #include "opimrecord.h" | 6 | #include "opimrecord.h" |
7 | 7 | ||
8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
9 | 9 | ||
10 | 10 | ||
11 | OPimRecord::OPimRecord( int uid ) | 11 | OPimRecord::OPimRecord( int uid ) |
12 | : Qtopia::Record() { | 12 | : Qtopia::Record() { |
13 | 13 | ||
14 | m_lastHit = -1; | ||
14 | setUid( uid ); | 15 | setUid( uid ); |
15 | } | 16 | } |
16 | OPimRecord::~OPimRecord() { | 17 | OPimRecord::~OPimRecord() { |
17 | } | 18 | } |
18 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 19 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
19 | : Qtopia::Record( rec ) | 20 | : Qtopia::Record( rec ) |
20 | { | 21 | { |
21 | (*this) = rec; | 22 | (*this) = rec; |
22 | } | 23 | } |
23 | 24 | ||
24 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 25 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
25 | Qtopia::Record::operator=( rec ); | 26 | Qtopia::Record::operator=( rec ); |
26 | m_xrefman = rec.m_xrefman; | 27 | m_xrefman = rec.m_xrefman; |
28 | m_lastHit = rec.m_lastHit; | ||
27 | 29 | ||
28 | return *this; | 30 | return *this; |
29 | } | 31 | } |
30 | /* | 32 | /* |
31 | * category names | 33 | * category names |
32 | */ | 34 | */ |
33 | QStringList OPimRecord::categoryNames( const QString& appname ) const { | 35 | QStringList OPimRecord::categoryNames( const QString& appname ) const { |
34 | QStringList list; | 36 | QStringList list; |
35 | QArray<int> cats = categories(); | 37 | QArray<int> cats = categories(); |
36 | Categories catDB; | 38 | Categories catDB; |
37 | catDB.load( categoryFileName() ); | 39 | catDB.load( categoryFileName() ); |
38 | 40 | ||
39 | for (uint i = 0; i < cats.count(); i++ ) { | 41 | for (uint i = 0; i < cats.count(); i++ ) { |
40 | list << catDB.label( appname, cats[i] ); | 42 | list << catDB.label( appname, cats[i] ); |
41 | } | 43 | } |
42 | 44 | ||
43 | return list; | 45 | return list; |
44 | } | 46 | } |
45 | void OPimRecord::setCategoryNames( const QStringList& ) { | 47 | void OPimRecord::setCategoryNames( const QStringList& ) { |
46 | 48 | ||
47 | } | 49 | } |
48 | void OPimRecord::addCategoryName( const QString& ) { | 50 | void OPimRecord::addCategoryName( const QString& ) { |
49 | Categories catDB; | 51 | Categories catDB; |
50 | catDB.load( categoryFileName() ); | 52 | catDB.load( categoryFileName() ); |
51 | 53 | ||
52 | 54 | ||
53 | } | 55 | } |
54 | bool OPimRecord::isEmpty()const { | 56 | bool OPimRecord::isEmpty()const { |
55 | return ( uid() == 0 ); | 57 | return ( uid() == 0 ); |
56 | } | 58 | } |
57 | /*QString OPimRecord::crossToString()const { | 59 | /*QString OPimRecord::crossToString()const { |
58 | QString str; | 60 | QString str; |
59 | QMap<QString, QArray<int> >::ConstIterator it; | 61 | QMap<QString, QArray<int> >::ConstIterator it; |
60 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 62 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
61 | QArray<int> id = it.data(); | 63 | QArray<int> id = it.data(); |
62 | for ( uint i = 0; i < id.size(); ++i ) { | 64 | for ( uint i = 0; i < id.size(); ++i ) { |
63 | str += it.key() + "," + QString::number( i ) + ";"; | 65 | str += it.key() + "," + QString::number( i ) + ";"; |
64 | } | 66 | } |
65 | } | 67 | } |
66 | str = str.remove( str.length()-1, 1); // strip the ; | 68 | str = str.remove( str.length()-1, 1); // strip the ; |
67 | //qWarning("IDS " + str ); | 69 | //qWarning("IDS " + str ); |
68 | 70 | ||
69 | return str; | 71 | return str; |
70 | }*/ | 72 | }*/ |
71 | /* if uid = 1 assign a new one */ | 73 | /* if uid = 1 assign a new one */ |
72 | void OPimRecord::setUid( int uid ) { | 74 | void OPimRecord::setUid( int uid ) { |
73 | if ( uid == 1) | 75 | if ( uid == 1) |
74 | uid = uidGen().generate(); | 76 | uid = uidGen().generate(); |
75 | 77 | ||
76 | Qtopia::Record::setUid( uid ); | 78 | Qtopia::Record::setUid( uid ); |
77 | }; | 79 | }; |
78 | Qtopia::UidGen &OPimRecord::uidGen() { | 80 | Qtopia::UidGen &OPimRecord::uidGen() { |
79 | return m_uidGen; | 81 | return m_uidGen; |
80 | } | 82 | } |
81 | OPimXRefManager &OPimRecord::xrefmanager() { | 83 | OPimXRefManager &OPimRecord::xrefmanager() { |
82 | return m_xrefman; | 84 | return m_xrefman; |
83 | } | 85 | } |
84 | int OPimRecord::rtti(){ | 86 | int OPimRecord::rtti(){ |
85 | return 0; | 87 | return 0; |
86 | } | 88 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * now let's put our data into the stream | 91 | * now let's put our data into the stream |
90 | */ | 92 | */ |
91 | /* | 93 | /* |
92 | * First read UID | 94 | * First read UID |
93 | * Categories | 95 | * Categories |
94 | * XRef | 96 | * XRef |
95 | */ | 97 | */ |
96 | bool OPimRecord::loadFromStream( QDataStream& stream ) { | 98 | bool OPimRecord::loadFromStream( QDataStream& stream ) { |
97 | int Int; | 99 | int Int; |
98 | uint UInt; | 100 | uint UInt; |
99 | stream >> Int; | 101 | stream >> Int; |
100 | setUid(Int); | 102 | setUid(Int); |
101 | 103 | ||
102 | /** Categories */ | 104 | /** Categories */ |
103 | stream >> UInt; | 105 | stream >> UInt; |
104 | QArray<int> array(UInt); | 106 | QArray<int> array(UInt); |
105 | for (uint i = 0; i < UInt; i++ ) { | 107 | for (uint i = 0; i < UInt; i++ ) { |
106 | stream >> array[i]; | 108 | stream >> array[i]; |
107 | } | 109 | } |
108 | setCategories( array ); | 110 | setCategories( array ); |
109 | 111 | ||
110 | /* | 112 | /* |
111 | * now we do the X-Ref stuff | 113 | * now we do the X-Ref stuff |
112 | */ | 114 | */ |
113 | OPimXRef xref; | 115 | OPimXRef xref; |
114 | stream >> UInt; | 116 | stream >> UInt; |
115 | for ( uint i = 0; i < UInt; i++ ) { | 117 | for ( uint i = 0; i < UInt; i++ ) { |
116 | xref.setPartner( OPimXRef::One, partner( stream ) ); | 118 | xref.setPartner( OPimXRef::One, partner( stream ) ); |
117 | xref.setPartner( OPimXRef::Two, partner( stream ) ); | 119 | xref.setPartner( OPimXRef::Two, partner( stream ) ); |
118 | m_xrefman.add( xref ); | 120 | m_xrefman.add( xref ); |
119 | } | 121 | } |
120 | 122 | ||
121 | return true; | 123 | return true; |
122 | } | 124 | } |
123 | bool OPimRecord::saveToStream( QDataStream& stream )const { | 125 | bool OPimRecord::saveToStream( QDataStream& stream )const { |
124 | /** UIDs */ | 126 | /** UIDs */ |
125 | 127 | ||
126 | stream << uid(); | 128 | stream << uid(); |
127 | 129 | ||
128 | /** Categories */ | 130 | /** Categories */ |
129 | stream << categories().count(); | 131 | stream << categories().count(); |
130 | for ( uint i = 0; i < categories().count(); i++ ) { | 132 | for ( uint i = 0; i < categories().count(); i++ ) { |
131 | stream << categories()[i]; | 133 | stream << categories()[i]; |
132 | } | 134 | } |
133 | 135 | ||
134 | /* | 136 | /* |
135 | * first the XRef count | 137 | * first the XRef count |
136 | * then the xrefs | 138 | * then the xrefs |
137 | */ | 139 | */ |
138 | stream << m_xrefman.list().count(); | 140 | stream << m_xrefman.list().count(); |
139 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 141 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
140 | it != m_xrefman.list().end(); ++it ) { | 142 | it != m_xrefman.list().end(); ++it ) { |
141 | flush( (*it).partner( OPimXRef::One), stream ); | 143 | flush( (*it).partner( OPimXRef::One), stream ); |
142 | flush( (*it).partner( OPimXRef::Two), stream ); | 144 | flush( (*it).partner( OPimXRef::Two), stream ); |
143 | } | 145 | } |
144 | return true; | 146 | return true; |
145 | } | 147 | } |
146 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ | 148 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ |
147 | str << par.service(); | 149 | str << par.service(); |
148 | str << par.uid(); | 150 | str << par.uid(); |
149 | str << par.field(); | 151 | str << par.field(); |
150 | } | 152 | } |
151 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | 153 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { |
152 | OPimXRefPartner par; | 154 | OPimXRefPartner par; |
153 | QString str; | 155 | QString str; |
154 | int i; | 156 | int i; |
155 | 157 | ||
156 | stream >> str; | 158 | stream >> str; |
157 | par.setService( str ); | 159 | par.setService( str ); |
158 | 160 | ||
159 | stream >> i; | 161 | stream >> i; |
160 | par.setUid( i ); | 162 | par.setUid( i ); |
161 | 163 | ||
162 | stream >> i ; | 164 | stream >> i ; |
163 | par.setField( i ); | 165 | par.setField( i ); |
164 | 166 | ||
165 | return par; | 167 | return par; |
166 | } | 168 | } |
169 | void OPimRecord::setLastHitField( int lastHit )const { | ||
170 | m_lastHit = lastHit; | ||
171 | } | ||
172 | int OPimRecord::lastHitField()const{ | ||
173 | return m_lastHit; | ||
174 | } | ||
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 6e7c0da..494c78e 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,140 +1,151 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qdatastream.h> | 4 | #include <qdatastream.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | 10 | ||
11 | #include <opie/opimxrefmanager.h> | 11 | #include <opie/opimxrefmanager.h> |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * This is the base class for | 14 | * This is the base class for |
15 | * all PIM Records | 15 | * all PIM Records |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | class OPimRecord : public Qtopia::Record { | 18 | class OPimRecord : public Qtopia::Record { |
19 | public: | 19 | public: |
20 | /** | 20 | /** |
21 | * c'tor | 21 | * c'tor |
22 | * uid of 0 isEmpty | 22 | * uid of 0 isEmpty |
23 | * uid of 1 will be assigned a new one | 23 | * uid of 1 will be assigned a new one |
24 | */ | 24 | */ |
25 | OPimRecord(int uid = 0); | 25 | OPimRecord(int uid = 0); |
26 | ~OPimRecord(); | 26 | ~OPimRecord(); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * copy c'tor | 29 | * copy c'tor |
30 | */ | 30 | */ |
31 | OPimRecord( const OPimRecord& rec ); | 31 | OPimRecord( const OPimRecord& rec ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * copy operator | 34 | * copy operator |
35 | */ | 35 | */ |
36 | OPimRecord &operator=( const OPimRecord& ); | 36 | OPimRecord &operator=( const OPimRecord& ); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * category names resolved | 39 | * category names resolved |
40 | */ | 40 | */ |
41 | QStringList categoryNames( const QString& appname )const; | 41 | QStringList categoryNames( const QString& appname )const; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * set category names they will be resolved | 44 | * set category names they will be resolved |
45 | */ | 45 | */ |
46 | void setCategoryNames( const QStringList& ); | 46 | void setCategoryNames( const QStringList& ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * addCategoryName adds a name | 49 | * addCategoryName adds a name |
50 | * to the internal category list | 50 | * to the internal category list |
51 | */ | 51 | */ |
52 | void addCategoryName( const QString& ); | 52 | void addCategoryName( const QString& ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * if a Record isEmpty | 55 | * if a Record isEmpty |
56 | * it's empty if it's 0 | 56 | * it's empty if it's 0 |
57 | */ | 57 | */ |
58 | virtual bool isEmpty()const; | 58 | virtual bool isEmpty()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * toRichText summary | 61 | * toRichText summary |
62 | */ | 62 | */ |
63 | virtual QString toRichText()const = 0; | 63 | virtual QString toRichText()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * a small one line summary | 66 | * a small one line summary |
67 | */ | 67 | */ |
68 | virtual QString toShortText()const = 0; | 68 | virtual QString toShortText()const = 0; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * the name of the Record | 71 | * the name of the Record |
72 | */ | 72 | */ |
73 | virtual QString type()const = 0; | 73 | virtual QString type()const = 0; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * matches the Records the regular expression? | 76 | * matches the Records the regular expression? |
77 | */ | 77 | */ |
78 | virtual bool match( const QString ®exp ) const | 78 | virtual bool match( const QString ®exp ) const |
79 | {return Qtopia::Record::match(QRegExp(regexp));}; | 79 | {setLastHitField( -1 ); |
80 | return Qtopia::Record::match(QRegExp(regexp));}; | ||
81 | |||
82 | /** | ||
83 | * if implemented this function returns which item has been | ||
84 | * last hit by the match() function. | ||
85 | * or -1 if not implemented or no hit has occured | ||
86 | */ | ||
87 | int lastHitField()const; | ||
80 | 88 | ||
81 | /** | 89 | /** |
82 | * converts the internal structure to a map | 90 | * converts the internal structure to a map |
83 | */ | 91 | */ |
84 | virtual QMap<int, QString> toMap()const = 0; | 92 | virtual QMap<int, QString> toMap()const = 0; |
85 | 93 | ||
86 | /** | 94 | /** |
87 | * key value representation of extra items | 95 | * key value representation of extra items |
88 | */ | 96 | */ |
89 | virtual QMap<QString, QString> toExtraMap()const = 0; | 97 | virtual QMap<QString, QString> toExtraMap()const = 0; |
90 | 98 | ||
91 | /** | 99 | /** |
92 | * the name for a recordField | 100 | * the name for a recordField |
93 | */ | 101 | */ |
94 | virtual QString recordField(int)const = 0; | 102 | virtual QString recordField(int)const = 0; |
95 | 103 | ||
96 | /** | 104 | /** |
97 | * returns a reference of the | 105 | * returns a reference of the |
98 | * Cross Reference Manager | 106 | * Cross Reference Manager |
99 | * Partner 'One' is THIS PIM RECORD! | 107 | * Partner 'One' is THIS PIM RECORD! |
100 | * 'Two' is the Partner where we link to | 108 | * 'Two' is the Partner where we link to |
101 | */ | 109 | */ |
102 | OPimXRefManager& xrefmanager(); | 110 | OPimXRefManager& xrefmanager(); |
103 | 111 | ||
104 | /** | 112 | /** |
105 | * set the uid | 113 | * set the uid |
106 | */ | 114 | */ |
107 | virtual void setUid( int uid ); | 115 | virtual void setUid( int uid ); |
108 | 116 | ||
109 | /* | 117 | /* |
110 | * used inside the Templates for casting | 118 | * used inside the Templates for casting |
111 | * REIMPLEMENT in your .... | 119 | * REIMPLEMENT in your .... |
112 | */ | 120 | */ |
113 | static int rtti(); | 121 | static int rtti(); |
114 | 122 | ||
115 | /** | 123 | /** |
116 | * some marshalling and de marshalling code | 124 | * some marshalling and de marshalling code |
117 | * saves the OPimRecord | 125 | * saves the OPimRecord |
118 | * to and from a DataStream | 126 | * to and from a DataStream |
119 | */ | 127 | */ |
120 | virtual bool loadFromStream(QDataStream& ); | 128 | virtual bool loadFromStream(QDataStream& ); |
121 | virtual bool saveToStream( QDataStream& stream )const; | 129 | virtual bool saveToStream( QDataStream& stream )const; |
122 | 130 | ||
123 | protected: | 131 | protected: |
132 | // need to be const cause it is called from const methods | ||
133 | mutable int m_lastHit; | ||
134 | void setLastHitField( int lastHit )const; | ||
124 | Qtopia::UidGen &uidGen(); | 135 | Qtopia::UidGen &uidGen(); |
125 | // QString crossToString()const; | 136 | // QString crossToString()const; |
126 | 137 | ||
127 | private: | 138 | private: |
128 | class OPimRecordPrivate; | 139 | class OPimRecordPrivate; |
129 | OPimRecordPrivate *d; | 140 | OPimRecordPrivate *d; |
130 | OPimXRefManager m_xrefman; | 141 | OPimXRefManager m_xrefman; |
131 | static Qtopia::UidGen m_uidGen; | 142 | static Qtopia::UidGen m_uidGen; |
132 | 143 | ||
133 | private: | 144 | private: |
134 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 145 | void flush( const OPimXRefPartner&, QDataStream& stream )const; |
135 | OPimXRefPartner partner( QDataStream& ); | 146 | OPimXRefPartner partner( QDataStream& ); |
136 | }; | 147 | }; |
137 | 148 | ||
138 | 149 | ||
139 | 150 | ||
140 | #endif | 151 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index aeb69ee..a7ca975 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -860,192 +860,193 @@ void OContact::save( QString &buf ) const | |||
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 | setLastHitField( -1 ); | ||
956 | bool match; | 957 | bool match; |
957 | match = false; | 958 | match = false; |
958 | QMap<int, QString>::ConstIterator it; | 959 | QMap<int, QString>::ConstIterator it; |
959 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 960 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
960 | if ( (*it).find( r ) > -1 ) { | 961 | if ( (*it).find( r ) > -1 ) { |
961 | setLastHitField( it.key() ); | 962 | setLastHitField( it.key() ); |
962 | match = true; | 963 | match = true; |
963 | break; | 964 | break; |
964 | } | 965 | } |
965 | } | 966 | } |
966 | return match; | 967 | return match; |
967 | } | 968 | } |
968 | 969 | ||
969 | 970 | ||
970 | QString OContact::toShortText() const | 971 | QString OContact::toShortText() const |
971 | { | 972 | { |
972 | return ( fullName() ); | 973 | return ( fullName() ); |
973 | } | 974 | } |
974 | QString OContact::type() const | 975 | QString OContact::type() const |
975 | { | 976 | { |
976 | return QString::fromLatin1( "OContact" ); | 977 | return QString::fromLatin1( "OContact" ); |
977 | } | 978 | } |
978 | 979 | ||
979 | // Definition is missing ! (se) | 980 | // Definition is missing ! (se) |
980 | QMap<QString,QString> OContact::toExtraMap() const | 981 | QMap<QString,QString> OContact::toExtraMap() const |
981 | { | 982 | { |
982 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 983 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
983 | QMap <QString,QString> useless; | 984 | QMap <QString,QString> useless; |
984 | return useless; | 985 | return useless; |
985 | } | 986 | } |
986 | 987 | ||
987 | class QString OContact::recordField( int pos ) const | 988 | class QString OContact::recordField( int pos ) const |
988 | { | 989 | { |
989 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 990 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
990 | return SLFIELDS[pos]; | 991 | return SLFIELDS[pos]; |
991 | } | 992 | } |
992 | 993 | ||
993 | // In future releases, we should store birthday and anniversary | 994 | // In future releases, we should store birthday and anniversary |
994 | // internally as QDate instead of QString ! | 995 | // internally as QDate instead of QString ! |
995 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 996 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
996 | 997 | ||
997 | /*! \fn void OContact::setBirthday( const QDate& date ) | 998 | /*! \fn void OContact::setBirthday( const QDate& date ) |
998 | Sets the birthday for the contact to \a date. If date is null | 999 | Sets the birthday for the contact to \a date. If date is null |
999 | the current stored date will be removed. | 1000 | the current stored date will be removed. |
1000 | */ | 1001 | */ |
1001 | void OContact::setBirthday( const QDate &v ) | 1002 | void OContact::setBirthday( const QDate &v ) |
1002 | { | 1003 | { |
1003 | if ( v.isNull() ){ | 1004 | if ( v.isNull() ){ |
1004 | qWarning( "Remove Birthday"); | 1005 | qWarning( "Remove Birthday"); |
1005 | replace( Qtopia::Birthday, QString::null ); | 1006 | replace( Qtopia::Birthday, QString::null ); |
1006 | return; | 1007 | return; |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | if ( v.isValid() ) | 1010 | if ( v.isValid() ) |
1010 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1011 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1011 | 1012 | ||
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | 1015 | ||
1015 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1016 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1016 | Sets the anniversary of the contact to \a date. If date is | 1017 | Sets the anniversary of the contact to \a date. If date is |
1017 | null, the current stored date will be removed. | 1018 | null, the current stored date will be removed. |
1018 | */ | 1019 | */ |
1019 | void OContact::setAnniversary( const QDate &v ) | 1020 | void OContact::setAnniversary( const QDate &v ) |
1020 | { | 1021 | { |
1021 | if ( v.isNull() ){ | 1022 | if ( v.isNull() ){ |
1022 | qWarning( "Remove Anniversary"); | 1023 | qWarning( "Remove Anniversary"); |
1023 | replace( Qtopia::Anniversary, QString::null ); | 1024 | replace( Qtopia::Anniversary, QString::null ); |
1024 | return; | 1025 | return; |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | if ( v.isValid() ) | 1028 | if ( v.isValid() ) |
1028 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1029 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | /*! \fn QDate OContact::birthday() const | 1032 | /*! \fn QDate OContact::birthday() const |
1032 | Returns the birthday of the contact. | 1033 | Returns the birthday of the contact. |
1033 | */ | 1034 | */ |
1034 | QDate OContact::birthday() const | 1035 | QDate OContact::birthday() const |
1035 | { | 1036 | { |
1036 | QString str = find( Qtopia::Birthday ); | 1037 | QString str = find( Qtopia::Birthday ); |
1037 | qWarning ("Birthday %s", str.latin1() ); | 1038 | qWarning ("Birthday %s", str.latin1() ); |
1038 | if ( !str.isEmpty() ) | 1039 | if ( !str.isEmpty() ) |
1039 | return OConversion::dateFromString ( str ); | 1040 | return OConversion::dateFromString ( str ); |
1040 | else | 1041 | else |
1041 | return QDate(); | 1042 | return QDate(); |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | 1045 | ||
1045 | /*! \fn QDate OContact::anniversary() const | 1046 | /*! \fn QDate OContact::anniversary() const |
1046 | Returns the anniversary of the contact. | 1047 | Returns the anniversary of the contact. |
1047 | */ | 1048 | */ |
1048 | QDate OContact::anniversary() const | 1049 | QDate OContact::anniversary() const |
1049 | { | 1050 | { |
1050 | QDate empty; | 1051 | QDate empty; |
1051 | QString str = find( Qtopia::Anniversary ); | 1052 | QString str = find( Qtopia::Anniversary ); |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index f79f0f3..dd2de17 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -121,124 +121,120 @@ public: | |||
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 | int lastHitField() const {return m_lastHitField;}; | ||
218 | protected: | ||
219 | mutable int m_lastHitField; | ||
220 | void setLastHitField(int i) const { m_lastHitField = i; }; | ||
221 | 217 | ||
222 | private: | 218 | private: |
223 | // The XML-Backend needs some access to the private functions | 219 | // The XML-Backend needs some access to the private functions |
224 | friend class OContactAccessBackend_XML; | 220 | friend class OContactAccessBackend_XML; |
225 | 221 | ||
226 | void insert( int key, const QString &value ); | 222 | void insert( int key, const QString &value ); |
227 | void replace( int key, const QString &value ); | 223 | void replace( int key, const QString &value ); |
228 | QString find( int key ) const; | 224 | QString find( int key ) const; |
229 | static QStringList fields(); | 225 | static QStringList fields(); |
230 | 226 | ||
231 | void save( QString &buf ) const; | 227 | void save( QString &buf ) const; |
232 | 228 | ||
233 | QString displayAddress( const QString &street, | 229 | QString displayAddress( const QString &street, |
234 | const QString &city, | 230 | const QString &city, |
235 | const QString &state, | 231 | const QString &state, |
236 | const QString &zip, | 232 | const QString &zip, |
237 | const QString &country ) const; | 233 | const QString &country ) const; |
238 | 234 | ||
239 | QMap<int, QString> mMap; | 235 | QMap<int, QString> mMap; |
240 | ContactPrivate *d; | 236 | ContactPrivate *d; |
241 | }; | 237 | }; |
242 | 238 | ||
243 | 239 | ||
244 | #endif | 240 | #endif |