Diffstat (limited to 'libopie2/opiepim/ocontactfields.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 496 |
1 files changed, 253 insertions, 243 deletions
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index deaa1e5..bec00f7 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
@@ -27,17 +27,20 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/ocontactfields.h> | 30 | #include "ocontactfields.h" |
31 | 31 | ||
32 | #include <qstringlist.h> | 32 | /* OPIE */ |
33 | #include <opie2/ocontact.h> | ||
34 | #include <qpe/recordfields.h> // We should use our own enum in the future .. | ||
35 | #include <qpe/config.h> | ||
36 | |||
37 | /* QT */ | ||
33 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | #include <qstringlist.h> | ||
34 | 40 | ||
35 | // We should use our own enum in the future .. | ||
36 | #include <qpe/recordfields.h> | ||
37 | #include <qpe/config.h> | ||
38 | #include <opie2/ocontact.h> | ||
39 | 41 | ||
40 | namespace Opie { | 42 | namespace Opie |
43 | { | ||
41 | /*! | 44 | /*! |
42 | \internal | 45 | \internal |
43 | Returns a list of personal field names for a contact. | 46 | Returns a list of personal field names for a contact. |
@@ -47,9 +50,9 @@ QStringList OContactFields::personalfields( bool sorted, bool translated ) | |||
47 | QStringList list; | 50 | QStringList list; |
48 | QMap<int, QString> mapIdToStr; | 51 | QMap<int, QString> mapIdToStr; |
49 | if ( translated ) | 52 | if ( translated ) |
50 | mapIdToStr = idToTrFields(); | 53 | mapIdToStr = idToTrFields(); |
51 | else | 54 | else |
52 | mapIdToStr = idToUntrFields(); | 55 | mapIdToStr = idToUntrFields(); |
53 | 56 | ||
54 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | 57 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
55 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | 58 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
@@ -68,7 +71,7 @@ QStringList OContactFields::personalfields( bool sorted, bool translated ) | |||
68 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 71 | list.append( mapIdToStr[ Qtopia::Notes ] ); |
69 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 72 | list.append( mapIdToStr[ Qtopia::Groups ] ); |
70 | 73 | ||
71 | if (sorted) list.sort(); | 74 | if ( sorted ) list.sort(); |
72 | return list; | 75 | return list; |
73 | } | 76 | } |
74 | 77 | ||
@@ -81,9 +84,9 @@ QStringList OContactFields::detailsfields( bool sorted, bool translated ) | |||
81 | QStringList list; | 84 | QStringList list; |
82 | QMap<int, QString> mapIdToStr; | 85 | QMap<int, QString> mapIdToStr; |
83 | if ( translated ) | 86 | if ( translated ) |
84 | mapIdToStr = idToTrFields(); | 87 | mapIdToStr = idToTrFields(); |
85 | else | 88 | else |
86 | mapIdToStr = idToUntrFields(); | 89 | mapIdToStr = idToUntrFields(); |
87 | 90 | ||
88 | list.append( mapIdToStr[ Qtopia::Office ] ); | 91 | list.append( mapIdToStr[ Qtopia::Office ] ); |
89 | list.append( mapIdToStr[ Qtopia::Profession ] ); | 92 | list.append( mapIdToStr[ Qtopia::Profession ] ); |
@@ -97,7 +100,7 @@ QStringList OContactFields::detailsfields( bool sorted, bool translated ) | |||
97 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | 100 | list.append( mapIdToStr[ Qtopia::Nickname ] ); |
98 | list.append( mapIdToStr[ Qtopia::Children ] ); | 101 | list.append( mapIdToStr[ Qtopia::Children ] ); |
99 | 102 | ||
100 | if (sorted) list.sort(); | 103 | if ( sorted ) list.sort(); |
101 | return list; | 104 | return list; |
102 | } | 105 | } |
103 | 106 | ||
@@ -110,26 +113,26 @@ QStringList OContactFields::phonefields( bool sorted, bool translated ) | |||
110 | QStringList list; | 113 | QStringList list; |
111 | QMap<int, QString> mapIdToStr; | 114 | QMap<int, QString> mapIdToStr; |
112 | if ( translated ) | 115 | if ( translated ) |
113 | mapIdToStr = idToTrFields(); | 116 | mapIdToStr = idToTrFields(); |
114 | else | 117 | else |
115 | mapIdToStr = idToUntrFields(); | 118 | mapIdToStr = idToUntrFields(); |
116 | 119 | ||
117 | list.append( mapIdToStr[Qtopia::BusinessPhone] ); | 120 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); |
118 | list.append( mapIdToStr[Qtopia::BusinessFax] ); | 121 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); |
119 | list.append( mapIdToStr[Qtopia::BusinessMobile] ); | 122 | list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); |
120 | list.append( mapIdToStr[Qtopia::BusinessPager] ); | 123 | list.append( mapIdToStr[ Qtopia::BusinessPager ] ); |
121 | list.append( mapIdToStr[Qtopia::BusinessWebPage] ); | 124 | list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); |
122 | 125 | ||
123 | list.append( mapIdToStr[Qtopia::DefaultEmail] ); | 126 | list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); |
124 | list.append( mapIdToStr[Qtopia::Emails] ); | 127 | list.append( mapIdToStr[ Qtopia::Emails ] ); |
125 | 128 | ||
126 | list.append( mapIdToStr[Qtopia::HomePhone] ); | 129 | list.append( mapIdToStr[ Qtopia::HomePhone ] ); |
127 | list.append( mapIdToStr[Qtopia::HomeFax] ); | 130 | list.append( mapIdToStr[ Qtopia::HomeFax ] ); |
128 | list.append( mapIdToStr[Qtopia::HomeMobile] ); | 131 | list.append( mapIdToStr[ Qtopia::HomeMobile ] ); |
129 | // list.append( mapIdToStr[Qtopia::HomePager] ); | 132 | // list.append( mapIdToStr[Qtopia::HomePager] ); |
130 | list.append( mapIdToStr[Qtopia::HomeWebPage] ); | 133 | list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); |
131 | 134 | ||
132 | if (sorted) list.sort(); | 135 | if ( sorted ) list.sort(); |
133 | 136 | ||
134 | return list; | 137 | return list; |
135 | } | 138 | } |
@@ -143,29 +146,29 @@ QStringList OContactFields::fields( bool sorted, bool translated ) | |||
143 | QStringList list; | 146 | QStringList list; |
144 | QMap<int, QString> mapIdToStr; | 147 | QMap<int, QString> mapIdToStr; |
145 | if ( translated ) | 148 | if ( translated ) |
146 | mapIdToStr = idToTrFields(); | 149 | mapIdToStr = idToTrFields(); |
147 | else | 150 | else |
148 | mapIdToStr = idToUntrFields(); | 151 | mapIdToStr = idToUntrFields(); |
149 | 152 | ||
150 | list += personalfields( sorted, translated ); | 153 | list += personalfields( sorted, translated ); |
151 | 154 | ||
152 | list += phonefields( sorted, translated ); | 155 | list += phonefields( sorted, translated ); |
153 | 156 | ||
154 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); | 157 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); |
155 | list.append( mapIdToStr[Qtopia::BusinessCity] ); | 158 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); |
156 | list.append( mapIdToStr[Qtopia::BusinessState] ); | 159 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); |
157 | list.append( mapIdToStr[Qtopia::BusinessZip] ); | 160 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); |
158 | list.append( mapIdToStr[Qtopia::BusinessCountry] ); | 161 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); |
159 | 162 | ||
160 | list.append( mapIdToStr[Qtopia::HomeStreet] ); | 163 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); |
161 | list.append( mapIdToStr[Qtopia::HomeCity] ); | 164 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); |
162 | list.append( mapIdToStr[Qtopia::HomeState] ); | 165 | list.append( mapIdToStr[ Qtopia::HomeState ] ); |
163 | list.append( mapIdToStr[Qtopia::HomeZip] ); | 166 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); |
164 | list.append( mapIdToStr[Qtopia::HomeCountry] ); | 167 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); |
165 | 168 | ||
166 | list += detailsfields( sorted, translated ); | 169 | list += detailsfields( sorted, translated ); |
167 | 170 | ||
168 | if (sorted) list.sort(); | 171 | if ( sorted ) list.sort(); |
169 | 172 | ||
170 | return list; | 173 | return list; |
171 | } | 174 | } |
@@ -177,7 +180,7 @@ QStringList OContactFields::fields( bool sorted, bool translated ) | |||
177 | */ | 180 | */ |
178 | QStringList OContactFields::untrpersonalfields( bool sorted ) | 181 | QStringList OContactFields::untrpersonalfields( bool sorted ) |
179 | { | 182 | { |
180 | return personalfields( sorted, false ); | 183 | return personalfields( sorted, false ); |
181 | } | 184 | } |
182 | 185 | ||
183 | 186 | ||
@@ -187,7 +190,7 @@ QStringList OContactFields::untrpersonalfields( bool sorted ) | |||
187 | */ | 190 | */ |
188 | QStringList OContactFields::trpersonalfields( bool sorted ) | 191 | QStringList OContactFields::trpersonalfields( bool sorted ) |
189 | { | 192 | { |
190 | return personalfields( sorted, true ); | 193 | return personalfields( sorted, true ); |
191 | } | 194 | } |
192 | 195 | ||
193 | 196 | ||
@@ -197,7 +200,7 @@ QStringList OContactFields::trpersonalfields( bool sorted ) | |||
197 | */ | 200 | */ |
198 | QStringList OContactFields::untrdetailsfields( bool sorted ) | 201 | QStringList OContactFields::untrdetailsfields( bool sorted ) |
199 | { | 202 | { |
200 | return detailsfields( sorted, false ); | 203 | return detailsfields( sorted, false ); |
201 | } | 204 | } |
202 | 205 | ||
203 | 206 | ||
@@ -207,7 +210,7 @@ QStringList OContactFields::untrdetailsfields( bool sorted ) | |||
207 | */ | 210 | */ |
208 | QStringList OContactFields::trdetailsfields( bool sorted ) | 211 | QStringList OContactFields::trdetailsfields( bool sorted ) |
209 | { | 212 | { |
210 | return detailsfields( sorted, true ); | 213 | return detailsfields( sorted, true ); |
211 | } | 214 | } |
212 | 215 | ||
213 | 216 | ||
@@ -217,7 +220,7 @@ QStringList OContactFields::trdetailsfields( bool sorted ) | |||
217 | */ | 220 | */ |
218 | QStringList OContactFields::trphonefields( bool sorted ) | 221 | QStringList OContactFields::trphonefields( bool sorted ) |
219 | { | 222 | { |
220 | return phonefields( sorted, true ); | 223 | return phonefields( sorted, true ); |
221 | } | 224 | } |
222 | 225 | ||
223 | /*! | 226 | /*! |
@@ -226,7 +229,7 @@ QStringList OContactFields::trphonefields( bool sorted ) | |||
226 | */ | 229 | */ |
227 | QStringList OContactFields::untrphonefields( bool sorted ) | 230 | QStringList OContactFields::untrphonefields( bool sorted ) |
228 | { | 231 | { |
229 | return phonefields( sorted, false ); | 232 | return phonefields( sorted, false ); |
230 | } | 233 | } |
231 | 234 | ||
232 | 235 | ||
@@ -236,7 +239,7 @@ QStringList OContactFields::untrphonefields( bool sorted ) | |||
236 | */ | 239 | */ |
237 | QStringList OContactFields::trfields( bool sorted ) | 240 | QStringList OContactFields::trfields( bool sorted ) |
238 | { | 241 | { |
239 | return fields( sorted, true ); | 242 | return fields( sorted, true ); |
240 | } | 243 | } |
241 | 244 | ||
242 | /*! | 245 | /*! |
@@ -250,258 +253,265 @@ QStringList OContactFields::untrfields( bool sorted ) | |||
250 | 253 | ||
251 | QMap<int, QString> OContactFields::idToTrFields() | 254 | QMap<int, QString> OContactFields::idToTrFields() |
252 | { | 255 | { |
253 | QMap<int, QString> ret_map; | 256 | QMap<int, QString> ret_map; |
254 | 257 | ||
255 | ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); | 258 | ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); |
256 | ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); | 259 | ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); |
257 | 260 | ||
258 | ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") ); | 261 | ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) ); |
259 | ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); | 262 | ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); |
260 | ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); | 263 | ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); |
261 | ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); | 264 | ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); |
262 | ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" )); | 265 | ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) ); |
263 | ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); | 266 | ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); |
264 | 267 | ||
265 | ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); | 268 | ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); |
266 | ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); | 269 | ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); |
267 | ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); | 270 | ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); |
268 | ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); | 271 | ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); |
269 | ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); | 272 | ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); |
270 | ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" )); | 273 | ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) ); |
271 | 274 | ||
272 | 275 | ||
273 | ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); | 276 | ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); |
274 | ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); | 277 | ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); |
275 | 278 | ||
276 | ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); | 279 | ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); |
277 | ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); | 280 | ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); |
278 | ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); | 281 | ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); |
279 | 282 | ||
280 | // business | 283 | // business |
281 | ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); | 284 | ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); |
282 | ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); | 285 | ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); |
283 | ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); | 286 | ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); |
284 | ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); | 287 | ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); |
285 | ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); | 288 | ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); |
286 | ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); | 289 | ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); |
287 | ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); | 290 | ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); |
288 | 291 | ||
289 | ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); | 292 | ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); |
290 | ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); | 293 | ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); |
291 | ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); | 294 | ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); |
292 | ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); | 295 | ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); |
293 | 296 | ||
294 | // home | 297 | // home |
295 | ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); | 298 | ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); |
296 | ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); | 299 | ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); |
297 | ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); | 300 | ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); |
298 | ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); | 301 | ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); |
299 | ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); | 302 | ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); |
300 | ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); | 303 | ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); |
301 | 304 | ||
302 | //personal | 305 | //personal |
303 | ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); | 306 | ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); |
304 | ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); | 307 | ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); |
305 | ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); | 308 | ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); |
306 | ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); | 309 | ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); |
307 | ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); | 310 | ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); |
308 | ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); | 311 | ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); |
309 | 312 | ||
310 | // other | 313 | // other |
311 | ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); | 314 | ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); |
312 | 315 | ||
313 | 316 | ||
314 | return ret_map; | 317 | return ret_map; |
315 | } | 318 | } |
316 | 319 | ||
317 | QMap<int, QString> OContactFields::idToUntrFields() | 320 | QMap<int, QString> OContactFields::idToUntrFields() |
318 | { | 321 | { |
319 | QMap<int, QString> ret_map; | 322 | QMap<int, QString> ret_map; |
320 | 323 | ||
321 | ret_map.insert( Qtopia::AddressUid, "User Id" ); | 324 | ret_map.insert( Qtopia::AddressUid, "User Id" ); |
322 | ret_map.insert( Qtopia::AddressCategory, "Categories" ); | 325 | ret_map.insert( Qtopia::AddressCategory, "Categories" ); |
323 | 326 | ||
324 | ret_map.insert( Qtopia::Title, "Name Title" ); | 327 | ret_map.insert( Qtopia::Title, "Name Title" ); |
325 | ret_map.insert( Qtopia::FirstName, "First Name" ); | 328 | ret_map.insert( Qtopia::FirstName, "First Name" ); |
326 | ret_map.insert( Qtopia::MiddleName, "Middle Name" ); | 329 | ret_map.insert( Qtopia::MiddleName, "Middle Name" ); |
327 | ret_map.insert( Qtopia::LastName, "Last Name" ); | 330 | ret_map.insert( Qtopia::LastName, "Last Name" ); |
328 | ret_map.insert( Qtopia::Suffix, "Suffix" ); | 331 | ret_map.insert( Qtopia::Suffix, "Suffix" ); |
329 | ret_map.insert( Qtopia::FileAs, "File As" ); | 332 | ret_map.insert( Qtopia::FileAs, "File As" ); |
330 | 333 | ||
331 | ret_map.insert( Qtopia::JobTitle, "Job Title" ); | 334 | ret_map.insert( Qtopia::JobTitle, "Job Title" ); |
332 | ret_map.insert( Qtopia::Department, "Department" ); | 335 | ret_map.insert( Qtopia::Department, "Department" ); |
333 | ret_map.insert( Qtopia::Company, "Company" ); | 336 | ret_map.insert( Qtopia::Company, "Company" ); |
334 | ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); | 337 | ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); |
335 | ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); | 338 | ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); |
336 | ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); | 339 | ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); |
337 | 340 | ||
338 | 341 | ||
339 | ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); | 342 | ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); |
340 | ret_map.insert( Qtopia::Emails, "Emails" ); | 343 | ret_map.insert( Qtopia::Emails, "Emails" ); |
341 | 344 | ||
342 | ret_map.insert( Qtopia::HomePhone, "Home Phone" ); | 345 | ret_map.insert( Qtopia::HomePhone, "Home Phone" ); |
343 | ret_map.insert( Qtopia::HomeFax, "Home Fax" ); | 346 | ret_map.insert( Qtopia::HomeFax, "Home Fax" ); |
344 | ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); | 347 | ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); |
345 | 348 | ||
346 | // business | 349 | // business |
347 | ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); | 350 | ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); |
348 | ret_map.insert( Qtopia::BusinessCity, "Business City" ); | 351 | ret_map.insert( Qtopia::BusinessCity, "Business City" ); |
349 | ret_map.insert( Qtopia::BusinessState, "Business State" ); | 352 | ret_map.insert( Qtopia::BusinessState, "Business State" ); |
350 | ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); | 353 | ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); |
351 | ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); | 354 | ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); |
352 | ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); | 355 | ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); |
353 | ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); | 356 | ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); |
354 | 357 | ||
355 | ret_map.insert( Qtopia::Office, "Office" ); | 358 | ret_map.insert( Qtopia::Office, "Office" ); |
356 | ret_map.insert( Qtopia::Profession, "Profession" ); | 359 | ret_map.insert( Qtopia::Profession, "Profession" ); |
357 | ret_map.insert( Qtopia::Assistant, "Assistant" ); | 360 | ret_map.insert( Qtopia::Assistant, "Assistant" ); |
358 | ret_map.insert( Qtopia::Manager, "Manager" ); | 361 | ret_map.insert( Qtopia::Manager, "Manager" ); |
359 | 362 | ||
360 | // home | 363 | // home |
361 | ret_map.insert( Qtopia::HomeStreet, "Home Street" ); | 364 | ret_map.insert( Qtopia::HomeStreet, "Home Street" ); |
362 | ret_map.insert( Qtopia::HomeCity, "Home City" ); | 365 | ret_map.insert( Qtopia::HomeCity, "Home City" ); |
363 | ret_map.insert( Qtopia::HomeState, "Home State" ); | 366 | ret_map.insert( Qtopia::HomeState, "Home State" ); |
364 | ret_map.insert( Qtopia::HomeZip, "Home Zip" ); | 367 | ret_map.insert( Qtopia::HomeZip, "Home Zip" ); |
365 | ret_map.insert( Qtopia::HomeCountry, "Home Country" ); | 368 | ret_map.insert( Qtopia::HomeCountry, "Home Country" ); |
366 | ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); | 369 | ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); |
367 | 370 | ||
368 | //personal | 371 | //personal |
369 | ret_map.insert( Qtopia::Spouse, "Spouse" ); | 372 | ret_map.insert( Qtopia::Spouse, "Spouse" ); |
370 | ret_map.insert( Qtopia::Gender, "Gender" ); | 373 | ret_map.insert( Qtopia::Gender, "Gender" ); |
371 | ret_map.insert( Qtopia::Birthday, "Birthday" ); | 374 | ret_map.insert( Qtopia::Birthday, "Birthday" ); |
372 | ret_map.insert( Qtopia::Anniversary, "Anniversary" ); | 375 | ret_map.insert( Qtopia::Anniversary, "Anniversary" ); |
373 | ret_map.insert( Qtopia::Nickname, "Nickname" ); | 376 | ret_map.insert( Qtopia::Nickname, "Nickname" ); |
374 | ret_map.insert( Qtopia::Children, "Children" ); | 377 | ret_map.insert( Qtopia::Children, "Children" ); |
375 | 378 | ||
376 | // other | 379 | // other |
377 | ret_map.insert( Qtopia::Notes, "Notes" ); | 380 | ret_map.insert( Qtopia::Notes, "Notes" ); |
378 | ret_map.insert( Qtopia::Groups, "Groups" ); | 381 | ret_map.insert( Qtopia::Groups, "Groups" ); |
379 | 382 | ||
380 | 383 | ||
381 | return ret_map; | 384 | return ret_map; |
382 | } | 385 | } |
383 | 386 | ||
384 | QMap<QString, int> OContactFields::trFieldsToId() | 387 | QMap<QString, int> OContactFields::trFieldsToId() |
385 | { | 388 | { |
386 | QMap<int, QString> idtostr = idToTrFields(); | 389 | QMap<int, QString> idtostr = idToTrFields(); |
387 | QMap<QString, int> ret_map; | 390 | QMap<QString, int> ret_map; |
388 | 391 | ||
389 | 392 | ||
390 | QMap<int, QString>::Iterator it; | 393 | QMap<int, QString>::Iterator it; |
391 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) | 394 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) |
392 | ret_map.insert( *it, it.key() ); | 395 | ret_map.insert( *it, it.key() ); |
393 | 396 | ||
394 | 397 | ||
395 | return ret_map; | 398 | return ret_map; |
396 | } | 399 | } |
397 | 400 | ||
398 | /* ======================================================================= */ | 401 | /* ======================================================================= */ |
399 | 402 | ||
400 | QMap<QString, int> OContactFields::untrFieldsToId() | 403 | QMap<QString, int> OContactFields::untrFieldsToId() |
401 | { | 404 | { |
402 | QMap<int, QString> idtostr = idToUntrFields(); | 405 | QMap<int, QString> idtostr = idToUntrFields(); |
403 | QMap<QString, int> ret_map; | 406 | QMap<QString, int> ret_map; |
404 | 407 | ||
405 | 408 | ||
406 | QMap<int, QString>::Iterator it; | 409 | QMap<int, QString>::Iterator it; |
407 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) | 410 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) |
408 | ret_map.insert( *it, it.key() ); | 411 | ret_map.insert( *it, it.key() ); |
409 | 412 | ||
410 | 413 | ||
411 | return ret_map; | 414 | return ret_map; |
412 | } | 415 | } |
413 | 416 | ||
414 | 417 | ||
415 | OContactFields::OContactFields(): | 418 | OContactFields::OContactFields() : |
416 | fieldOrder( DEFAULT_FIELD_ORDER ), | 419 | fieldOrder( DEFAULT_FIELD_ORDER ), |
417 | changedFieldOrder( false ) | 420 | changedFieldOrder( false ) |
418 | { | 421 | { |
419 | // Get the global field order from the config file and | 422 | // Get the global field order from the config file and |
420 | // use it as a start pattern | 423 | // use it as a start pattern |
421 | Config cfg ( "AddressBook" ); | 424 | Config cfg ( "AddressBook" ); |
422 | cfg.setGroup( "ContactFieldOrder" ); | 425 | cfg.setGroup( "ContactFieldOrder" ); |
423 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); | 426 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); |
424 | } | 427 | } |
425 | 428 | ||
426 | OContactFields::~OContactFields(){ | 429 | OContactFields::~OContactFields() |
430 | { | ||
427 | 431 | ||
428 | // We will store the fieldorder into the config file | 432 | // We will store the fieldorder into the config file |
429 | // to reuse it for the future.. | 433 | // to reuse it for the future.. |
430 | if ( changedFieldOrder ){ | 434 | if ( changedFieldOrder ) |
431 | Config cfg ( "AddressBook" ); | 435 | { |
432 | cfg.setGroup( "ContactFieldOrder" ); | 436 | Config cfg ( "AddressBook" ); |
433 | cfg.writeEntry( "General", globalFieldOrder ); | 437 | cfg.setGroup( "ContactFieldOrder" ); |
434 | } | 438 | cfg.writeEntry( "General", globalFieldOrder ); |
439 | } | ||
435 | } | 440 | } |
436 | 441 | ||
437 | 442 | ||
438 | 443 | ||
439 | void OContactFields::saveToRecord( OContact &cnt ){ | 444 | void OContactFields::saveToRecord( OContact &cnt ) |
445 | { | ||
440 | 446 | ||
441 | qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1()); | 447 | qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); |
442 | 448 | ||
443 | // Store fieldorder into this contact. | 449 | // Store fieldorder into this contact. |
444 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); | 450 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); |
445 | 451 | ||
446 | globalFieldOrder = fieldOrder; | 452 | globalFieldOrder = fieldOrder; |
447 | changedFieldOrder = true; | 453 | changedFieldOrder = true; |
448 | 454 | ||
449 | } | 455 | } |
450 | 456 | ||
451 | void OContactFields::loadFromRecord( const OContact &cnt ){ | 457 | void OContactFields::loadFromRecord( const OContact &cnt ) |
452 | qDebug("ocontactfields loadFromRecord"); | 458 | { |
453 | qDebug("loading >%s<",cnt.fullName().latin1()); | 459 | qDebug( "ocontactfields loadFromRecord" ); |
460 | qDebug( "loading >%s<", cnt.fullName().latin1() ); | ||
454 | 461 | ||
455 | // Get fieldorder for this contact. If none is defined, | 462 | // Get fieldorder for this contact. If none is defined, |
456 | // we will use the global one from the config file.. | 463 | // we will use the global one from the config file.. |
457 | 464 | ||
458 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); | 465 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); |
459 | 466 | ||
460 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); | 467 | qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); |
461 | 468 | ||
462 | if (fieldOrder.isEmpty()){ | 469 | if ( fieldOrder.isEmpty() ) |
463 | fieldOrder = globalFieldOrder; | 470 | { |
464 | } | 471 | fieldOrder = globalFieldOrder; |
472 | } | ||
465 | 473 | ||
466 | 474 | ||
467 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); | 475 | qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); |
468 | } | 476 | } |
469 | 477 | ||
470 | void OContactFields::setFieldOrder( int num, int index ){ | 478 | void OContactFields::setFieldOrder( int num, int index ) |
471 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); | 479 | { |
480 | qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); | ||
472 | 481 | ||
473 | fieldOrder[num] = QString::number( index, 16 )[0]; | 482 | fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; |
474 | 483 | ||
475 | // We will store this new fieldorder globally to | 484 | // We will store this new fieldorder globally to |
476 | // remember it for contacts which have none | 485 | // remember it for contacts which have none |
477 | globalFieldOrder = fieldOrder; | 486 | globalFieldOrder = fieldOrder; |
478 | changedFieldOrder = true; | 487 | changedFieldOrder = true; |
479 | 488 | ||
480 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 489 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); |
481 | } | 490 | } |
482 | 491 | ||
483 | int OContactFields::getFieldOrder( int num, int defIndex ){ | 492 | int OContactFields::getFieldOrder( int num, int defIndex ) |
484 | qDebug("ocontactfields getFieldOrder"); | 493 | { |
485 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 494 | qDebug( "ocontactfields getFieldOrder" ); |
495 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); | ||
486 | 496 | ||
487 | // Get index of combo as char.. | 497 | // Get index of combo as char.. |
488 | QChar poschar = fieldOrder[num]; | 498 | QChar poschar = fieldOrder[ num ]; |
489 | 499 | ||
490 | bool ok; | 500 | bool ok; |
491 | int ret = 0; | 501 | int ret = 0; |
492 | // Convert char to number.. | 502 | // Convert char to number.. |
493 | if ( !( poschar == QChar::null ) ) | 503 | if ( !( poschar == QChar::null ) ) |
494 | ret = QString( poschar ).toInt(&ok, 16); | 504 | ret = QString( poschar ).toInt( &ok, 16 ); |
495 | else | 505 | else |
496 | ok = false; | 506 | ok = false; |
497 | 507 | ||
498 | // Return default value if index for | 508 | // Return default value if index for |
499 | // num was not set or if anything else happened.. | 509 | // num was not set or if anything else happened.. |
500 | if ( !ok ) ret = defIndex; | 510 | if ( !ok ) ret = defIndex; |
501 | 511 | ||
502 | qDebug("returning >%i<",ret); | 512 | qDebug( "returning >%i<", ret ); |
503 | 513 | ||
504 | return ret; | 514 | return ret; |
505 | 515 | ||
506 | } | 516 | } |
507 | 517 | ||