-rw-r--r-- | libopie/pim/ocontact.cpp | 29 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 29 |
2 files changed, 42 insertions, 16 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index 734f5a2..bf27d0f 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -1,1635 +1,1648 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #define QTOPIA_INTERNAL_CONTACT_MRE | 22 | #define QTOPIA_INTERNAL_CONTACT_MRE |
23 | 23 | ||
24 | #include "ocontact.h" | 24 | #include "ocontact.h" |
25 | #include "../../library/backend/vobject_p.h" | 25 | #include "../../library/backend/vobject_p.h" |
26 | #include "../../library/backend/qfiledirect_p.h" | 26 | #include "../../library/backend/qfiledirect_p.h" |
27 | 27 | ||
28 | #include <qpe/stringutil.h> | 28 | #include <qpe/stringutil.h> |
29 | #include <qpe/timeconversion.h> | 29 | #include <qpe/timeconversion.h> |
30 | #include <qpe/timestring.h> | 30 | #include <qpe/timestring.h> |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qstylesheet.h> | 34 | #include <qstylesheet.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | 39 | ||
40 | /*! | 40 | /*! |
41 | \class Contact contact.h | 41 | \class Contact contact.h |
42 | \brief The Contact class holds the data of an address book entry. | 42 | \brief The Contact class holds the data of an address book entry. |
43 | 43 | ||
44 | This data includes information the name of the person, contact | 44 | This data includes information the name of the person, contact |
45 | information, and business information such as deparment and job title. | 45 | information, and business information such as deparment and job title. |
46 | 46 | ||
47 | \ingroup qtopiaemb | 47 | \ingroup qtopiaemb |
48 | \ingroup qtopiadesktop | 48 | \ingroup qtopiadesktop |
49 | */ | 49 | */ |
50 | 50 | ||
51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); | 51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); |
52 | 52 | ||
53 | /*! | 53 | /*! |
54 | Creates a new, empty contact. | 54 | Creates a new, empty contact. |
55 | */ | 55 | */ |
56 | OContact::OContact() | 56 | OContact::OContact() |
57 | : OPimRecord(), mMap(), d( 0 ) | 57 | : OPimRecord(), mMap(), d( 0 ) |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | /*! | 61 | /*! |
62 | \internal | 62 | \internal |
63 | Creates a new contact. The properties of the contact are | 63 | Creates a new contact. The properties of the contact are |
64 | set from \a fromMap. | 64 | set from \a fromMap. |
65 | */ | 65 | */ |
66 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 66 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
67 | OPimRecord(), mMap( fromMap ), d( 0 ) | 67 | OPimRecord(), mMap( fromMap ), d( 0 ) |
68 | { | 68 | { |
69 | QString cats = mMap[ Qtopia::AddressCategory ]; | 69 | QString cats = mMap[ Qtopia::AddressCategory ]; |
70 | if ( !cats.isEmpty() ) | 70 | if ( !cats.isEmpty() ) |
71 | setCategories( idsFromString( cats ) ); | 71 | setCategories( idsFromString( cats ) ); |
72 | QString uidStr = find( Qtopia::AddressUid ); | 72 | QString uidStr = find( Qtopia::AddressUid ); |
73 | 73 | ||
74 | if ( uidStr.isEmpty() ) | 74 | if ( uidStr.isEmpty() ) |
75 | setUid( uidGen().generate() ); | 75 | setUid( uidGen().generate() ); |
76 | else | 76 | else |
77 | setUid( uidStr.toInt() ); | 77 | setUid( uidStr.toInt() ); |
78 | 78 | ||
79 | if ( !uidStr.isEmpty() ) | 79 | if ( !uidStr.isEmpty() ) |
80 | setUid( uidStr.toInt() ); | 80 | setUid( uidStr.toInt() ); |
81 | } | 81 | } |
82 | 82 | ||
83 | /*! | 83 | /*! |
84 | Destroys a contact. | 84 | Destroys a contact. |
85 | */ | 85 | */ |
86 | OContact::~OContact() | 86 | OContact::~OContact() |
87 | { | 87 | { |
88 | } | 88 | } |
89 | 89 | ||
90 | /*! \fn void OContact::setTitle( const QString &str ) | 90 | /*! \fn void OContact::setTitle( const QString &str ) |
91 | Sets the title of the contact to \a str. | 91 | Sets the title of the contact to \a str. |
92 | */ | 92 | */ |
93 | 93 | ||
94 | /*! \fn void OContact::setFirstName( const QString &str ) | 94 | /*! \fn void OContact::setFirstName( const QString &str ) |
95 | Sets the first name of the contact to \a str. | 95 | Sets the first name of the contact to \a str. |
96 | */ | 96 | */ |
97 | 97 | ||
98 | /*! \fn void OContact::setMiddleName( const QString &str ) | 98 | /*! \fn void OContact::setMiddleName( const QString &str ) |
99 | Sets the middle name of the contact to \a str. | 99 | Sets the middle name of the contact to \a str. |
100 | */ | 100 | */ |
101 | 101 | ||
102 | /*! \fn void OContact::setLastName( const QString &str ) | 102 | /*! \fn void OContact::setLastName( const QString &str ) |
103 | Sets the last name of the contact to \a str. | 103 | Sets the last name of the contact to \a str. |
104 | */ | 104 | */ |
105 | 105 | ||
106 | /*! \fn void OContact::setSuffix( const QString &str ) | 106 | /*! \fn void OContact::setSuffix( const QString &str ) |
107 | Sets the suffix of the contact to \a str. | 107 | Sets the suffix of the contact to \a str. |
108 | */ | 108 | */ |
109 | 109 | ||
110 | /*! \fn void OContact::setFileAs( const QString &str ) | 110 | /*! \fn void OContact::setFileAs( const QString &str ) |
111 | Sets the contact to filed as \a str. | 111 | Sets the contact to filed as \a str. |
112 | */ | 112 | */ |
113 | 113 | ||
114 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 114 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
115 | Sets the default email of the contact to \a str. | 115 | Sets the default email of the contact to \a str. |
116 | */ | 116 | */ |
117 | 117 | ||
118 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 118 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
119 | Sets the home street address of the contact to \a str. | 119 | Sets the home street address of the contact to \a str. |
120 | */ | 120 | */ |
121 | 121 | ||
122 | /*! \fn void OContact::setHomeCity( const QString &str ) | 122 | /*! \fn void OContact::setHomeCity( const QString &str ) |
123 | Sets the home city of the contact to \a str. | 123 | Sets the home city of the contact to \a str. |
124 | */ | 124 | */ |
125 | 125 | ||
126 | /*! \fn void OContact::setHomeState( const QString &str ) | 126 | /*! \fn void OContact::setHomeState( const QString &str ) |
127 | Sets the home state of the contact to \a str. | 127 | Sets the home state of the contact to \a str. |
128 | */ | 128 | */ |
129 | 129 | ||
130 | /*! \fn void OContact::setHomeZip( const QString &str ) | 130 | /*! \fn void OContact::setHomeZip( const QString &str ) |
131 | Sets the home zip code of the contact to \a str. | 131 | Sets the home zip code of the contact to \a str. |
132 | */ | 132 | */ |
133 | 133 | ||
134 | /*! \fn void OContact::setHomeCountry( const QString &str ) | 134 | /*! \fn void OContact::setHomeCountry( const QString &str ) |
135 | Sets the home country of the contact to \a str. | 135 | Sets the home country of the contact to \a str. |
136 | */ | 136 | */ |
137 | 137 | ||
138 | /*! \fn void OContact::setHomePhone( const QString &str ) | 138 | /*! \fn void OContact::setHomePhone( const QString &str ) |
139 | Sets the home phone number of the contact to \a str. | 139 | Sets the home phone number of the contact to \a str. |
140 | */ | 140 | */ |
141 | 141 | ||
142 | /*! \fn void OContact::setHomeFax( const QString &str ) | 142 | /*! \fn void OContact::setHomeFax( const QString &str ) |
143 | Sets the home fax number of the contact to \a str. | 143 | Sets the home fax number of the contact to \a str. |
144 | */ | 144 | */ |
145 | 145 | ||
146 | /*! \fn void OContact::setHomeMobile( const QString &str ) | 146 | /*! \fn void OContact::setHomeMobile( const QString &str ) |
147 | Sets the home mobile phone number of the contact to \a str. | 147 | Sets the home mobile phone number of the contact to \a str. |
148 | */ | 148 | */ |
149 | 149 | ||
150 | /*! \fn void OContact::setHomeWebpage( const QString &str ) | 150 | /*! \fn void OContact::setHomeWebpage( const QString &str ) |
151 | Sets the home webpage of the contact to \a str. | 151 | Sets the home webpage of the contact to \a str. |
152 | */ | 152 | */ |
153 | 153 | ||
154 | /*! \fn void OContact::setCompany( const QString &str ) | 154 | /*! \fn void OContact::setCompany( const QString &str ) |
155 | Sets the company for contact to \a str. | 155 | Sets the company for contact to \a str. |
156 | */ | 156 | */ |
157 | 157 | ||
158 | /*! \fn void OContact::setJobTitle( const QString &str ) | 158 | /*! \fn void OContact::setJobTitle( const QString &str ) |
159 | Sets the job title of the contact to \a str. | 159 | Sets the job title of the contact to \a str. |
160 | */ | 160 | */ |
161 | 161 | ||
162 | /*! \fn void OContact::setDepartment( const QString &str ) | 162 | /*! \fn void OContact::setDepartment( const QString &str ) |
163 | Sets the department for contact to \a str. | 163 | Sets the department for contact to \a str. |
164 | */ | 164 | */ |
165 | 165 | ||
166 | /*! \fn void OContact::setOffice( const QString &str ) | 166 | /*! \fn void OContact::setOffice( const QString &str ) |
167 | Sets the office for contact to \a str. | 167 | Sets the office for contact to \a str. |
168 | */ | 168 | */ |
169 | 169 | ||
170 | /*! \fn void OContact::setBusinessStreet( const QString &str ) | 170 | /*! \fn void OContact::setBusinessStreet( const QString &str ) |
171 | Sets the business street address of the contact to \a str. | 171 | Sets the business street address of the contact to \a str. |
172 | */ | 172 | */ |
173 | 173 | ||
174 | /*! \fn void OContact::setBusinessCity( const QString &str ) | 174 | /*! \fn void OContact::setBusinessCity( const QString &str ) |
175 | Sets the business city of the contact to \a str. | 175 | Sets the business city of the contact to \a str. |
176 | */ | 176 | */ |
177 | 177 | ||
178 | /*! \fn void OContact::setBusinessState( const QString &str ) | 178 | /*! \fn void OContact::setBusinessState( const QString &str ) |
179 | Sets the business state of the contact to \a str. | 179 | Sets the business state of the contact to \a str. |
180 | */ | 180 | */ |
181 | 181 | ||
182 | /*! \fn void OContact::setBusinessZip( const QString &str ) | 182 | /*! \fn void OContact::setBusinessZip( const QString &str ) |
183 | Sets the business zip code of the contact to \a str. | 183 | Sets the business zip code of the contact to \a str. |
184 | */ | 184 | */ |
185 | 185 | ||
186 | /*! \fn void OContact::setBusinessCountry( const QString &str ) | 186 | /*! \fn void OContact::setBusinessCountry( const QString &str ) |
187 | Sets the business country of the contact to \a str. | 187 | Sets the business country of the contact to \a str. |
188 | */ | 188 | */ |
189 | 189 | ||
190 | /*! \fn void OContact::setBusinessPhone( const QString &str ) | 190 | /*! \fn void OContact::setBusinessPhone( const QString &str ) |
191 | Sets the business phone number of the contact to \a str. | 191 | Sets the business phone number of the contact to \a str. |
192 | */ | 192 | */ |
193 | 193 | ||
194 | /*! \fn void OContact::setBusinessFax( const QString &str ) | 194 | /*! \fn void OContact::setBusinessFax( const QString &str ) |
195 | Sets the business fax number of the contact to \a str. | 195 | Sets the business fax number of the contact to \a str. |
196 | */ | 196 | */ |
197 | 197 | ||
198 | /*! \fn void OContact::setBusinessMobile( const QString &str ) | 198 | /*! \fn void OContact::setBusinessMobile( const QString &str ) |
199 | Sets the business mobile phone number of the contact to \a str. | 199 | Sets the business mobile phone number of the contact to \a str. |
200 | */ | 200 | */ |
201 | 201 | ||
202 | /*! \fn void OContact::setBusinessPager( const QString &str ) | 202 | /*! \fn void OContact::setBusinessPager( const QString &str ) |
203 | Sets the business pager number of the contact to \a str. | 203 | Sets the business pager number of the contact to \a str. |
204 | */ | 204 | */ |
205 | 205 | ||
206 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) | 206 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) |
207 | Sets the business webpage of the contact to \a str. | 207 | Sets the business webpage of the contact to \a str. |
208 | */ | 208 | */ |
209 | 209 | ||
210 | /*! \fn void OContact::setProfession( const QString &str ) | 210 | /*! \fn void OContact::setProfession( const QString &str ) |
211 | Sets the profession of the contact to \a str. | 211 | Sets the profession of the contact to \a str. |
212 | */ | 212 | */ |
213 | 213 | ||
214 | /*! \fn void OContact::setAssistant( const QString &str ) | 214 | /*! \fn void OContact::setAssistant( const QString &str ) |
215 | Sets the assistant of the contact to \a str. | 215 | Sets the assistant of the contact to \a str. |
216 | */ | 216 | */ |
217 | 217 | ||
218 | /*! \fn void OContact::setManager( const QString &str ) | 218 | /*! \fn void OContact::setManager( const QString &str ) |
219 | Sets the manager of the contact to \a str. | 219 | Sets the manager of the contact to \a str. |
220 | */ | 220 | */ |
221 | 221 | ||
222 | /*! \fn void OContact::setSpouse( const QString &str ) | 222 | /*! \fn void OContact::setSpouse( const QString &str ) |
223 | Sets the spouse of the contact to \a str. | 223 | Sets the spouse of the contact to \a str. |
224 | */ | 224 | */ |
225 | 225 | ||
226 | /*! \fn void OContact::setGender( const QString &str ) | 226 | /*! \fn void OContact::setGender( const QString &str ) |
227 | Sets the gender of the contact to \a str. | 227 | Sets the gender of the contact to \a str. |
228 | */ | 228 | */ |
229 | 229 | ||
230 | /*! \fn void OContact::setNickname( const QString &str ) | 230 | /*! \fn void OContact::setNickname( const QString &str ) |
231 | Sets the nickname of the contact to \a str. | 231 | Sets the nickname of the contact to \a str. |
232 | */ | 232 | */ |
233 | 233 | ||
234 | /*! \fn void OContact::setNotes( const QString &str ) | 234 | /*! \fn void OContact::setNotes( const QString &str ) |
235 | Sets the notes about the contact to \a str. | 235 | Sets the notes about the contact to \a str. |
236 | */ | 236 | */ |
237 | 237 | ||
238 | /*! \fn QString OContact::title() const | 238 | /*! \fn QString OContact::title() const |
239 | Returns the title of the contact. | 239 | Returns the title of the contact. |
240 | */ | 240 | */ |
241 | 241 | ||
242 | /*! \fn QString OContact::firstName() const | 242 | /*! \fn QString OContact::firstName() const |
243 | Returns the first name of the contact. | 243 | Returns the first name of the contact. |
244 | */ | 244 | */ |
245 | 245 | ||
246 | /*! \fn QString OContact::middleName() const | 246 | /*! \fn QString OContact::middleName() const |
247 | Returns the middle name of the contact. | 247 | Returns the middle name of the contact. |
248 | */ | 248 | */ |
249 | 249 | ||
250 | /*! \fn QString OContact::lastName() const | 250 | /*! \fn QString OContact::lastName() const |
251 | Returns the last name of the contact. | 251 | Returns the last name of the contact. |
252 | */ | 252 | */ |
253 | 253 | ||
254 | /*! \fn QString OContact::suffix() const | 254 | /*! \fn QString OContact::suffix() const |
255 | Returns the suffix of the contact. | 255 | Returns the suffix of the contact. |
256 | */ | 256 | */ |
257 | 257 | ||
258 | /*! \fn QString OContact::fileAs() const | 258 | /*! \fn QString OContact::fileAs() const |
259 | Returns the string the contact is filed as. | 259 | Returns the string the contact is filed as. |
260 | */ | 260 | */ |
261 | 261 | ||
262 | /*! \fn QString OContact::defaultEmail() const | 262 | /*! \fn QString OContact::defaultEmail() const |
263 | Returns the default email address of the contact. | 263 | Returns the default email address of the contact. |
264 | */ | 264 | */ |
265 | 265 | ||
266 | /*! \fn QString OContact::emails() const | 266 | /*! \fn QString OContact::emails() const |
267 | Returns the list of email address for a contact separated by ';'s in a single | 267 | Returns the list of email address for a contact separated by ';'s in a single |
268 | string. | 268 | string. |
269 | */ | 269 | */ |
270 | 270 | ||
271 | /*! \fn QString OContact::homeStreet() const | 271 | /*! \fn QString OContact::homeStreet() const |
272 | Returns the home street address of the contact. | 272 | Returns the home street address of the contact. |
273 | */ | 273 | */ |
274 | 274 | ||
275 | /*! \fn QString OContact::homeCity() const | 275 | /*! \fn QString OContact::homeCity() const |
276 | Returns the home city of the contact. | 276 | Returns the home city of the contact. |
277 | */ | 277 | */ |
278 | 278 | ||
279 | /*! \fn QString OContact::homeState() const | 279 | /*! \fn QString OContact::homeState() const |
280 | Returns the home state of the contact. | 280 | Returns the home state of the contact. |
281 | */ | 281 | */ |
282 | 282 | ||
283 | /*! \fn QString OContact::homeZip() const | 283 | /*! \fn QString OContact::homeZip() const |
284 | Returns the home zip of the contact. | 284 | Returns the home zip of the contact. |
285 | */ | 285 | */ |
286 | 286 | ||
287 | /*! \fn QString OContact::homeCountry() const | 287 | /*! \fn QString OContact::homeCountry() const |
288 | Returns the home country of the contact. | 288 | Returns the home country of the contact. |
289 | */ | 289 | */ |
290 | 290 | ||
291 | /*! \fn QString OContact::homePhone() const | 291 | /*! \fn QString OContact::homePhone() const |
292 | Returns the home phone number of the contact. | 292 | Returns the home phone number of the contact. |
293 | */ | 293 | */ |
294 | 294 | ||
295 | /*! \fn QString OContact::homeFax() const | 295 | /*! \fn QString OContact::homeFax() const |
296 | Returns the home fax number of the contact. | 296 | Returns the home fax number of the contact. |
297 | */ | 297 | */ |
298 | 298 | ||
299 | /*! \fn QString OContact::homeMobile() const | 299 | /*! \fn QString OContact::homeMobile() const |
300 | Returns the home mobile number of the contact. | 300 | Returns the home mobile number of the contact. |
301 | */ | 301 | */ |
302 | 302 | ||
303 | /*! \fn QString OContact::homeWebpage() const | 303 | /*! \fn QString OContact::homeWebpage() const |
304 | Returns the home webpage of the contact. | 304 | Returns the home webpage of the contact. |
305 | */ | 305 | */ |
306 | 306 | ||
307 | /*! \fn QString OContact::company() const | 307 | /*! \fn QString OContact::company() const |
308 | Returns the company for the contact. | 308 | Returns the company for the contact. |
309 | */ | 309 | */ |
310 | 310 | ||
311 | /*! \fn QString OContact::department() const | 311 | /*! \fn QString OContact::department() const |
312 | Returns the department for the contact. | 312 | Returns the department for the contact. |
313 | */ | 313 | */ |
314 | 314 | ||
315 | /*! \fn QString OContact::office() const | 315 | /*! \fn QString OContact::office() const |
316 | Returns the office for the contact. | 316 | Returns the office for the contact. |
317 | */ | 317 | */ |
318 | 318 | ||
319 | /*! \fn QString OContact::jobTitle() const | 319 | /*! \fn QString OContact::jobTitle() const |
320 | Returns the job title of the contact. | 320 | Returns the job title of the contact. |
321 | */ | 321 | */ |
322 | 322 | ||
323 | /*! \fn QString OContact::profession() const | 323 | /*! \fn QString OContact::profession() const |
324 | Returns the profession of the contact. | 324 | Returns the profession of the contact. |
325 | */ | 325 | */ |
326 | 326 | ||
327 | /*! \fn QString OContact::assistant() const | 327 | /*! \fn QString OContact::assistant() const |
328 | Returns the assistant of the contact. | 328 | Returns the assistant of the contact. |
329 | */ | 329 | */ |
330 | 330 | ||
331 | /*! \fn QString OContact::manager() const | 331 | /*! \fn QString OContact::manager() const |
332 | Returns the manager of the contact. | 332 | Returns the manager of the contact. |
333 | */ | 333 | */ |
334 | 334 | ||
335 | /*! \fn QString OContact::businessStreet() const | 335 | /*! \fn QString OContact::businessStreet() const |
336 | Returns the business street address of the contact. | 336 | Returns the business street address of the contact. |
337 | */ | 337 | */ |
338 | 338 | ||
339 | /*! \fn QString OContact::businessCity() const | 339 | /*! \fn QString OContact::businessCity() const |
340 | Returns the business city of the contact. | 340 | Returns the business city of the contact. |
341 | */ | 341 | */ |
342 | 342 | ||
343 | /*! \fn QString OContact::businessState() const | 343 | /*! \fn QString OContact::businessState() const |
344 | Returns the business state of the contact. | 344 | Returns the business state of the contact. |
345 | */ | 345 | */ |
346 | 346 | ||
347 | /*! \fn QString OContact::businessZip() const | 347 | /*! \fn QString OContact::businessZip() const |
348 | Returns the business zip of the contact. | 348 | Returns the business zip of the contact. |
349 | */ | 349 | */ |
350 | 350 | ||
351 | /*! \fn QString OContact::businessCountry() const | 351 | /*! \fn QString OContact::businessCountry() const |
352 | Returns the business country of the contact. | 352 | Returns the business country of the contact. |
353 | */ | 353 | */ |
354 | 354 | ||
355 | /*! \fn QString OContact::businessPhone() const | 355 | /*! \fn QString OContact::businessPhone() const |
356 | Returns the business phone number of the contact. | 356 | Returns the business phone number of the contact. |
357 | */ | 357 | */ |
358 | 358 | ||
359 | /*! \fn QString OContact::businessFax() const | 359 | /*! \fn QString OContact::businessFax() const |
360 | Returns the business fax number of the contact. | 360 | Returns the business fax number of the contact. |
361 | */ | 361 | */ |
362 | 362 | ||
363 | /*! \fn QString OContact::businessMobile() const | 363 | /*! \fn QString OContact::businessMobile() const |
364 | Returns the business mobile number of the contact. | 364 | Returns the business mobile number of the contact. |
365 | */ | 365 | */ |
366 | 366 | ||
367 | /*! \fn QString OContact::businessPager() const | 367 | /*! \fn QString OContact::businessPager() const |
368 | Returns the business pager number of the contact. | 368 | Returns the business pager number of the contact. |
369 | */ | 369 | */ |
370 | 370 | ||
371 | /*! \fn QString OContact::businessWebpage() const | 371 | /*! \fn QString OContact::businessWebpage() const |
372 | Returns the business webpage of the contact. | 372 | Returns the business webpage of the contact. |
373 | */ | 373 | */ |
374 | 374 | ||
375 | /*! \fn QString OContact::spouse() const | 375 | /*! \fn QString OContact::spouse() const |
376 | Returns the spouse of the contact. | 376 | Returns the spouse of the contact. |
377 | */ | 377 | */ |
378 | 378 | ||
379 | /*! \fn QString OContact::gender() const | 379 | /*! \fn QString OContact::gender() const |
380 | Returns the gender of the contact. | 380 | Returns the gender of the contact. |
381 | */ | 381 | */ |
382 | 382 | ||
383 | /*! \fn QString OContact::nickname() const | 383 | /*! \fn QString OContact::nickname() const |
384 | Returns the nickname of the contact. | 384 | Returns the nickname of the contact. |
385 | */ | 385 | */ |
386 | 386 | ||
387 | /*! \fn QString OContact::children() const | 387 | /*! \fn QString OContact::children() const |
388 | Returns the children of the contact. | 388 | Returns the children of the contact. |
389 | */ | 389 | */ |
390 | 390 | ||
391 | /*! \fn QString OContact::notes() const | 391 | /*! \fn QString OContact::notes() const |
392 | Returns the notes relating to the the contact. | 392 | Returns the notes relating to the the contact. |
393 | */ | 393 | */ |
394 | 394 | ||
395 | /*! \fn QString OContact::groups() const | 395 | /*! \fn QString OContact::groups() const |
396 | \internal | 396 | \internal |
397 | Returns the groups for the contact. | 397 | Returns the groups for the contact. |
398 | */ | 398 | */ |
399 | 399 | ||
400 | /*! \fn QStringList OContact::groupList() const | 400 | /*! \fn QStringList OContact::groupList() const |
401 | \internal | 401 | \internal |
402 | */ | 402 | */ |
403 | 403 | ||
404 | /*! \fn QString OContact::field(int) const | 404 | /*! \fn QString OContact::field(int) const |
405 | \internal | 405 | \internal |
406 | */ | 406 | */ |
407 | 407 | ||
408 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 408 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
409 | \internal | 409 | \internal |
410 | */ | 410 | */ |
411 | 411 | ||
412 | /*! \fn void OContact::setUid( int id ) | 412 | /*! \fn void OContact::setUid( int id ) |
413 | \internal | 413 | \internal |
414 | Sets the uid for this record to \a id. | 414 | Sets the uid for this record to \a id. |
415 | */ | 415 | */ |
416 | 416 | ||
417 | /*! \enum OContact::journal_action | 417 | /*! \enum OContact::journal_action |
418 | \internal | 418 | \internal |
419 | */ | 419 | */ |
420 | 420 | ||
421 | /*! | 421 | /*! |
422 | \internal | 422 | \internal |
423 | */ | 423 | */ |
424 | QMap<int, QString> OContact::toMap() const | 424 | QMap<int, QString> OContact::toMap() const |
425 | { | 425 | { |
426 | QMap<int, QString> map = mMap; | 426 | QMap<int, QString> map = mMap; |
427 | QString cats = idsToString( categories() ); | 427 | QString cats = idsToString( categories() ); |
428 | if ( !cats.isEmpty() ) | 428 | if ( !cats.isEmpty() ) |
429 | map.insert( Qtopia::AddressCategory, cats ); | 429 | map.insert( Qtopia::AddressCategory, cats ); |
430 | return map; | 430 | return map; |
431 | } | 431 | } |
432 | 432 | ||
433 | /*! | 433 | /*! |
434 | Returns a rich text formatted QString representing the contents the contact. | 434 | Returns a rich text formatted QString representing the contents the contact. |
435 | */ | 435 | */ |
436 | QString OContact::toRichText() const | 436 | QString OContact::toRichText() const |
437 | { | 437 | { |
438 | QString text; | 438 | QString text; |
439 | QString value, comp, state; | 439 | QString value, comp, state; |
440 | 440 | ||
441 | // name, jobtitle and company | 441 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 442 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; | 443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; |
444 | if ( !(value = jobTitle()).isEmpty() ) | 444 | if ( !(value = jobTitle()).isEmpty() ) |
445 | text += Qtopia::escapeString(value) + "<br>"; | 445 | text += Qtopia::escapeString(value) + "<br>"; |
446 | 446 | ||
447 | comp = company(); | 447 | comp = company(); |
448 | if ( !(value = department()).isEmpty() ) { | 448 | if ( !(value = department()).isEmpty() ) { |
449 | text += Qtopia::escapeString(value); | 449 | text += Qtopia::escapeString(value); |
450 | if ( comp ) | 450 | if ( comp ) |
451 | text += ", "; | 451 | text += ", "; |
452 | else | 452 | else |
453 | text += "<br>"; | 453 | text += "<br>"; |
454 | } | 454 | } |
455 | if ( !comp.isEmpty() ) | 455 | if ( !comp.isEmpty() ) |
456 | text += Qtopia::escapeString(comp) + "<br>"; | 456 | text += Qtopia::escapeString(comp) + "<br>"; |
457 | 457 | ||
458 | // business address | 458 | // business address |
459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
461 | text += "<br>"; | 461 | text += "<br>"; |
462 | text += QObject::tr( "<b>Work Address:</b>" ); | 462 | text += QObject::tr( "<b>Work Address:</b>" ); |
463 | text += "<br>"; | 463 | text += "<br>"; |
464 | } | 464 | } |
465 | 465 | ||
466 | if ( !(value = businessStreet()).isEmpty() ) | 466 | if ( !(value = businessStreet()).isEmpty() ) |
467 | text += Qtopia::escapeString(value) + "<br>"; | 467 | text += Qtopia::escapeString(value) + "<br>"; |
468 | state = businessState(); | 468 | state = businessState(); |
469 | if ( !(value = businessCity()).isEmpty() ) { | 469 | if ( !(value = businessCity()).isEmpty() ) { |
470 | text += Qtopia::escapeString(value); | 470 | text += Qtopia::escapeString(value); |
471 | if ( state ) | 471 | if ( state ) |
472 | text += ", " + Qtopia::escapeString(state); | 472 | text += ", " + Qtopia::escapeString(state); |
473 | text += "<br>"; | 473 | text += "<br>"; |
474 | } else if ( !state.isEmpty() ) | 474 | } else if ( !state.isEmpty() ) |
475 | text += Qtopia::escapeString(state) + "<br>"; | 475 | text += Qtopia::escapeString(state) + "<br>"; |
476 | if ( !(value = businessZip()).isEmpty() ) | 476 | if ( !(value = businessZip()).isEmpty() ) |
477 | text += Qtopia::escapeString(value) + "<br>"; | 477 | text += Qtopia::escapeString(value) + "<br>"; |
478 | if ( !(value = businessCountry()).isEmpty() ) | 478 | if ( !(value = businessCountry()).isEmpty() ) |
479 | text += Qtopia::escapeString(value) + "<br>"; | 479 | text += Qtopia::escapeString(value) + "<br>"; |
480 | 480 | ||
481 | // home address | 481 | // home address |
482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
484 | text += "<br>"; | 484 | text += "<br>"; |
485 | text += QObject::tr( "<b>Home Address:</b>" ); | 485 | text += QObject::tr( "<b>Home Address:</b>" ); |
486 | text += "<br>"; | 486 | text += "<br>"; |
487 | } | 487 | } |
488 | 488 | ||
489 | if ( !(value = homeStreet()).isEmpty() ) | 489 | if ( !(value = homeStreet()).isEmpty() ) |
490 | text += Qtopia::escapeString(value) + "<br>"; | 490 | text += Qtopia::escapeString(value) + "<br>"; |
491 | state = homeState(); | 491 | state = homeState(); |
492 | if ( !(value = homeCity()).isEmpty() ) { | 492 | if ( !(value = homeCity()).isEmpty() ) { |
493 | text += Qtopia::escapeString(value); | 493 | text += Qtopia::escapeString(value); |
494 | if ( !state.isEmpty() ) | 494 | if ( !state.isEmpty() ) |
495 | text += ", " + Qtopia::escapeString(state); | 495 | text += ", " + Qtopia::escapeString(state); |
496 | text += "<br>"; | 496 | text += "<br>"; |
497 | } else if (!state.isEmpty()) | 497 | } else if (!state.isEmpty()) |
498 | text += Qtopia::escapeString(state) + "<br>"; | 498 | text += Qtopia::escapeString(state) + "<br>"; |
499 | if ( !(value = homeZip()).isEmpty() ) | 499 | if ( !(value = homeZip()).isEmpty() ) |
500 | text += Qtopia::escapeString(value) + "<br>"; | 500 | text += Qtopia::escapeString(value) + "<br>"; |
501 | if ( !(value = homeCountry()).isEmpty() ) | 501 | if ( !(value = homeCountry()).isEmpty() ) |
502 | text += Qtopia::escapeString(value) + "<br>"; | 502 | text += Qtopia::escapeString(value) + "<br>"; |
503 | 503 | ||
504 | // the others... | 504 | // the others... |
505 | QString str; | 505 | QString str; |
506 | str = emails(); | 506 | str = emails(); |
507 | if ( !str.isEmpty() ) | 507 | if ( !str.isEmpty() ) |
508 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" | 508 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" |
509 | + Qtopia::escapeString(str) + "<br>"; | 509 | + Qtopia::escapeString(str) + "<br>"; |
510 | str = homePhone(); | 510 | str = homePhone(); |
511 | if ( !str.isEmpty() ) | 511 | if ( !str.isEmpty() ) |
512 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 512 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" |
513 | + Qtopia::escapeString(str) + "<br>"; | 513 | + Qtopia::escapeString(str) + "<br>"; |
514 | str = homeFax(); | 514 | str = homeFax(); |
515 | if ( !str.isEmpty() ) | 515 | if ( !str.isEmpty() ) |
516 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 516 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" |
517 | + Qtopia::escapeString(str) + "<br>"; | 517 | + Qtopia::escapeString(str) + "<br>"; |
518 | str = homeMobile(); | 518 | str = homeMobile(); |
519 | if ( !str.isEmpty() ) | 519 | if ( !str.isEmpty() ) |
520 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 520 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" |
521 | + Qtopia::escapeString(str) + "<br>"; | 521 | + Qtopia::escapeString(str) + "<br>"; |
522 | str = homeWebpage(); | 522 | str = homeWebpage(); |
523 | if ( !str.isEmpty() ) | 523 | if ( !str.isEmpty() ) |
524 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 524 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" |
525 | + Qtopia::escapeString(str) + "<br>"; | 525 | + Qtopia::escapeString(str) + "<br>"; |
526 | str = businessWebpage(); | 526 | str = businessWebpage(); |
527 | if ( !str.isEmpty() ) | 527 | if ( !str.isEmpty() ) |
528 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 528 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" |
529 | + Qtopia::escapeString(str) + "<br>"; | 529 | + Qtopia::escapeString(str) + "<br>"; |
530 | str = office(); | 530 | str = office(); |
531 | if ( !str.isEmpty() ) | 531 | if ( !str.isEmpty() ) |
532 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 532 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
533 | + Qtopia::escapeString(str) + "<br>"; | 533 | + Qtopia::escapeString(str) + "<br>"; |
534 | str = businessPhone(); | 534 | str = businessPhone(); |
535 | if ( !str.isEmpty() ) | 535 | if ( !str.isEmpty() ) |
536 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 536 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" |
537 | + Qtopia::escapeString(str) + "<br>"; | 537 | + Qtopia::escapeString(str) + "<br>"; |
538 | str = businessFax(); | 538 | str = businessFax(); |
539 | if ( !str.isEmpty() ) | 539 | if ( !str.isEmpty() ) |
540 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 540 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" |
541 | + Qtopia::escapeString(str) + "<br>"; | 541 | + Qtopia::escapeString(str) + "<br>"; |
542 | str = businessMobile(); | 542 | str = businessMobile(); |
543 | if ( !str.isEmpty() ) | 543 | if ( !str.isEmpty() ) |
544 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 544 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" |
545 | + Qtopia::escapeString(str) + "<br>"; | 545 | + Qtopia::escapeString(str) + "<br>"; |
546 | str = businessPager(); | 546 | str = businessPager(); |
547 | if ( !str.isEmpty() ) | 547 | if ( !str.isEmpty() ) |
548 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 548 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
549 | + Qtopia::escapeString(str) + "<br>"; | 549 | + Qtopia::escapeString(str) + "<br>"; |
550 | str = profession(); | 550 | str = profession(); |
551 | if ( !str.isEmpty() ) | 551 | if ( !str.isEmpty() ) |
552 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 552 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
553 | + Qtopia::escapeString(str) + "<br>"; | 553 | + Qtopia::escapeString(str) + "<br>"; |
554 | str = assistant(); | 554 | str = assistant(); |
555 | if ( !str.isEmpty() ) | 555 | if ( !str.isEmpty() ) |
556 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 556 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
557 | + Qtopia::escapeString(str) + "<br>"; | 557 | + Qtopia::escapeString(str) + "<br>"; |
558 | str = manager(); | 558 | str = manager(); |
559 | if ( !str.isEmpty() ) | 559 | if ( !str.isEmpty() ) |
560 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 560 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
561 | + Qtopia::escapeString(str) + "<br>"; | 561 | + Qtopia::escapeString(str) + "<br>"; |
562 | str = gender(); | 562 | str = gender(); |
563 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 563 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
564 | if ( str.toInt() == 1 ) | 564 | if ( str.toInt() == 1 ) |
565 | str = QObject::tr( "Male" ); | 565 | str = QObject::tr( "Male" ); |
566 | else if ( str.toInt() == 2 ) | 566 | else if ( str.toInt() == 2 ) |
567 | str = QObject::tr( "Female" ); | 567 | str = QObject::tr( "Female" ); |
568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
569 | } | 569 | } |
570 | str = spouse(); | 570 | str = spouse(); |
571 | if ( !str.isEmpty() ) | 571 | if ( !str.isEmpty() ) |
572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 573 | + Qtopia::escapeString(str) + "<br>"; |
574 | if ( !birthday().isNull() ){ | 574 | if ( !birthday().isValid() ){ |
575 | str = TimeString::numberDateString( birthday() ); | 575 | str = TimeString::numberDateString( birthday() ); |
576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
578 | } | 578 | } |
579 | if ( !anniversary().isNull() ){ | 579 | if ( !anniversary().isValid() ){ |
580 | str = TimeString::numberDateString( anniversary() ); | 580 | str = TimeString::numberDateString( anniversary() ); |
581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
582 | + Qtopia::escapeString(str) + "<br>"; | 582 | + Qtopia::escapeString(str) + "<br>"; |
583 | } | 583 | } |
584 | str = nickname(); | 584 | str = nickname(); |
585 | if ( !str.isEmpty() ) | 585 | if ( !str.isEmpty() ) |
586 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 586 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 587 | + Qtopia::escapeString(str) + "<br>"; |
588 | 588 | ||
589 | // notes last | 589 | // notes last |
590 | if ( (value = notes()) ) { | 590 | if ( (value = notes()) ) { |
591 | QRegExp reg("\n"); | 591 | QRegExp reg("\n"); |
592 | 592 | ||
593 | //QString tmp = Qtopia::escapeString(value); | 593 | //QString tmp = Qtopia::escapeString(value); |
594 | QString tmp = QStyleSheet::convertFromPlainText(value); | 594 | QString tmp = QStyleSheet::convertFromPlainText(value); |
595 | //tmp.replace( reg, "<br>" ); | 595 | //tmp.replace( reg, "<br>" ); |
596 | text += "<br>" + tmp + "<br>"; | 596 | text += "<br>" + tmp + "<br>"; |
597 | } | 597 | } |
598 | return text; | 598 | return text; |
599 | } | 599 | } |
600 | 600 | ||
601 | /*! | 601 | /*! |
602 | \internal | 602 | \internal |
603 | */ | 603 | */ |
604 | void OContact::insert( int key, const QString &v ) | 604 | void OContact::insert( int key, const QString &v ) |
605 | { | 605 | { |
606 | QString value = v.stripWhiteSpace(); | 606 | QString value = v.stripWhiteSpace(); |
607 | if ( value.isEmpty() ) | 607 | if ( value.isEmpty() ) |
608 | mMap.remove( key ); | 608 | mMap.remove( key ); |
609 | else | 609 | else |
610 | mMap.insert( key, value ); | 610 | mMap.insert( key, value ); |
611 | } | 611 | } |
612 | 612 | ||
613 | /*! | 613 | /*! |
614 | \internal | 614 | \internal |
615 | */ | 615 | */ |
616 | void OContact::replace( int key, const QString & v ) | 616 | void OContact::replace( int key, const QString & v ) |
617 | { | 617 | { |
618 | QString value = v.stripWhiteSpace(); | 618 | QString value = v.stripWhiteSpace(); |
619 | if ( value.isEmpty() ) | 619 | if ( value.isEmpty() ) |
620 | mMap.remove( key ); | 620 | mMap.remove( key ); |
621 | else | 621 | else |
622 | mMap.replace( key, value ); | 622 | mMap.replace( key, value ); |
623 | } | 623 | } |
624 | 624 | ||
625 | /*! | 625 | /*! |
626 | \internal | 626 | \internal |
627 | */ | 627 | */ |
628 | QString OContact::find( int key ) const | 628 | QString OContact::find( int key ) const |
629 | { | 629 | { |
630 | return mMap[key]; | 630 | return mMap[key]; |
631 | } | 631 | } |
632 | 632 | ||
633 | /*! | 633 | /*! |
634 | \internal | 634 | \internal |
635 | */ | 635 | */ |
636 | QString OContact::displayAddress( const QString &street, | 636 | QString OContact::displayAddress( const QString &street, |
637 | const QString &city, | 637 | const QString &city, |
638 | const QString &state, | 638 | const QString &state, |
639 | const QString &zip, | 639 | const QString &zip, |
640 | const QString &country ) const | 640 | const QString &country ) const |
641 | { | 641 | { |
642 | QString s = street; | 642 | QString s = street; |
643 | if ( !street.isEmpty() ) | 643 | if ( !street.isEmpty() ) |
644 | s+= "\n"; | 644 | s+= "\n"; |
645 | s += city; | 645 | s += city; |
646 | if ( !city.isEmpty() && !state.isEmpty() ) | 646 | if ( !city.isEmpty() && !state.isEmpty() ) |
647 | s += ", "; | 647 | s += ", "; |
648 | s += state; | 648 | s += state; |
649 | if ( !state.isEmpty() && !zip.isEmpty() ) | 649 | if ( !state.isEmpty() && !zip.isEmpty() ) |
650 | s += " "; | 650 | s += " "; |
651 | s += zip; | 651 | s += zip; |
652 | if ( !country.isEmpty() && !s.isEmpty() ) | 652 | if ( !country.isEmpty() && !s.isEmpty() ) |
653 | s += "\n"; | 653 | s += "\n"; |
654 | s += country; | 654 | s += country; |
655 | return s; | 655 | return s; |
656 | } | 656 | } |
657 | 657 | ||
658 | /*! | 658 | /*! |
659 | \internal | 659 | \internal |
660 | */ | 660 | */ |
661 | QString OContact::displayBusinessAddress() const | 661 | QString OContact::displayBusinessAddress() const |
662 | { | 662 | { |
663 | return displayAddress( businessStreet(), businessCity(), | 663 | return displayAddress( businessStreet(), businessCity(), |
664 | businessState(), businessZip(), | 664 | businessState(), businessZip(), |
665 | businessCountry() ); | 665 | businessCountry() ); |
666 | } | 666 | } |
667 | 667 | ||
668 | /*! | 668 | /*! |
669 | \internal | 669 | \internal |
670 | */ | 670 | */ |
671 | QString OContact::displayHomeAddress() const | 671 | QString OContact::displayHomeAddress() const |
672 | { | 672 | { |
673 | return displayAddress( homeStreet(), homeCity(), | 673 | return displayAddress( homeStreet(), homeCity(), |
674 | homeState(), homeZip(), | 674 | homeState(), homeZip(), |
675 | homeCountry() ); | 675 | homeCountry() ); |
676 | } | 676 | } |
677 | 677 | ||
678 | /*! | 678 | /*! |
679 | Returns the full name of the contact | 679 | Returns the full name of the contact |
680 | */ | 680 | */ |
681 | QString OContact::fullName() const | 681 | QString OContact::fullName() const |
682 | { | 682 | { |
683 | QString title = find( Qtopia::Title ); | 683 | QString title = find( Qtopia::Title ); |
684 | QString firstName = find( Qtopia::FirstName ); | 684 | QString firstName = find( Qtopia::FirstName ); |
685 | QString middleName = find( Qtopia::MiddleName ); | 685 | QString middleName = find( Qtopia::MiddleName ); |
686 | QString lastName = find( Qtopia::LastName ); | 686 | QString lastName = find( Qtopia::LastName ); |
687 | QString suffix = find( Qtopia::Suffix ); | 687 | QString suffix = find( Qtopia::Suffix ); |
688 | 688 | ||
689 | QString name = title; | 689 | QString name = title; |
690 | if ( !firstName.isEmpty() ) { | 690 | if ( !firstName.isEmpty() ) { |
691 | if ( !name.isEmpty() ) | 691 | if ( !name.isEmpty() ) |
692 | name += " "; | 692 | name += " "; |
693 | name += firstName; | 693 | name += firstName; |
694 | } | 694 | } |
695 | if ( !middleName.isEmpty() ) { | 695 | if ( !middleName.isEmpty() ) { |
696 | if ( !name.isEmpty() ) | 696 | if ( !name.isEmpty() ) |
697 | name += " "; | 697 | name += " "; |
698 | name += middleName; | 698 | name += middleName; |
699 | } | 699 | } |
700 | if ( !lastName.isEmpty() ) { | 700 | if ( !lastName.isEmpty() ) { |
701 | if ( !name.isEmpty() ) | 701 | if ( !name.isEmpty() ) |
702 | name += " "; | 702 | name += " "; |
703 | name += lastName; | 703 | name += lastName; |
704 | } | 704 | } |
705 | if ( !suffix.isEmpty() ) { | 705 | if ( !suffix.isEmpty() ) { |
706 | if ( !name.isEmpty() ) | 706 | if ( !name.isEmpty() ) |
707 | name += " "; | 707 | name += " "; |
708 | name += suffix; | 708 | name += suffix; |
709 | } | 709 | } |
710 | return name.simplifyWhiteSpace(); | 710 | return name.simplifyWhiteSpace(); |
711 | } | 711 | } |
712 | 712 | ||
713 | /*! | 713 | /*! |
714 | Returns a list of the names of the children of the contact. | 714 | Returns a list of the names of the children of the contact. |
715 | */ | 715 | */ |
716 | QStringList OContact::childrenList() const | 716 | QStringList OContact::childrenList() const |
717 | { | 717 | { |
718 | return QStringList::split( " ", find( Qtopia::Children ) ); | 718 | return QStringList::split( " ", find( Qtopia::Children ) ); |
719 | } | 719 | } |
720 | 720 | ||
721 | /*! \fn void OContact::insertEmail( const QString &email ) | 721 | /*! \fn void OContact::insertEmail( const QString &email ) |
722 | 722 | ||
723 | Insert \a email into the email list. Ensures \a email can only be added | 723 | Insert \a email into the email list. Ensures \a email can only be added |
724 | once. If there is no default email address set, it sets it to the \a email. | 724 | once. If there is no default email address set, it sets it to the \a email. |
725 | */ | 725 | */ |
726 | 726 | ||
727 | /*! \fn void OContact::removeEmail( const QString &email ) | 727 | /*! \fn void OContact::removeEmail( const QString &email ) |
728 | 728 | ||
729 | Removes the \a email from the email list. If the default email was \a email, | 729 | Removes the \a email from the email list. If the default email was \a email, |
730 | then the default email address is assigned to the first email in the | 730 | then the default email address is assigned to the first email in the |
731 | email list | 731 | email list |
732 | */ | 732 | */ |
733 | 733 | ||
734 | /*! \fn void OContact::clearEmails() | 734 | /*! \fn void OContact::clearEmails() |
735 | 735 | ||
736 | Clears the email list. | 736 | Clears the email list. |
737 | */ | 737 | */ |
738 | 738 | ||
739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
740 | 740 | ||
741 | Appends the \a emailList to the exiting email list | 741 | Appends the \a emailList to the exiting email list |
742 | */ | 742 | */ |
743 | 743 | ||
744 | /*! | 744 | /*! |
745 | Returns a list of email addresses belonging to the contact, including | 745 | Returns a list of email addresses belonging to the contact, including |
746 | the default email address. | 746 | the default email address. |
747 | */ | 747 | */ |
748 | QStringList OContact::emailList() const | 748 | QStringList OContact::emailList() const |
749 | { | 749 | { |
750 | QString emailStr = emails(); | 750 | QString emailStr = emails(); |
751 | 751 | ||
752 | QStringList r; | 752 | QStringList r; |
753 | if ( !emailStr.isEmpty() ) { | 753 | if ( !emailStr.isEmpty() ) { |
754 | qDebug(" emailstr "); | 754 | qDebug(" emailstr "); |
755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
757 | r += (*it).simplifyWhiteSpace(); | 757 | r += (*it).simplifyWhiteSpace(); |
758 | } | 758 | } |
759 | 759 | ||
760 | return r; | 760 | return r; |
761 | } | 761 | } |
762 | 762 | ||
763 | /*! | 763 | /*! |
764 | \overload | 764 | \overload |
765 | 765 | ||
766 | Generates the string for the contact to be filed as from the first, | 766 | Generates the string for the contact to be filed as from the first, |
767 | middle and last name of the contact. | 767 | middle and last name of the contact. |
768 | */ | 768 | */ |
769 | void OContact::setFileAs() | 769 | void OContact::setFileAs() |
770 | { | 770 | { |
771 | QString lastName, firstName, middleName, fileas; | 771 | QString lastName, firstName, middleName, fileas; |
772 | 772 | ||
773 | lastName = find( Qtopia::LastName ); | 773 | lastName = find( Qtopia::LastName ); |
774 | firstName = find( Qtopia::FirstName ); | 774 | firstName = find( Qtopia::FirstName ); |
775 | middleName = find( Qtopia::MiddleName ); | 775 | middleName = find( Qtopia::MiddleName ); |
776 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 776 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
777 | && !middleName.isEmpty() ) | 777 | && !middleName.isEmpty() ) |
778 | fileas = lastName + ", " + firstName + " " + middleName; | 778 | fileas = lastName + ", " + firstName + " " + middleName; |
779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
780 | fileas = lastName + ", " + firstName; | 780 | fileas = lastName + ", " + firstName; |
781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
782 | !middleName.isEmpty() ) | 782 | !middleName.isEmpty() ) |
783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
784 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 784 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
785 | + lastName; | 785 | + lastName; |
786 | 786 | ||
787 | replace( Qtopia::FileAs, fileas ); | 787 | replace( Qtopia::FileAs, fileas ); |
788 | } | 788 | } |
789 | 789 | ||
790 | /*! | 790 | /*! |
791 | \internal | 791 | \internal |
792 | Appends the contact information to \a buf. | 792 | Appends the contact information to \a buf. |
793 | */ | 793 | */ |
794 | void OContact::save( QString &buf ) const | 794 | void OContact::save( QString &buf ) const |
795 | { | 795 | { |
796 | static const QStringList SLFIELDS = fields(); | 796 | static const QStringList SLFIELDS = fields(); |
797 | // I'm expecting "<Contact " in front of this... | 797 | // I'm expecting "<Contact " in front of this... |
798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
799 | it != mMap.end(); ++it ) { | 799 | it != mMap.end(); ++it ) { |
800 | const QString &value = it.data(); | 800 | const QString &value = it.data(); |
801 | int key = it.key(); | 801 | int key = it.key(); |
802 | if ( !value.isEmpty() ) { | 802 | if ( !value.isEmpty() ) { |
803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
804 | continue; | 804 | continue; |
805 | 805 | ||
806 | key -= Qtopia::AddressCategory+1; | 806 | key -= Qtopia::AddressCategory+1; |
807 | buf += SLFIELDS[key]; | 807 | buf += SLFIELDS[key]; |
808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
809 | } | 809 | } |
810 | } | 810 | } |
811 | buf += customToXml(); | 811 | buf += customToXml(); |
812 | if ( categories().count() > 0 ) | 812 | if ( categories().count() > 0 ) |
813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
815 | // You need to close this yourself | 815 | // You need to close this yourself |
816 | } | 816 | } |
817 | 817 | ||
818 | /*! | 818 | /*! |
819 | \internal | 819 | \internal |
820 | Returns the list of fields belonging to a contact | 820 | Returns the list of fields belonging to a contact |
821 | */ | 821 | */ |
822 | QStringList OContact::fields() | 822 | QStringList OContact::fields() |
823 | { | 823 | { |
824 | QStringList list; | 824 | QStringList list; |
825 | 825 | ||
826 | list.append( "Title" ); // Not Used! | 826 | list.append( "Title" ); // Not Used! |
827 | list.append( "FirstName" ); | 827 | list.append( "FirstName" ); |
828 | list.append( "MiddleName" ); | 828 | list.append( "MiddleName" ); |
829 | list.append( "LastName" ); | 829 | list.append( "LastName" ); |
830 | list.append( "Suffix" ); | 830 | list.append( "Suffix" ); |
831 | list.append( "FileAs" ); | 831 | list.append( "FileAs" ); |
832 | 832 | ||
833 | list.append( "JobTitle" ); | 833 | list.append( "JobTitle" ); |
834 | list.append( "Department" ); | 834 | list.append( "Department" ); |
835 | list.append( "Company" ); | 835 | list.append( "Company" ); |
836 | list.append( "BusinessPhone" ); | 836 | list.append( "BusinessPhone" ); |
837 | list.append( "BusinessFax" ); | 837 | list.append( "BusinessFax" ); |
838 | list.append( "BusinessMobile" ); | 838 | list.append( "BusinessMobile" ); |
839 | 839 | ||
840 | list.append( "DefaultEmail" ); | 840 | list.append( "DefaultEmail" ); |
841 | list.append( "Emails" ); | 841 | list.append( "Emails" ); |
842 | 842 | ||
843 | list.append( "HomePhone" ); | 843 | list.append( "HomePhone" ); |
844 | list.append( "HomeFax" ); | 844 | list.append( "HomeFax" ); |
845 | list.append( "HomeMobile" ); | 845 | list.append( "HomeMobile" ); |
846 | 846 | ||
847 | list.append( "BusinessStreet" ); | 847 | list.append( "BusinessStreet" ); |
848 | list.append( "BusinessCity" ); | 848 | list.append( "BusinessCity" ); |
849 | list.append( "BusinessState" ); | 849 | list.append( "BusinessState" ); |
850 | list.append( "BusinessZip" ); | 850 | list.append( "BusinessZip" ); |
851 | list.append( "BusinessCountry" ); | 851 | list.append( "BusinessCountry" ); |
852 | list.append( "BusinessPager" ); | 852 | list.append( "BusinessPager" ); |
853 | list.append( "BusinessWebPage" ); | 853 | list.append( "BusinessWebPage" ); |
854 | 854 | ||
855 | list.append( "Office" ); | 855 | list.append( "Office" ); |
856 | list.append( "Profession" ); | 856 | list.append( "Profession" ); |
857 | list.append( "Assistant" ); | 857 | list.append( "Assistant" ); |
858 | list.append( "Manager" ); | 858 | list.append( "Manager" ); |
859 | 859 | ||
860 | list.append( "HomeStreet" ); | 860 | list.append( "HomeStreet" ); |
861 | list.append( "HomeCity" ); | 861 | list.append( "HomeCity" ); |
862 | list.append( "HomeState" ); | 862 | list.append( "HomeState" ); |
863 | list.append( "HomeZip" ); | 863 | list.append( "HomeZip" ); |
864 | list.append( "HomeCountry" ); | 864 | list.append( "HomeCountry" ); |
865 | list.append( "HomeWebPage" ); | 865 | list.append( "HomeWebPage" ); |
866 | 866 | ||
867 | list.append( "Spouse" ); | 867 | list.append( "Spouse" ); |
868 | list.append( "Gender" ); | 868 | list.append( "Gender" ); |
869 | list.append( "Birthday" ); | 869 | list.append( "Birthday" ); |
870 | list.append( "Anniversary" ); | 870 | list.append( "Anniversary" ); |
871 | list.append( "Nickname" ); | 871 | list.append( "Nickname" ); |
872 | list.append( "Children" ); | 872 | list.append( "Children" ); |
873 | 873 | ||
874 | list.append( "Notes" ); | 874 | list.append( "Notes" ); |
875 | list.append( "Groups" ); | 875 | list.append( "Groups" ); |
876 | 876 | ||
877 | return list; | 877 | return list; |
878 | } | 878 | } |
879 | 879 | ||
880 | /*! | 880 | /*! |
881 | \internal | 881 | \internal |
882 | Returns a translated list of field names for a contact. | 882 | Returns a translated list of field names for a contact. |
883 | */ | 883 | */ |
884 | QStringList OContact::trfields() | 884 | QStringList OContact::trfields() |
885 | { | 885 | { |
886 | QStringList list; | 886 | QStringList list; |
887 | 887 | ||
888 | list.append( QObject::tr( "Name Title") ); | 888 | list.append( QObject::tr( "Name Title") ); |
889 | list.append( QObject::tr( "First Name" ) ); | 889 | list.append( QObject::tr( "First Name" ) ); |
890 | list.append( QObject::tr( "Middle Name" ) ); | 890 | list.append( QObject::tr( "Middle Name" ) ); |
891 | list.append( QObject::tr( "Last Name" ) ); | 891 | list.append( QObject::tr( "Last Name" ) ); |
892 | list.append( QObject::tr( "Suffix" ) ); | 892 | list.append( QObject::tr( "Suffix" ) ); |
893 | list.append( QObject::tr( "File As" ) ); | 893 | list.append( QObject::tr( "File As" ) ); |
894 | 894 | ||
895 | list.append( QObject::tr( "Job Title" ) ); | 895 | list.append( QObject::tr( "Job Title" ) ); |
896 | list.append( QObject::tr( "Department" ) ); | 896 | list.append( QObject::tr( "Department" ) ); |
897 | list.append( QObject::tr( "Company" ) ); | 897 | list.append( QObject::tr( "Company" ) ); |
898 | list.append( QObject::tr( "Business Phone" ) ); | 898 | list.append( QObject::tr( "Business Phone" ) ); |
899 | list.append( QObject::tr( "Business Fax" ) ); | 899 | list.append( QObject::tr( "Business Fax" ) ); |
900 | list.append( QObject::tr( "Business Mobile" ) ); | 900 | list.append( QObject::tr( "Business Mobile" ) ); |
901 | 901 | ||
902 | list.append( QObject::tr( "Default Email" ) ); | 902 | list.append( QObject::tr( "Default Email" ) ); |
903 | list.append( QObject::tr( "Emails" ) ); | 903 | list.append( QObject::tr( "Emails" ) ); |
904 | 904 | ||
905 | list.append( QObject::tr( "Home Phone" ) ); | 905 | list.append( QObject::tr( "Home Phone" ) ); |
906 | list.append( QObject::tr( "Home Fax" ) ); | 906 | list.append( QObject::tr( "Home Fax" ) ); |
907 | list.append( QObject::tr( "Home Mobile" ) ); | 907 | list.append( QObject::tr( "Home Mobile" ) ); |
908 | 908 | ||
909 | list.append( QObject::tr( "Business Street" ) ); | 909 | list.append( QObject::tr( "Business Street" ) ); |
910 | list.append( QObject::tr( "Business City" ) ); | 910 | list.append( QObject::tr( "Business City" ) ); |
911 | list.append( QObject::tr( "Business State" ) ); | 911 | list.append( QObject::tr( "Business State" ) ); |
912 | list.append( QObject::tr( "Business Zip" ) ); | 912 | list.append( QObject::tr( "Business Zip" ) ); |
913 | list.append( QObject::tr( "Business Country" ) ); | 913 | list.append( QObject::tr( "Business Country" ) ); |
914 | list.append( QObject::tr( "Business Pager" ) ); | 914 | list.append( QObject::tr( "Business Pager" ) ); |
915 | list.append( QObject::tr( "Business WebPage" ) ); | 915 | list.append( QObject::tr( "Business WebPage" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Office" ) ); | 917 | list.append( QObject::tr( "Office" ) ); |
918 | list.append( QObject::tr( "Profession" ) ); | 918 | list.append( QObject::tr( "Profession" ) ); |
919 | list.append( QObject::tr( "Assistant" ) ); | 919 | list.append( QObject::tr( "Assistant" ) ); |
920 | list.append( QObject::tr( "Manager" ) ); | 920 | list.append( QObject::tr( "Manager" ) ); |
921 | 921 | ||
922 | list.append( QObject::tr( "Home Street" ) ); | 922 | list.append( QObject::tr( "Home Street" ) ); |
923 | list.append( QObject::tr( "Home City" ) ); | 923 | list.append( QObject::tr( "Home City" ) ); |
924 | list.append( QObject::tr( "Home State" ) ); | 924 | list.append( QObject::tr( "Home State" ) ); |
925 | list.append( QObject::tr( "Home Zip" ) ); | 925 | list.append( QObject::tr( "Home Zip" ) ); |
926 | list.append( QObject::tr( "Home Country" ) ); | 926 | list.append( QObject::tr( "Home Country" ) ); |
927 | list.append( QObject::tr( "Home Web Page" ) ); | 927 | list.append( QObject::tr( "Home Web Page" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Spouse" ) ); | 929 | list.append( QObject::tr( "Spouse" ) ); |
930 | list.append( QObject::tr( "Gender" ) ); | 930 | list.append( QObject::tr( "Gender" ) ); |
931 | list.append( QObject::tr( "Birthday" ) ); | 931 | list.append( QObject::tr( "Birthday" ) ); |
932 | list.append( QObject::tr( "Anniversary" ) ); | 932 | list.append( QObject::tr( "Anniversary" ) ); |
933 | list.append( QObject::tr( "Nickname" ) ); | 933 | list.append( QObject::tr( "Nickname" ) ); |
934 | list.append( QObject::tr( "Children" ) ); | 934 | list.append( QObject::tr( "Children" ) ); |
935 | 935 | ||
936 | list.append( QObject::tr( "Notes" ) ); | 936 | list.append( QObject::tr( "Notes" ) ); |
937 | list.append( QObject::tr( "Groups" ) ); | 937 | list.append( QObject::tr( "Groups" ) ); |
938 | 938 | ||
939 | return list; | 939 | return list; |
940 | } | 940 | } |
941 | 941 | ||
942 | /*! | 942 | /*! |
943 | \internal | 943 | \internal |
944 | Returns an untranslated list of field names for a contact. | 944 | Returns an untranslated list of field names for a contact. |
945 | */ | 945 | */ |
946 | QStringList OContact::untrfields() | 946 | QStringList OContact::untrfields() |
947 | { | 947 | { |
948 | QStringList list; | 948 | QStringList list; |
949 | 949 | ||
950 | list.append( "Name Title" ); | 950 | list.append( "Name Title" ); |
951 | list.append( "First Name" ); | 951 | list.append( "First Name" ); |
952 | list.append( "Middle Name" ); | 952 | list.append( "Middle Name" ); |
953 | list.append( "Last Name" ); | 953 | list.append( "Last Name" ); |
954 | list.append( "Suffix" ); | 954 | list.append( "Suffix" ); |
955 | list.append( "File As" ); | 955 | list.append( "File As" ); |
956 | 956 | ||
957 | list.append( "Job Title" ); | 957 | list.append( "Job Title" ); |
958 | list.append( "Department" ); | 958 | list.append( "Department" ); |
959 | list.append( "Company" ); | 959 | list.append( "Company" ); |
960 | list.append( "Business Phone" ); | 960 | list.append( "Business Phone" ); |
961 | list.append( "Business Fax" ); | 961 | list.append( "Business Fax" ); |
962 | list.append( "Business Mobile" ); | 962 | list.append( "Business Mobile" ); |
963 | 963 | ||
964 | list.append( "Default Email" ); | 964 | list.append( "Default Email" ); |
965 | list.append( "Emails" ); | 965 | list.append( "Emails" ); |
966 | 966 | ||
967 | list.append( "Home Phone" ); | 967 | list.append( "Home Phone" ); |
968 | list.append( "Home Fax" ); | 968 | list.append( "Home Fax" ); |
969 | list.append( "Home Mobile" ); | 969 | list.append( "Home Mobile" ); |
970 | 970 | ||
971 | list.append( "Business Street" ); | 971 | list.append( "Business Street" ); |
972 | list.append( "Business City" ); | 972 | list.append( "Business City" ); |
973 | list.append( "Business State" ); | 973 | list.append( "Business State" ); |
974 | list.append( "Business Zip" ); | 974 | list.append( "Business Zip" ); |
975 | list.append( "Business Country" ); | 975 | list.append( "Business Country" ); |
976 | list.append( "Business Pager" ); | 976 | list.append( "Business Pager" ); |
977 | list.append( "Business WebPage" ); | 977 | list.append( "Business WebPage" ); |
978 | 978 | ||
979 | list.append( "Office" ); | 979 | list.append( "Office" ); |
980 | list.append( "Profession" ); | 980 | list.append( "Profession" ); |
981 | list.append( "Assistant" ); | 981 | list.append( "Assistant" ); |
982 | list.append( "Manager" ); | 982 | list.append( "Manager" ); |
983 | 983 | ||
984 | list.append( "Home Street" ); | 984 | list.append( "Home Street" ); |
985 | list.append( "Home City" ); | 985 | list.append( "Home City" ); |
986 | list.append( "Home State" ); | 986 | list.append( "Home State" ); |
987 | list.append( "Home Zip" ); | 987 | list.append( "Home Zip" ); |
988 | list.append( "Home Country" ); | 988 | list.append( "Home Country" ); |
989 | list.append( "Home Web Page" ); | 989 | list.append( "Home Web Page" ); |
990 | 990 | ||
991 | list.append( "Spouse" ); | 991 | list.append( "Spouse" ); |
992 | list.append( "Gender" ); | 992 | list.append( "Gender" ); |
993 | list.append( "Birthday" ); | 993 | list.append( "Birthday" ); |
994 | list.append( "Anniversary" ); | 994 | list.append( "Anniversary" ); |
995 | list.append( "Nickname" ); | 995 | list.append( "Nickname" ); |
996 | list.append( "Children" ); | 996 | list.append( "Children" ); |
997 | 997 | ||
998 | list.append( "Notes" ); | 998 | list.append( "Notes" ); |
999 | list.append( "Groups" ); | 999 | list.append( "Groups" ); |
1000 | 1000 | ||
1001 | return list; | 1001 | return list; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /*! | 1004 | /*! |
1005 | Sets the list of email address for contact to those contained in \a str. | 1005 | Sets the list of email address for contact to those contained in \a str. |
1006 | Email address should be separated by ';'s. | 1006 | Email address should be separated by ';'s. |
1007 | */ | 1007 | */ |
1008 | void OContact::setEmails( const QString &str ) | 1008 | void OContact::setEmails( const QString &str ) |
1009 | { | 1009 | { |
1010 | replace( Qtopia::Emails, str ); | 1010 | replace( Qtopia::Emails, str ); |
1011 | if ( str.isEmpty() ) | 1011 | if ( str.isEmpty() ) |
1012 | setDefaultEmail( QString::null ); | 1012 | setDefaultEmail( QString::null ); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | /*! | 1015 | /*! |
1016 | Sets the list of children for the contact to those contained in \a str. | 1016 | Sets the list of children for the contact to those contained in \a str. |
1017 | */ | 1017 | */ |
1018 | void OContact::setChildren( const QString &str ) | 1018 | void OContact::setChildren( const QString &str ) |
1019 | { | 1019 | { |
1020 | replace( Qtopia::Children, str ); | 1020 | replace( Qtopia::Children, str ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | // vcard conversion code | 1023 | // vcard conversion code |
1024 | /*! | 1024 | /*! |
1025 | \internal | 1025 | \internal |
1026 | */ | 1026 | */ |
1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
1028 | { | 1028 | { |
1029 | VObject *ret = 0; | 1029 | VObject *ret = 0; |
1030 | if ( o && !value.isEmpty() ) | 1030 | if ( o && !value.isEmpty() ) |
1031 | ret = addPropValue( o, prop, value.latin1() ); | 1031 | ret = addPropValue( o, prop, value.latin1() ); |
1032 | return ret; | 1032 | return ret; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /*! | 1035 | /*! |
1036 | \internal | 1036 | \internal |
1037 | */ | 1037 | */ |
1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
1039 | { | 1039 | { |
1040 | VObject *ret = 0; | 1040 | VObject *ret = 0; |
1041 | if ( o ) | 1041 | if ( o ) |
1042 | ret = addProp( o, prop ); | 1042 | ret = addProp( o, prop ); |
1043 | return ret; | 1043 | return ret; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | /*! | 1046 | /*! |
1047 | \internal | 1047 | \internal |
1048 | */ | 1048 | */ |
1049 | static VObject *createVObject( const OContact &c ) | 1049 | static VObject *createVObject( const OContact &c ) |
1050 | { | 1050 | { |
1051 | VObject *vcard = newVObject( VCCardProp ); | 1051 | VObject *vcard = newVObject( VCCardProp ); |
1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1055 | 1055 | ||
1056 | // full name | 1056 | // full name |
1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1058 | 1058 | ||
1059 | // name properties | 1059 | // name properties |
1060 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1060 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1066 | 1066 | ||
1067 | // home properties | 1067 | // home properties |
1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1069 | safeAddProp( home_adr, VCHomeProp ); | 1069 | safeAddProp( home_adr, VCHomeProp ); |
1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1075 | 1075 | ||
1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1077 | safeAddProp( home_phone, VCHomeProp ); | 1077 | safeAddProp( home_phone, VCHomeProp ); |
1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1079 | safeAddProp( home_phone, VCHomeProp ); | 1079 | safeAddProp( home_phone, VCHomeProp ); |
1080 | safeAddProp( home_phone, VCCellularProp ); | 1080 | safeAddProp( home_phone, VCCellularProp ); |
1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1082 | safeAddProp( home_phone, VCHomeProp ); | 1082 | safeAddProp( home_phone, VCHomeProp ); |
1083 | safeAddProp( home_phone, VCFaxProp ); | 1083 | safeAddProp( home_phone, VCFaxProp ); |
1084 | 1084 | ||
1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1086 | safeAddProp( url, VCHomeProp ); | 1086 | safeAddProp( url, VCHomeProp ); |
1087 | 1087 | ||
1088 | // work properties | 1088 | // work properties |
1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1090 | safeAddProp( work_adr, VCWorkProp ); | 1090 | safeAddProp( work_adr, VCWorkProp ); |
1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1096 | 1096 | ||
1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1098 | safeAddProp( work_phone, VCWorkProp ); | 1098 | safeAddProp( work_phone, VCWorkProp ); |
1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1100 | safeAddProp( work_phone, VCWorkProp ); | 1100 | safeAddProp( work_phone, VCWorkProp ); |
1101 | safeAddProp( work_phone, VCCellularProp ); | 1101 | safeAddProp( work_phone, VCCellularProp ); |
1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1103 | safeAddProp( work_phone, VCWorkProp ); | 1103 | safeAddProp( work_phone, VCWorkProp ); |
1104 | safeAddProp( work_phone, VCFaxProp ); | 1104 | safeAddProp( work_phone, VCFaxProp ); |
1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1106 | safeAddProp( work_phone, VCWorkProp ); | 1106 | safeAddProp( work_phone, VCWorkProp ); |
1107 | safeAddProp( work_phone, VCPagerProp ); | 1107 | safeAddProp( work_phone, VCPagerProp ); |
1108 | 1108 | ||
1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1110 | safeAddProp( url, VCWorkProp ); | 1110 | safeAddProp( url, VCWorkProp ); |
1111 | 1111 | ||
1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1113 | safeAddProp( title, VCWorkProp ); | 1113 | safeAddProp( title, VCWorkProp ); |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | QStringList emails = c.emailList(); | 1116 | QStringList emails = c.emailList(); |
1117 | emails.prepend( c.defaultEmail() ); | 1117 | emails.prepend( c.defaultEmail() ); |
1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1120 | safeAddProp( email, VCInternetProp ); | 1120 | safeAddProp( email, VCInternetProp ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1124 | 1124 | ||
1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | 1126 | if ( !c.birthday().isValid() ){ |
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | 1127 | QString birthd_rfc2425 = QString("%1-%2-%3") |
1128 | .arg( c.birthday().year() ) | ||
1129 | .arg( c.birthday().month(), 2 ) | ||
1130 | .arg( c.birthday().day(), 2 ); | ||
1131 | // Now replace spaces with "0"... | ||
1132 | int pos = 0; | ||
1133 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) | ||
1134 | birthd_rfc2425.replace( pos, 1, "0" ); | ||
1135 | |||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | 1136 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); |
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); |
1130 | } | 1138 | } |
1131 | 1139 | ||
1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1140 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1141 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1134 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1142 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1135 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1143 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1136 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1144 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1137 | } | 1145 | } |
1138 | 1146 | ||
1139 | // some values we have to export as custom fields | 1147 | // some values we have to export as custom fields |
1140 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1141 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1149 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1142 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1150 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1143 | 1151 | ||
1144 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1152 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1145 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1153 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1146 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); | 1154 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); |
1147 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1155 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1148 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1156 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1149 | 1157 | ||
1150 | return vcard; | 1158 | return vcard; |
1151 | } | 1159 | } |
1152 | 1160 | ||
1153 | 1161 | ||
1154 | /*! | 1162 | /*! |
1155 | \internal | 1163 | \internal |
1156 | */ | 1164 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | 1165 | static QDate convVCardDateToDate( const QString& datestr ) |
1158 | { | 1166 | { |
1159 | int monthPos = datestr.find('-'); | 1167 | int monthPos = datestr.find('-'); |
1160 | int dayPos = datestr.find('-', monthPos+1 ); | 1168 | int dayPos = datestr.find('-', monthPos+1 ); |
1169 | int sep_ignore = 1; | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | 1170 | if ( monthPos == -1 || dayPos == -1 ) { |
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 1171 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
1163 | return QDate(); | 1172 | // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) |
1173 | monthPos = 4; | ||
1174 | dayPos = 6; | ||
1175 | sep_ignore = 0; | ||
1176 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1164 | } | 1177 | } |
1165 | int y = datestr.left( monthPos ).toInt(); | 1178 | int y = datestr.left( monthPos ).toInt(); |
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | 1179 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | 1180 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
1168 | QDate date ( y,m,d ); | ||
1169 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 1181 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
1182 | QDate date ( y,m,d ); | ||
1170 | return date; | 1183 | return date; |
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | static OContact parseVObject( VObject *obj ) | 1186 | static OContact parseVObject( VObject *obj ) |
1174 | { | 1187 | { |
1175 | OContact c; | 1188 | OContact c; |
1176 | 1189 | ||
1177 | VObjectIterator it; | 1190 | VObjectIterator it; |
1178 | initPropIterator( &it, obj ); | 1191 | initPropIterator( &it, obj ); |
1179 | while( moreIteration( &it ) ) { | 1192 | while( moreIteration( &it ) ) { |
1180 | VObject *o = nextVObject( &it ); | 1193 | VObject *o = nextVObject( &it ); |
1181 | QCString name = vObjectName( o ); | 1194 | QCString name = vObjectName( o ); |
1182 | QCString value = vObjectStringZValue( o ); | 1195 | QCString value = vObjectStringZValue( o ); |
1183 | if ( name == VCNameProp ) { | 1196 | if ( name == VCNameProp ) { |
1184 | VObjectIterator nit; | 1197 | VObjectIterator nit; |
1185 | initPropIterator( &nit, o ); | 1198 | initPropIterator( &nit, o ); |
1186 | while( moreIteration( &nit ) ) { | 1199 | while( moreIteration( &nit ) ) { |
1187 | VObject *o = nextVObject( &nit ); | 1200 | VObject *o = nextVObject( &nit ); |
1188 | QCString name = vObjectTypeInfo( o ); | 1201 | QCString name = vObjectTypeInfo( o ); |
1189 | QString value = vObjectStringZValue( o ); | 1202 | QString value = vObjectStringZValue( o ); |
1190 | if ( name == VCNamePrefixesProp ) | 1203 | if ( name == VCNamePrefixesProp ) |
1191 | c.setTitle( value ); | 1204 | c.setTitle( value ); |
1192 | else if ( name == VCNameSuffixesProp ) | 1205 | else if ( name == VCNameSuffixesProp ) |
1193 | c.setSuffix( value ); | 1206 | c.setSuffix( value ); |
1194 | else if ( name == VCFamilyNameProp ) | 1207 | else if ( name == VCFamilyNameProp ) |
1195 | c.setLastName( value ); | 1208 | c.setLastName( value ); |
1196 | else if ( name == VCGivenNameProp ) | 1209 | else if ( name == VCGivenNameProp ) |
1197 | c.setFirstName( value ); | 1210 | c.setFirstName( value ); |
1198 | else if ( name == VCAdditionalNamesProp ) | 1211 | else if ( name == VCAdditionalNamesProp ) |
1199 | c.setMiddleName( value ); | 1212 | c.setMiddleName( value ); |
1200 | } | 1213 | } |
1201 | } | 1214 | } |
1202 | else if ( name == VCAdrProp ) { | 1215 | else if ( name == VCAdrProp ) { |
1203 | bool work = TRUE; // default address is work address | 1216 | bool work = TRUE; // default address is work address |
1204 | QString street; | 1217 | QString street; |
1205 | QString city; | 1218 | QString city; |
1206 | QString region; | 1219 | QString region; |
1207 | QString postal; | 1220 | QString postal; |
1208 | QString country; | 1221 | QString country; |
1209 | 1222 | ||
1210 | VObjectIterator nit; | 1223 | VObjectIterator nit; |
1211 | initPropIterator( &nit, o ); | 1224 | initPropIterator( &nit, o ); |
1212 | while( moreIteration( &nit ) ) { | 1225 | while( moreIteration( &nit ) ) { |
1213 | VObject *o = nextVObject( &nit ); | 1226 | VObject *o = nextVObject( &nit ); |
1214 | QCString name = vObjectName( o ); | 1227 | QCString name = vObjectName( o ); |
1215 | QString value = vObjectStringZValue( o ); | 1228 | QString value = vObjectStringZValue( o ); |
1216 | if ( name == VCHomeProp ) | 1229 | if ( name == VCHomeProp ) |
1217 | work = FALSE; | 1230 | work = FALSE; |
1218 | else if ( name == VCWorkProp ) | 1231 | else if ( name == VCWorkProp ) |
1219 | work = TRUE; | 1232 | work = TRUE; |
1220 | else if ( name == VCStreetAddressProp ) | 1233 | else if ( name == VCStreetAddressProp ) |
1221 | street = value; | 1234 | street = value; |
1222 | else if ( name == VCCityProp ) | 1235 | else if ( name == VCCityProp ) |
1223 | city = value; | 1236 | city = value; |
1224 | else if ( name == VCRegionProp ) | 1237 | else if ( name == VCRegionProp ) |
1225 | region = value; | 1238 | region = value; |
1226 | else if ( name == VCPostalCodeProp ) | 1239 | else if ( name == VCPostalCodeProp ) |
1227 | postal = value; | 1240 | postal = value; |
1228 | else if ( name == VCCountryNameProp ) | 1241 | else if ( name == VCCountryNameProp ) |
1229 | country = value; | 1242 | country = value; |
1230 | } | 1243 | } |
1231 | if ( work ) { | 1244 | if ( work ) { |
1232 | c.setBusinessStreet( street ); | 1245 | c.setBusinessStreet( street ); |
1233 | c.setBusinessCity( city ); | 1246 | c.setBusinessCity( city ); |
1234 | c.setBusinessCountry( country ); | 1247 | c.setBusinessCountry( country ); |
1235 | c.setBusinessZip( postal ); | 1248 | c.setBusinessZip( postal ); |
1236 | c.setBusinessState( region ); | 1249 | c.setBusinessState( region ); |
1237 | } else { | 1250 | } else { |
1238 | c.setHomeStreet( street ); | 1251 | c.setHomeStreet( street ); |
1239 | c.setHomeCity( city ); | 1252 | c.setHomeCity( city ); |
1240 | c.setHomeCountry( country ); | 1253 | c.setHomeCountry( country ); |
1241 | c.setHomeZip( postal ); | 1254 | c.setHomeZip( postal ); |
1242 | c.setHomeState( region ); | 1255 | c.setHomeState( region ); |
1243 | } | 1256 | } |
1244 | } | 1257 | } |
1245 | else if ( name == VCTelephoneProp ) { | 1258 | else if ( name == VCTelephoneProp ) { |
1246 | enum { | 1259 | enum { |
1247 | HOME = 0x01, | 1260 | HOME = 0x01, |
1248 | WORK = 0x02, | 1261 | WORK = 0x02, |
1249 | VOICE = 0x04, | 1262 | VOICE = 0x04, |
1250 | CELL = 0x08, | 1263 | CELL = 0x08, |
1251 | FAX = 0x10, | 1264 | FAX = 0x10, |
1252 | PAGER = 0x20, | 1265 | PAGER = 0x20, |
1253 | UNKNOWN = 0x80 | 1266 | UNKNOWN = 0x80 |
1254 | }; | 1267 | }; |
1255 | int type = 0; | 1268 | int type = 0; |
1256 | 1269 | ||
1257 | VObjectIterator nit; | 1270 | VObjectIterator nit; |
1258 | initPropIterator( &nit, o ); | 1271 | initPropIterator( &nit, o ); |
1259 | while( moreIteration( &nit ) ) { | 1272 | while( moreIteration( &nit ) ) { |
1260 | VObject *o = nextVObject( &nit ); | 1273 | VObject *o = nextVObject( &nit ); |
1261 | QCString name = vObjectTypeInfo( o ); | 1274 | QCString name = vObjectTypeInfo( o ); |
1262 | if ( name == VCHomeProp ) | 1275 | if ( name == VCHomeProp ) |
1263 | type |= HOME; | 1276 | type |= HOME; |
1264 | else if ( name == VCWorkProp ) | 1277 | else if ( name == VCWorkProp ) |
1265 | type |= WORK; | 1278 | type |= WORK; |
1266 | else if ( name == VCVoiceProp ) | 1279 | else if ( name == VCVoiceProp ) |
1267 | type |= VOICE; | 1280 | type |= VOICE; |
1268 | else if ( name == VCCellularProp ) | 1281 | else if ( name == VCCellularProp ) |
1269 | type |= CELL; | 1282 | type |= CELL; |
1270 | else if ( name == VCFaxProp ) | 1283 | else if ( name == VCFaxProp ) |
1271 | type |= FAX; | 1284 | type |= FAX; |
1272 | else if ( name == VCPagerProp ) | 1285 | else if ( name == VCPagerProp ) |
1273 | type |= PAGER; | 1286 | type |= PAGER; |
1274 | else if ( name == VCPreferredProp ) | 1287 | else if ( name == VCPreferredProp ) |
1275 | ; | 1288 | ; |
1276 | else | 1289 | else |
1277 | type |= UNKNOWN; | 1290 | type |= UNKNOWN; |
1278 | } | 1291 | } |
1279 | if ( (type & UNKNOWN) != UNKNOWN ) { | 1292 | if ( (type & UNKNOWN) != UNKNOWN ) { |
1280 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 1293 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
1281 | type |= HOME; | 1294 | type |= HOME; |
1282 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 1295 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
1283 | type |= VOICE; | 1296 | type |= VOICE; |
1284 | 1297 | ||
1285 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 1298 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
1286 | c.setHomePhone( value ); | 1299 | c.setHomePhone( value ); |
1287 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 1300 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
1288 | c.setHomeFax( value ); | 1301 | c.setHomeFax( value ); |
1289 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 1302 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
1290 | c.setHomeMobile( value ); | 1303 | c.setHomeMobile( value ); |
1291 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 1304 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
1292 | c.setBusinessPhone( value ); | 1305 | c.setBusinessPhone( value ); |
1293 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 1306 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
1294 | c.setBusinessFax( value ); | 1307 | c.setBusinessFax( value ); |
1295 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 1308 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
1296 | c.setBusinessMobile( value ); | 1309 | c.setBusinessMobile( value ); |
1297 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 1310 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
1298 | c.setBusinessPager( value ); | 1311 | c.setBusinessPager( value ); |
1299 | } | 1312 | } |
1300 | } | 1313 | } |
1301 | else if ( name == VCEmailAddressProp ) { | 1314 | else if ( name == VCEmailAddressProp ) { |
1302 | QString email = vObjectStringZValue( o ); | 1315 | QString email = vObjectStringZValue( o ); |
1303 | bool valid = TRUE; | 1316 | bool valid = TRUE; |
1304 | VObjectIterator nit; | 1317 | VObjectIterator nit; |
1305 | initPropIterator( &nit, o ); | 1318 | initPropIterator( &nit, o ); |
1306 | while( moreIteration( &nit ) ) { | 1319 | while( moreIteration( &nit ) ) { |
1307 | VObject *o = nextVObject( &nit ); | 1320 | VObject *o = nextVObject( &nit ); |
1308 | QCString name = vObjectTypeInfo( o ); | 1321 | QCString name = vObjectTypeInfo( o ); |
1309 | if ( name != VCInternetProp && name != VCHomeProp && | 1322 | if ( name != VCInternetProp && name != VCHomeProp && |
1310 | name != VCWorkProp && | 1323 | name != VCWorkProp && |
1311 | name != VCPreferredProp ) | 1324 | name != VCPreferredProp ) |
1312 | // ### preffered should map to default email | 1325 | // ### preffered should map to default email |
1313 | valid = FALSE; | 1326 | valid = FALSE; |
1314 | } | 1327 | } |
1315 | if ( valid ) { | 1328 | if ( valid ) { |
1316 | c.insertEmail( email ); | 1329 | c.insertEmail( email ); |
1317 | } | 1330 | } |
1318 | } | 1331 | } |
1319 | else if ( name == VCURLProp ) { | 1332 | else if ( name == VCURLProp ) { |
1320 | VObjectIterator nit; | 1333 | VObjectIterator nit; |
1321 | initPropIterator( &nit, o ); | 1334 | initPropIterator( &nit, o ); |
1322 | while( moreIteration( &nit ) ) { | 1335 | while( moreIteration( &nit ) ) { |
1323 | VObject *o = nextVObject( &nit ); | 1336 | VObject *o = nextVObject( &nit ); |
1324 | QCString name = vObjectTypeInfo( o ); | 1337 | QCString name = vObjectTypeInfo( o ); |
1325 | if ( name == VCHomeProp ) | 1338 | if ( name == VCHomeProp ) |
1326 | c.setHomeWebpage( value ); | 1339 | c.setHomeWebpage( value ); |
1327 | else if ( name == VCWorkProp ) | 1340 | else if ( name == VCWorkProp ) |
1328 | c.setBusinessWebpage( value ); | 1341 | c.setBusinessWebpage( value ); |
1329 | } | 1342 | } |
1330 | } | 1343 | } |
1331 | else if ( name == VCOrgProp ) { | 1344 | else if ( name == VCOrgProp ) { |
1332 | VObjectIterator nit; | 1345 | VObjectIterator nit; |
1333 | initPropIterator( &nit, o ); | 1346 | initPropIterator( &nit, o ); |
1334 | while( moreIteration( &nit ) ) { | 1347 | while( moreIteration( &nit ) ) { |
1335 | VObject *o = nextVObject( &nit ); | 1348 | VObject *o = nextVObject( &nit ); |
1336 | QCString name = vObjectName( o ); | 1349 | QCString name = vObjectName( o ); |
1337 | QString value = vObjectStringZValue( o ); | 1350 | QString value = vObjectStringZValue( o ); |
1338 | if ( name == VCOrgNameProp ) | 1351 | if ( name == VCOrgNameProp ) |
1339 | c.setCompany( value ); | 1352 | c.setCompany( value ); |
1340 | else if ( name == VCOrgUnitProp ) | 1353 | else if ( name == VCOrgUnitProp ) |
1341 | c.setDepartment( value ); | 1354 | c.setDepartment( value ); |
1342 | else if ( name == VCOrgUnit2Prop ) | 1355 | else if ( name == VCOrgUnit2Prop ) |
1343 | c.setOffice( value ); | 1356 | c.setOffice( value ); |
1344 | } | 1357 | } |
1345 | } | 1358 | } |
1346 | else if ( name == VCTitleProp ) { | 1359 | else if ( name == VCTitleProp ) { |
1347 | c.setJobTitle( value ); | 1360 | c.setJobTitle( value ); |
1348 | } | 1361 | } |
1349 | else if ( name == "X-Qtopia-Profession" ) { | 1362 | else if ( name == "X-Qtopia-Profession" ) { |
1350 | c.setProfession( value ); | 1363 | c.setProfession( value ); |
1351 | } | 1364 | } |
1352 | else if ( name == "X-Qtopia-Manager" ) { | 1365 | else if ( name == "X-Qtopia-Manager" ) { |
1353 | c.setManager( value ); | 1366 | c.setManager( value ); |
1354 | } | 1367 | } |
1355 | else if ( name == "X-Qtopia-Assistant" ) { | 1368 | else if ( name == "X-Qtopia-Assistant" ) { |
1356 | c.setAssistant( value ); | 1369 | c.setAssistant( value ); |
1357 | } | 1370 | } |
1358 | else if ( name == "X-Qtopia-Spouse" ) { | 1371 | else if ( name == "X-Qtopia-Spouse" ) { |
1359 | c.setSpouse( value ); | 1372 | c.setSpouse( value ); |
1360 | } | 1373 | } |
1361 | else if ( name == "X-Qtopia-Gender" ) { | 1374 | else if ( name == "X-Qtopia-Gender" ) { |
1362 | c.setGender( value ); | 1375 | c.setGender( value ); |
1363 | } | 1376 | } |
1364 | else if ( name == "X-Qtopia-Anniversary" ) { | 1377 | else if ( name == "X-Qtopia-Anniversary" ) { |
1365 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1378 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1366 | } | 1379 | } |
1367 | else if ( name == "X-Qtopia-Nickname" ) { | 1380 | else if ( name == "X-Qtopia-Nickname" ) { |
1368 | c.setNickname( value ); | 1381 | c.setNickname( value ); |
1369 | } | 1382 | } |
1370 | else if ( name == "X-Qtopia-Children" ) { | 1383 | else if ( name == "X-Qtopia-Children" ) { |
1371 | c.setChildren( value ); | 1384 | c.setChildren( value ); |
1372 | } | 1385 | } |
1373 | else if ( name == VCBirthDateProp ) { | 1386 | else if ( name == VCBirthDateProp ) { |
1374 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 1387 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
1375 | c.setBirthday( convVCardDateToDate( value ) ); | 1388 | c.setBirthday( convVCardDateToDate( value ) ); |
1376 | 1389 | ||
1377 | } | 1390 | } |
1378 | 1391 | ||
1379 | #if 0 | 1392 | #if 0 |
1380 | else { | 1393 | else { |
1381 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1394 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1382 | VObjectIterator nit; | 1395 | VObjectIterator nit; |
1383 | initPropIterator( &nit, o ); | 1396 | initPropIterator( &nit, o ); |
1384 | while( moreIteration( &nit ) ) { | 1397 | while( moreIteration( &nit ) ) { |
1385 | VObject *o = nextVObject( &nit ); | 1398 | VObject *o = nextVObject( &nit ); |
1386 | QCString name = vObjectName( o ); | 1399 | QCString name = vObjectName( o ); |
1387 | QString value = vObjectStringZValue( o ); | 1400 | QString value = vObjectStringZValue( o ); |
1388 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1401 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1389 | } | 1402 | } |
1390 | } | 1403 | } |
1391 | #endif | 1404 | #endif |
1392 | } | 1405 | } |
1393 | c.setFileAs(); | 1406 | c.setFileAs(); |
1394 | return c; | 1407 | return c; |
1395 | } | 1408 | } |
1396 | 1409 | ||
1397 | /*! | 1410 | /*! |
1398 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1411 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1399 | */ | 1412 | */ |
1400 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1413 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1401 | { | 1414 | { |
1402 | QFileDirect f( filename.utf8().data() ); | 1415 | QFileDirect f( filename.utf8().data() ); |
1403 | if ( !f.open( IO_WriteOnly ) ) { | 1416 | if ( !f.open( IO_WriteOnly ) ) { |
1404 | qWarning("Unable to open vcard write"); | 1417 | qWarning("Unable to open vcard write"); |
1405 | return; | 1418 | return; |
1406 | } | 1419 | } |
1407 | 1420 | ||
1408 | QValueList<OContact>::ConstIterator it; | 1421 | QValueList<OContact>::ConstIterator it; |
1409 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1422 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1410 | VObject *obj = createVObject( *it ); | 1423 | VObject *obj = createVObject( *it ); |
1411 | writeVObject(f.directHandle() , obj ); | 1424 | writeVObject(f.directHandle() , obj ); |
1412 | cleanVObject( obj ); | 1425 | cleanVObject( obj ); |
1413 | } | 1426 | } |
1414 | cleanStrTbl(); | 1427 | cleanStrTbl(); |
1415 | } | 1428 | } |
1416 | 1429 | ||
1417 | /*! | 1430 | /*! |
1418 | writes \a contact as a VCard to the file \a filename. | 1431 | writes \a contact as a VCard to the file \a filename. |
1419 | */ | 1432 | */ |
1420 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1433 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1421 | { | 1434 | { |
1422 | QFileDirect f( filename.utf8().data() ); | 1435 | QFileDirect f( filename.utf8().data() ); |
1423 | if ( !f.open( IO_WriteOnly ) ) { | 1436 | if ( !f.open( IO_WriteOnly ) ) { |
1424 | qWarning("Unable to open vcard write"); | 1437 | qWarning("Unable to open vcard write"); |
1425 | return; | 1438 | return; |
1426 | } | 1439 | } |
1427 | 1440 | ||
1428 | VObject *obj = createVObject( contact ); | 1441 | VObject *obj = createVObject( contact ); |
1429 | writeVObject( f.directHandle() , obj ); | 1442 | writeVObject( f.directHandle() , obj ); |
1430 | cleanVObject( obj ); | 1443 | cleanVObject( obj ); |
1431 | 1444 | ||
1432 | cleanStrTbl(); | 1445 | cleanStrTbl(); |
1433 | } | 1446 | } |
1434 | 1447 | ||
1435 | /*! | 1448 | /*! |
1436 | Returns the set of contacts read as VCards from the file \a filename. | 1449 | Returns the set of contacts read as VCards from the file \a filename. |
1437 | */ | 1450 | */ |
1438 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1451 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1439 | { | 1452 | { |
1440 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1453 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1441 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1454 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1442 | 1455 | ||
1443 | qDebug("vobject = %p", obj ); | 1456 | qDebug("vobject = %p", obj ); |
1444 | 1457 | ||
1445 | QValueList<OContact> contacts; | 1458 | QValueList<OContact> contacts; |
1446 | 1459 | ||
1447 | while ( obj ) { | 1460 | while ( obj ) { |
1448 | contacts.append( parseVObject( obj ) ); | 1461 | contacts.append( parseVObject( obj ) ); |
1449 | 1462 | ||
1450 | VObject *t = obj; | 1463 | VObject *t = obj; |
1451 | obj = nextVObjectInList(obj); | 1464 | obj = nextVObjectInList(obj); |
1452 | cleanVObject( t ); | 1465 | cleanVObject( t ); |
1453 | } | 1466 | } |
1454 | 1467 | ||
1455 | return contacts; | 1468 | return contacts; |
1456 | } | 1469 | } |
1457 | 1470 | ||
1458 | /*! | 1471 | /*! |
1459 | Returns TRUE if the contact matches the regular expression \a regexp. | 1472 | Returns TRUE if the contact matches the regular expression \a regexp. |
1460 | Otherwise returns FALSE. | 1473 | Otherwise returns FALSE. |
1461 | */ | 1474 | */ |
1462 | bool OContact::match( const QString ®exp ) const | 1475 | bool OContact::match( const QString ®exp ) const |
1463 | { | 1476 | { |
1464 | return match(QRegExp(regexp)); | 1477 | return match(QRegExp(regexp)); |
1465 | } | 1478 | } |
1466 | 1479 | ||
1467 | /*! | 1480 | /*! |
1468 | \overload | 1481 | \overload |
1469 | Returns TRUE if the contact matches the regular expression \a regexp. | 1482 | Returns TRUE if the contact matches the regular expression \a regexp. |
1470 | Otherwise returns FALSE. | 1483 | Otherwise returns FALSE. |
1471 | */ | 1484 | */ |
1472 | bool OContact::match( const QRegExp &r ) const | 1485 | bool OContact::match( const QRegExp &r ) const |
1473 | { | 1486 | { |
1474 | bool match; | 1487 | bool match; |
1475 | match = false; | 1488 | match = false; |
1476 | QMap<int, QString>::ConstIterator it; | 1489 | QMap<int, QString>::ConstIterator it; |
1477 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1490 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1478 | if ( (*it).find( r ) > -1 ) { | 1491 | if ( (*it).find( r ) > -1 ) { |
1479 | match = true; | 1492 | match = true; |
1480 | break; | 1493 | break; |
1481 | } | 1494 | } |
1482 | } | 1495 | } |
1483 | return match; | 1496 | return match; |
1484 | } | 1497 | } |
1485 | 1498 | ||
1486 | 1499 | ||
1487 | QString OContact::toShortText() const | 1500 | QString OContact::toShortText() const |
1488 | { | 1501 | { |
1489 | return ( fullName() ); | 1502 | return ( fullName() ); |
1490 | } | 1503 | } |
1491 | QString OContact::type() const | 1504 | QString OContact::type() const |
1492 | { | 1505 | { |
1493 | return QString::fromLatin1( "OContact" ); | 1506 | return QString::fromLatin1( "OContact" ); |
1494 | } | 1507 | } |
1495 | 1508 | ||
1496 | // Definition is missing ! (se) | 1509 | // Definition is missing ! (se) |
1497 | QMap<QString,QString> OContact::toExtraMap() const | 1510 | QMap<QString,QString> OContact::toExtraMap() const |
1498 | { | 1511 | { |
1499 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1512 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1500 | QMap <QString,QString> useless; | 1513 | QMap <QString,QString> useless; |
1501 | return useless; | 1514 | return useless; |
1502 | } | 1515 | } |
1503 | 1516 | ||
1504 | class QString OContact::recordField( int pos ) const | 1517 | class QString OContact::recordField( int pos ) const |
1505 | { | 1518 | { |
1506 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1519 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1507 | return SLFIELDS[pos]; | 1520 | return SLFIELDS[pos]; |
1508 | } | 1521 | } |
1509 | 1522 | ||
1510 | // In future releases, we should store birthday and anniversary | 1523 | // In future releases, we should store birthday and anniversary |
1511 | // internally as QDate instead of QString ! | 1524 | // internally as QDate instead of QString ! |
1512 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1525 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1513 | 1526 | ||
1514 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1527 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1515 | Sets the birthday for the contact to \a date. | 1528 | Sets the birthday for the contact to \a date. |
1516 | */ | 1529 | */ |
1517 | void OContact::setBirthday( const QDate &v ) | 1530 | void OContact::setBirthday( const QDate &v ) |
1518 | { | 1531 | { |
1519 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1532 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1520 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1533 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1521 | 1534 | ||
1522 | } | 1535 | } |
1523 | 1536 | ||
1524 | 1537 | ||
1525 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1538 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1526 | Sets the anniversary of the contact to \a date. | 1539 | Sets the anniversary of the contact to \a date. |
1527 | */ | 1540 | */ |
1528 | void OContact::setAnniversary( const QDate &v ) | 1541 | void OContact::setAnniversary( const QDate &v ) |
1529 | { | 1542 | { |
1530 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1543 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1531 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1544 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1532 | } | 1545 | } |
1533 | 1546 | ||
1534 | /*! \fn QDate OContact::birthday() const | 1547 | /*! \fn QDate OContact::birthday() const |
1535 | Returns the birthday of the contact. | 1548 | Returns the birthday of the contact. |
1536 | */ | 1549 | */ |
1537 | QDate OContact::birthday() const | 1550 | QDate OContact::birthday() const |
1538 | { | 1551 | { |
1539 | QDate empty; | 1552 | QDate empty; |
1540 | QString str = find( Qtopia::Birthday ); | 1553 | QString str = find( Qtopia::Birthday ); |
1541 | qWarning ("Birthday %s", str.latin1() ); | 1554 | qWarning ("Birthday %s", str.latin1() ); |
1542 | if ( !str.isEmpty() ) | 1555 | if ( !str.isEmpty() ) |
1543 | return TimeConversion::fromString ( str ); | 1556 | return TimeConversion::fromString ( str ); |
1544 | else | 1557 | else |
1545 | return empty; | 1558 | return empty; |
1546 | } | 1559 | } |
1547 | 1560 | ||
1548 | 1561 | ||
1549 | /*! \fn QDate OContact::anniversary() const | 1562 | /*! \fn QDate OContact::anniversary() const |
1550 | Returns the anniversary of the contact. | 1563 | Returns the anniversary of the contact. |
1551 | */ | 1564 | */ |
1552 | QDate OContact::anniversary() const | 1565 | QDate OContact::anniversary() const |
1553 | { | 1566 | { |
1554 | QDate empty; | 1567 | QDate empty; |
1555 | QString str = find( Qtopia::Anniversary ); | 1568 | QString str = find( Qtopia::Anniversary ); |
1556 | qWarning ("Anniversary %s", str.latin1() ); | 1569 | qWarning ("Anniversary %s", str.latin1() ); |
1557 | if ( !str.isEmpty() ) | 1570 | if ( !str.isEmpty() ) |
1558 | return TimeConversion::fromString ( str ); | 1571 | return TimeConversion::fromString ( str ); |
1559 | else | 1572 | else |
1560 | return empty; | 1573 | return empty; |
1561 | } | 1574 | } |
1562 | 1575 | ||
1563 | 1576 | ||
1564 | void OContact::insertEmail( const QString &v ) | 1577 | void OContact::insertEmail( const QString &v ) |
1565 | { | 1578 | { |
1566 | //qDebug("insertEmail %s", v.latin1()); | 1579 | //qDebug("insertEmail %s", v.latin1()); |
1567 | QString e = v.simplifyWhiteSpace(); | 1580 | QString e = v.simplifyWhiteSpace(); |
1568 | QString def = defaultEmail(); | 1581 | QString def = defaultEmail(); |
1569 | 1582 | ||
1570 | // if no default, set it as the default email and don't insert | 1583 | // if no default, set it as the default email and don't insert |
1571 | if ( def.isEmpty() ) { | 1584 | if ( def.isEmpty() ) { |
1572 | setDefaultEmail( e ); // will insert into the list for us | 1585 | setDefaultEmail( e ); // will insert into the list for us |
1573 | return; | 1586 | return; |
1574 | } | 1587 | } |
1575 | 1588 | ||
1576 | // otherwise, insert assuming doesn't already exist | 1589 | // otherwise, insert assuming doesn't already exist |
1577 | QString emailsStr = find( Qtopia::Emails ); | 1590 | QString emailsStr = find( Qtopia::Emails ); |
1578 | if ( emailsStr.contains( e )) | 1591 | if ( emailsStr.contains( e )) |
1579 | return; | 1592 | return; |
1580 | if ( !emailsStr.isEmpty() ) | 1593 | if ( !emailsStr.isEmpty() ) |
1581 | emailsStr += emailSeparator(); | 1594 | emailsStr += emailSeparator(); |
1582 | emailsStr += e; | 1595 | emailsStr += e; |
1583 | replace( Qtopia::Emails, emailsStr ); | 1596 | replace( Qtopia::Emails, emailsStr ); |
1584 | } | 1597 | } |
1585 | 1598 | ||
1586 | void OContact::removeEmail( const QString &v ) | 1599 | void OContact::removeEmail( const QString &v ) |
1587 | { | 1600 | { |
1588 | QString e = v.simplifyWhiteSpace(); | 1601 | QString e = v.simplifyWhiteSpace(); |
1589 | QString def = defaultEmail(); | 1602 | QString def = defaultEmail(); |
1590 | QString emailsStr = find( Qtopia::Emails ); | 1603 | QString emailsStr = find( Qtopia::Emails ); |
1591 | QStringList emails = emailList(); | 1604 | QStringList emails = emailList(); |
1592 | 1605 | ||
1593 | // otherwise, must first contain it | 1606 | // otherwise, must first contain it |
1594 | if ( !emailsStr.contains( e ) ) | 1607 | if ( !emailsStr.contains( e ) ) |
1595 | return; | 1608 | return; |
1596 | 1609 | ||
1597 | // remove it | 1610 | // remove it |
1598 | //qDebug(" removing email from list %s", e.latin1()); | 1611 | //qDebug(" removing email from list %s", e.latin1()); |
1599 | emails.remove( e ); | 1612 | emails.remove( e ); |
1600 | // reset the string | 1613 | // reset the string |
1601 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1614 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1602 | replace( Qtopia::Emails, emailsStr ); | 1615 | replace( Qtopia::Emails, emailsStr ); |
1603 | 1616 | ||
1604 | // if default, then replace the default email with the first one | 1617 | // if default, then replace the default email with the first one |
1605 | if ( def == e ) { | 1618 | if ( def == e ) { |
1606 | //qDebug("removeEmail is default; setting new default"); | 1619 | //qDebug("removeEmail is default; setting new default"); |
1607 | if ( !emails.count() ) | 1620 | if ( !emails.count() ) |
1608 | clearEmails(); | 1621 | clearEmails(); |
1609 | else // setDefaultEmail will remove e from the list | 1622 | else // setDefaultEmail will remove e from the list |
1610 | setDefaultEmail( emails.first() ); | 1623 | setDefaultEmail( emails.first() ); |
1611 | } | 1624 | } |
1612 | } | 1625 | } |
1613 | void OContact::clearEmails() | 1626 | void OContact::clearEmails() |
1614 | { | 1627 | { |
1615 | mMap.remove( Qtopia::DefaultEmail ); | 1628 | mMap.remove( Qtopia::DefaultEmail ); |
1616 | mMap.remove( Qtopia::Emails ); | 1629 | mMap.remove( Qtopia::Emails ); |
1617 | } | 1630 | } |
1618 | void OContact::setDefaultEmail( const QString &v ) | 1631 | void OContact::setDefaultEmail( const QString &v ) |
1619 | { | 1632 | { |
1620 | QString e = v.simplifyWhiteSpace(); | 1633 | QString e = v.simplifyWhiteSpace(); |
1621 | 1634 | ||
1622 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1635 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1623 | replace( Qtopia::DefaultEmail, e ); | 1636 | replace( Qtopia::DefaultEmail, e ); |
1624 | 1637 | ||
1625 | if ( !e.isEmpty() ) | 1638 | if ( !e.isEmpty() ) |
1626 | insertEmail( e ); | 1639 | insertEmail( e ); |
1627 | 1640 | ||
1628 | } | 1641 | } |
1629 | 1642 | ||
1630 | void OContact::insertEmails( const QStringList &v ) | 1643 | void OContact::insertEmails( const QStringList &v ) |
1631 | { | 1644 | { |
1632 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1645 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1633 | insertEmail( *it ); | 1646 | insertEmail( *it ); |
1634 | } | 1647 | } |
1635 | 1648 | ||
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index 734f5a2..bf27d0f 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,1635 +1,1648 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #define QTOPIA_INTERNAL_CONTACT_MRE | 22 | #define QTOPIA_INTERNAL_CONTACT_MRE |
23 | 23 | ||
24 | #include "ocontact.h" | 24 | #include "ocontact.h" |
25 | #include "../../library/backend/vobject_p.h" | 25 | #include "../../library/backend/vobject_p.h" |
26 | #include "../../library/backend/qfiledirect_p.h" | 26 | #include "../../library/backend/qfiledirect_p.h" |
27 | 27 | ||
28 | #include <qpe/stringutil.h> | 28 | #include <qpe/stringutil.h> |
29 | #include <qpe/timeconversion.h> | 29 | #include <qpe/timeconversion.h> |
30 | #include <qpe/timestring.h> | 30 | #include <qpe/timestring.h> |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qstylesheet.h> | 34 | #include <qstylesheet.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | 39 | ||
40 | /*! | 40 | /*! |
41 | \class Contact contact.h | 41 | \class Contact contact.h |
42 | \brief The Contact class holds the data of an address book entry. | 42 | \brief The Contact class holds the data of an address book entry. |
43 | 43 | ||
44 | This data includes information the name of the person, contact | 44 | This data includes information the name of the person, contact |
45 | information, and business information such as deparment and job title. | 45 | information, and business information such as deparment and job title. |
46 | 46 | ||
47 | \ingroup qtopiaemb | 47 | \ingroup qtopiaemb |
48 | \ingroup qtopiadesktop | 48 | \ingroup qtopiadesktop |
49 | */ | 49 | */ |
50 | 50 | ||
51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); | 51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); |
52 | 52 | ||
53 | /*! | 53 | /*! |
54 | Creates a new, empty contact. | 54 | Creates a new, empty contact. |
55 | */ | 55 | */ |
56 | OContact::OContact() | 56 | OContact::OContact() |
57 | : OPimRecord(), mMap(), d( 0 ) | 57 | : OPimRecord(), mMap(), d( 0 ) |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | /*! | 61 | /*! |
62 | \internal | 62 | \internal |
63 | Creates a new contact. The properties of the contact are | 63 | Creates a new contact. The properties of the contact are |
64 | set from \a fromMap. | 64 | set from \a fromMap. |
65 | */ | 65 | */ |
66 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 66 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
67 | OPimRecord(), mMap( fromMap ), d( 0 ) | 67 | OPimRecord(), mMap( fromMap ), d( 0 ) |
68 | { | 68 | { |
69 | QString cats = mMap[ Qtopia::AddressCategory ]; | 69 | QString cats = mMap[ Qtopia::AddressCategory ]; |
70 | if ( !cats.isEmpty() ) | 70 | if ( !cats.isEmpty() ) |
71 | setCategories( idsFromString( cats ) ); | 71 | setCategories( idsFromString( cats ) ); |
72 | QString uidStr = find( Qtopia::AddressUid ); | 72 | QString uidStr = find( Qtopia::AddressUid ); |
73 | 73 | ||
74 | if ( uidStr.isEmpty() ) | 74 | if ( uidStr.isEmpty() ) |
75 | setUid( uidGen().generate() ); | 75 | setUid( uidGen().generate() ); |
76 | else | 76 | else |
77 | setUid( uidStr.toInt() ); | 77 | setUid( uidStr.toInt() ); |
78 | 78 | ||
79 | if ( !uidStr.isEmpty() ) | 79 | if ( !uidStr.isEmpty() ) |
80 | setUid( uidStr.toInt() ); | 80 | setUid( uidStr.toInt() ); |
81 | } | 81 | } |
82 | 82 | ||
83 | /*! | 83 | /*! |
84 | Destroys a contact. | 84 | Destroys a contact. |
85 | */ | 85 | */ |
86 | OContact::~OContact() | 86 | OContact::~OContact() |
87 | { | 87 | { |
88 | } | 88 | } |
89 | 89 | ||
90 | /*! \fn void OContact::setTitle( const QString &str ) | 90 | /*! \fn void OContact::setTitle( const QString &str ) |
91 | Sets the title of the contact to \a str. | 91 | Sets the title of the contact to \a str. |
92 | */ | 92 | */ |
93 | 93 | ||
94 | /*! \fn void OContact::setFirstName( const QString &str ) | 94 | /*! \fn void OContact::setFirstName( const QString &str ) |
95 | Sets the first name of the contact to \a str. | 95 | Sets the first name of the contact to \a str. |
96 | */ | 96 | */ |
97 | 97 | ||
98 | /*! \fn void OContact::setMiddleName( const QString &str ) | 98 | /*! \fn void OContact::setMiddleName( const QString &str ) |
99 | Sets the middle name of the contact to \a str. | 99 | Sets the middle name of the contact to \a str. |
100 | */ | 100 | */ |
101 | 101 | ||
102 | /*! \fn void OContact::setLastName( const QString &str ) | 102 | /*! \fn void OContact::setLastName( const QString &str ) |
103 | Sets the last name of the contact to \a str. | 103 | Sets the last name of the contact to \a str. |
104 | */ | 104 | */ |
105 | 105 | ||
106 | /*! \fn void OContact::setSuffix( const QString &str ) | 106 | /*! \fn void OContact::setSuffix( const QString &str ) |
107 | Sets the suffix of the contact to \a str. | 107 | Sets the suffix of the contact to \a str. |
108 | */ | 108 | */ |
109 | 109 | ||
110 | /*! \fn void OContact::setFileAs( const QString &str ) | 110 | /*! \fn void OContact::setFileAs( const QString &str ) |
111 | Sets the contact to filed as \a str. | 111 | Sets the contact to filed as \a str. |
112 | */ | 112 | */ |
113 | 113 | ||
114 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 114 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
115 | Sets the default email of the contact to \a str. | 115 | Sets the default email of the contact to \a str. |
116 | */ | 116 | */ |
117 | 117 | ||
118 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 118 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
119 | Sets the home street address of the contact to \a str. | 119 | Sets the home street address of the contact to \a str. |
120 | */ | 120 | */ |
121 | 121 | ||
122 | /*! \fn void OContact::setHomeCity( const QString &str ) | 122 | /*! \fn void OContact::setHomeCity( const QString &str ) |
123 | Sets the home city of the contact to \a str. | 123 | Sets the home city of the contact to \a str. |
124 | */ | 124 | */ |
125 | 125 | ||
126 | /*! \fn void OContact::setHomeState( const QString &str ) | 126 | /*! \fn void OContact::setHomeState( const QString &str ) |
127 | Sets the home state of the contact to \a str. | 127 | Sets the home state of the contact to \a str. |
128 | */ | 128 | */ |
129 | 129 | ||
130 | /*! \fn void OContact::setHomeZip( const QString &str ) | 130 | /*! \fn void OContact::setHomeZip( const QString &str ) |
131 | Sets the home zip code of the contact to \a str. | 131 | Sets the home zip code of the contact to \a str. |
132 | */ | 132 | */ |
133 | 133 | ||
134 | /*! \fn void OContact::setHomeCountry( const QString &str ) | 134 | /*! \fn void OContact::setHomeCountry( const QString &str ) |
135 | Sets the home country of the contact to \a str. | 135 | Sets the home country of the contact to \a str. |
136 | */ | 136 | */ |
137 | 137 | ||
138 | /*! \fn void OContact::setHomePhone( const QString &str ) | 138 | /*! \fn void OContact::setHomePhone( const QString &str ) |
139 | Sets the home phone number of the contact to \a str. | 139 | Sets the home phone number of the contact to \a str. |
140 | */ | 140 | */ |
141 | 141 | ||
142 | /*! \fn void OContact::setHomeFax( const QString &str ) | 142 | /*! \fn void OContact::setHomeFax( const QString &str ) |
143 | Sets the home fax number of the contact to \a str. | 143 | Sets the home fax number of the contact to \a str. |
144 | */ | 144 | */ |
145 | 145 | ||
146 | /*! \fn void OContact::setHomeMobile( const QString &str ) | 146 | /*! \fn void OContact::setHomeMobile( const QString &str ) |
147 | Sets the home mobile phone number of the contact to \a str. | 147 | Sets the home mobile phone number of the contact to \a str. |
148 | */ | 148 | */ |
149 | 149 | ||
150 | /*! \fn void OContact::setHomeWebpage( const QString &str ) | 150 | /*! \fn void OContact::setHomeWebpage( const QString &str ) |
151 | Sets the home webpage of the contact to \a str. | 151 | Sets the home webpage of the contact to \a str. |
152 | */ | 152 | */ |
153 | 153 | ||
154 | /*! \fn void OContact::setCompany( const QString &str ) | 154 | /*! \fn void OContact::setCompany( const QString &str ) |
155 | Sets the company for contact to \a str. | 155 | Sets the company for contact to \a str. |
156 | */ | 156 | */ |
157 | 157 | ||
158 | /*! \fn void OContact::setJobTitle( const QString &str ) | 158 | /*! \fn void OContact::setJobTitle( const QString &str ) |
159 | Sets the job title of the contact to \a str. | 159 | Sets the job title of the contact to \a str. |
160 | */ | 160 | */ |
161 | 161 | ||
162 | /*! \fn void OContact::setDepartment( const QString &str ) | 162 | /*! \fn void OContact::setDepartment( const QString &str ) |
163 | Sets the department for contact to \a str. | 163 | Sets the department for contact to \a str. |
164 | */ | 164 | */ |
165 | 165 | ||
166 | /*! \fn void OContact::setOffice( const QString &str ) | 166 | /*! \fn void OContact::setOffice( const QString &str ) |
167 | Sets the office for contact to \a str. | 167 | Sets the office for contact to \a str. |
168 | */ | 168 | */ |
169 | 169 | ||
170 | /*! \fn void OContact::setBusinessStreet( const QString &str ) | 170 | /*! \fn void OContact::setBusinessStreet( const QString &str ) |
171 | Sets the business street address of the contact to \a str. | 171 | Sets the business street address of the contact to \a str. |
172 | */ | 172 | */ |
173 | 173 | ||
174 | /*! \fn void OContact::setBusinessCity( const QString &str ) | 174 | /*! \fn void OContact::setBusinessCity( const QString &str ) |
175 | Sets the business city of the contact to \a str. | 175 | Sets the business city of the contact to \a str. |
176 | */ | 176 | */ |
177 | 177 | ||
178 | /*! \fn void OContact::setBusinessState( const QString &str ) | 178 | /*! \fn void OContact::setBusinessState( const QString &str ) |
179 | Sets the business state of the contact to \a str. | 179 | Sets the business state of the contact to \a str. |
180 | */ | 180 | */ |
181 | 181 | ||
182 | /*! \fn void OContact::setBusinessZip( const QString &str ) | 182 | /*! \fn void OContact::setBusinessZip( const QString &str ) |
183 | Sets the business zip code of the contact to \a str. | 183 | Sets the business zip code of the contact to \a str. |
184 | */ | 184 | */ |
185 | 185 | ||
186 | /*! \fn void OContact::setBusinessCountry( const QString &str ) | 186 | /*! \fn void OContact::setBusinessCountry( const QString &str ) |
187 | Sets the business country of the contact to \a str. | 187 | Sets the business country of the contact to \a str. |
188 | */ | 188 | */ |
189 | 189 | ||
190 | /*! \fn void OContact::setBusinessPhone( const QString &str ) | 190 | /*! \fn void OContact::setBusinessPhone( const QString &str ) |
191 | Sets the business phone number of the contact to \a str. | 191 | Sets the business phone number of the contact to \a str. |
192 | */ | 192 | */ |
193 | 193 | ||
194 | /*! \fn void OContact::setBusinessFax( const QString &str ) | 194 | /*! \fn void OContact::setBusinessFax( const QString &str ) |
195 | Sets the business fax number of the contact to \a str. | 195 | Sets the business fax number of the contact to \a str. |
196 | */ | 196 | */ |
197 | 197 | ||
198 | /*! \fn void OContact::setBusinessMobile( const QString &str ) | 198 | /*! \fn void OContact::setBusinessMobile( const QString &str ) |
199 | Sets the business mobile phone number of the contact to \a str. | 199 | Sets the business mobile phone number of the contact to \a str. |
200 | */ | 200 | */ |
201 | 201 | ||
202 | /*! \fn void OContact::setBusinessPager( const QString &str ) | 202 | /*! \fn void OContact::setBusinessPager( const QString &str ) |
203 | Sets the business pager number of the contact to \a str. | 203 | Sets the business pager number of the contact to \a str. |
204 | */ | 204 | */ |
205 | 205 | ||
206 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) | 206 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) |
207 | Sets the business webpage of the contact to \a str. | 207 | Sets the business webpage of the contact to \a str. |
208 | */ | 208 | */ |
209 | 209 | ||
210 | /*! \fn void OContact::setProfession( const QString &str ) | 210 | /*! \fn void OContact::setProfession( const QString &str ) |
211 | Sets the profession of the contact to \a str. | 211 | Sets the profession of the contact to \a str. |
212 | */ | 212 | */ |
213 | 213 | ||
214 | /*! \fn void OContact::setAssistant( const QString &str ) | 214 | /*! \fn void OContact::setAssistant( const QString &str ) |
215 | Sets the assistant of the contact to \a str. | 215 | Sets the assistant of the contact to \a str. |
216 | */ | 216 | */ |
217 | 217 | ||
218 | /*! \fn void OContact::setManager( const QString &str ) | 218 | /*! \fn void OContact::setManager( const QString &str ) |
219 | Sets the manager of the contact to \a str. | 219 | Sets the manager of the contact to \a str. |
220 | */ | 220 | */ |
221 | 221 | ||
222 | /*! \fn void OContact::setSpouse( const QString &str ) | 222 | /*! \fn void OContact::setSpouse( const QString &str ) |
223 | Sets the spouse of the contact to \a str. | 223 | Sets the spouse of the contact to \a str. |
224 | */ | 224 | */ |
225 | 225 | ||
226 | /*! \fn void OContact::setGender( const QString &str ) | 226 | /*! \fn void OContact::setGender( const QString &str ) |
227 | Sets the gender of the contact to \a str. | 227 | Sets the gender of the contact to \a str. |
228 | */ | 228 | */ |
229 | 229 | ||
230 | /*! \fn void OContact::setNickname( const QString &str ) | 230 | /*! \fn void OContact::setNickname( const QString &str ) |
231 | Sets the nickname of the contact to \a str. | 231 | Sets the nickname of the contact to \a str. |
232 | */ | 232 | */ |
233 | 233 | ||
234 | /*! \fn void OContact::setNotes( const QString &str ) | 234 | /*! \fn void OContact::setNotes( const QString &str ) |
235 | Sets the notes about the contact to \a str. | 235 | Sets the notes about the contact to \a str. |
236 | */ | 236 | */ |
237 | 237 | ||
238 | /*! \fn QString OContact::title() const | 238 | /*! \fn QString OContact::title() const |
239 | Returns the title of the contact. | 239 | Returns the title of the contact. |
240 | */ | 240 | */ |
241 | 241 | ||
242 | /*! \fn QString OContact::firstName() const | 242 | /*! \fn QString OContact::firstName() const |
243 | Returns the first name of the contact. | 243 | Returns the first name of the contact. |
244 | */ | 244 | */ |
245 | 245 | ||
246 | /*! \fn QString OContact::middleName() const | 246 | /*! \fn QString OContact::middleName() const |
247 | Returns the middle name of the contact. | 247 | Returns the middle name of the contact. |
248 | */ | 248 | */ |
249 | 249 | ||
250 | /*! \fn QString OContact::lastName() const | 250 | /*! \fn QString OContact::lastName() const |
251 | Returns the last name of the contact. | 251 | Returns the last name of the contact. |
252 | */ | 252 | */ |
253 | 253 | ||
254 | /*! \fn QString OContact::suffix() const | 254 | /*! \fn QString OContact::suffix() const |
255 | Returns the suffix of the contact. | 255 | Returns the suffix of the contact. |
256 | */ | 256 | */ |
257 | 257 | ||
258 | /*! \fn QString OContact::fileAs() const | 258 | /*! \fn QString OContact::fileAs() const |
259 | Returns the string the contact is filed as. | 259 | Returns the string the contact is filed as. |
260 | */ | 260 | */ |
261 | 261 | ||
262 | /*! \fn QString OContact::defaultEmail() const | 262 | /*! \fn QString OContact::defaultEmail() const |
263 | Returns the default email address of the contact. | 263 | Returns the default email address of the contact. |
264 | */ | 264 | */ |
265 | 265 | ||
266 | /*! \fn QString OContact::emails() const | 266 | /*! \fn QString OContact::emails() const |
267 | Returns the list of email address for a contact separated by ';'s in a single | 267 | Returns the list of email address for a contact separated by ';'s in a single |
268 | string. | 268 | string. |
269 | */ | 269 | */ |
270 | 270 | ||
271 | /*! \fn QString OContact::homeStreet() const | 271 | /*! \fn QString OContact::homeStreet() const |
272 | Returns the home street address of the contact. | 272 | Returns the home street address of the contact. |
273 | */ | 273 | */ |
274 | 274 | ||
275 | /*! \fn QString OContact::homeCity() const | 275 | /*! \fn QString OContact::homeCity() const |
276 | Returns the home city of the contact. | 276 | Returns the home city of the contact. |
277 | */ | 277 | */ |
278 | 278 | ||
279 | /*! \fn QString OContact::homeState() const | 279 | /*! \fn QString OContact::homeState() const |
280 | Returns the home state of the contact. | 280 | Returns the home state of the contact. |
281 | */ | 281 | */ |
282 | 282 | ||
283 | /*! \fn QString OContact::homeZip() const | 283 | /*! \fn QString OContact::homeZip() const |
284 | Returns the home zip of the contact. | 284 | Returns the home zip of the contact. |
285 | */ | 285 | */ |
286 | 286 | ||
287 | /*! \fn QString OContact::homeCountry() const | 287 | /*! \fn QString OContact::homeCountry() const |
288 | Returns the home country of the contact. | 288 | Returns the home country of the contact. |
289 | */ | 289 | */ |
290 | 290 | ||
291 | /*! \fn QString OContact::homePhone() const | 291 | /*! \fn QString OContact::homePhone() const |
292 | Returns the home phone number of the contact. | 292 | Returns the home phone number of the contact. |
293 | */ | 293 | */ |
294 | 294 | ||
295 | /*! \fn QString OContact::homeFax() const | 295 | /*! \fn QString OContact::homeFax() const |
296 | Returns the home fax number of the contact. | 296 | Returns the home fax number of the contact. |
297 | */ | 297 | */ |
298 | 298 | ||
299 | /*! \fn QString OContact::homeMobile() const | 299 | /*! \fn QString OContact::homeMobile() const |
300 | Returns the home mobile number of the contact. | 300 | Returns the home mobile number of the contact. |
301 | */ | 301 | */ |
302 | 302 | ||
303 | /*! \fn QString OContact::homeWebpage() const | 303 | /*! \fn QString OContact::homeWebpage() const |
304 | Returns the home webpage of the contact. | 304 | Returns the home webpage of the contact. |
305 | */ | 305 | */ |
306 | 306 | ||
307 | /*! \fn QString OContact::company() const | 307 | /*! \fn QString OContact::company() const |
308 | Returns the company for the contact. | 308 | Returns the company for the contact. |
309 | */ | 309 | */ |
310 | 310 | ||
311 | /*! \fn QString OContact::department() const | 311 | /*! \fn QString OContact::department() const |
312 | Returns the department for the contact. | 312 | Returns the department for the contact. |
313 | */ | 313 | */ |
314 | 314 | ||
315 | /*! \fn QString OContact::office() const | 315 | /*! \fn QString OContact::office() const |
316 | Returns the office for the contact. | 316 | Returns the office for the contact. |
317 | */ | 317 | */ |
318 | 318 | ||
319 | /*! \fn QString OContact::jobTitle() const | 319 | /*! \fn QString OContact::jobTitle() const |
320 | Returns the job title of the contact. | 320 | Returns the job title of the contact. |
321 | */ | 321 | */ |
322 | 322 | ||
323 | /*! \fn QString OContact::profession() const | 323 | /*! \fn QString OContact::profession() const |
324 | Returns the profession of the contact. | 324 | Returns the profession of the contact. |
325 | */ | 325 | */ |
326 | 326 | ||
327 | /*! \fn QString OContact::assistant() const | 327 | /*! \fn QString OContact::assistant() const |
328 | Returns the assistant of the contact. | 328 | Returns the assistant of the contact. |
329 | */ | 329 | */ |
330 | 330 | ||
331 | /*! \fn QString OContact::manager() const | 331 | /*! \fn QString OContact::manager() const |
332 | Returns the manager of the contact. | 332 | Returns the manager of the contact. |
333 | */ | 333 | */ |
334 | 334 | ||
335 | /*! \fn QString OContact::businessStreet() const | 335 | /*! \fn QString OContact::businessStreet() const |
336 | Returns the business street address of the contact. | 336 | Returns the business street address of the contact. |
337 | */ | 337 | */ |
338 | 338 | ||
339 | /*! \fn QString OContact::businessCity() const | 339 | /*! \fn QString OContact::businessCity() const |
340 | Returns the business city of the contact. | 340 | Returns the business city of the contact. |
341 | */ | 341 | */ |
342 | 342 | ||
343 | /*! \fn QString OContact::businessState() const | 343 | /*! \fn QString OContact::businessState() const |
344 | Returns the business state of the contact. | 344 | Returns the business state of the contact. |
345 | */ | 345 | */ |
346 | 346 | ||
347 | /*! \fn QString OContact::businessZip() const | 347 | /*! \fn QString OContact::businessZip() const |
348 | Returns the business zip of the contact. | 348 | Returns the business zip of the contact. |
349 | */ | 349 | */ |
350 | 350 | ||
351 | /*! \fn QString OContact::businessCountry() const | 351 | /*! \fn QString OContact::businessCountry() const |
352 | Returns the business country of the contact. | 352 | Returns the business country of the contact. |
353 | */ | 353 | */ |
354 | 354 | ||
355 | /*! \fn QString OContact::businessPhone() const | 355 | /*! \fn QString OContact::businessPhone() const |
356 | Returns the business phone number of the contact. | 356 | Returns the business phone number of the contact. |
357 | */ | 357 | */ |
358 | 358 | ||
359 | /*! \fn QString OContact::businessFax() const | 359 | /*! \fn QString OContact::businessFax() const |
360 | Returns the business fax number of the contact. | 360 | Returns the business fax number of the contact. |
361 | */ | 361 | */ |
362 | 362 | ||
363 | /*! \fn QString OContact::businessMobile() const | 363 | /*! \fn QString OContact::businessMobile() const |
364 | Returns the business mobile number of the contact. | 364 | Returns the business mobile number of the contact. |
365 | */ | 365 | */ |
366 | 366 | ||
367 | /*! \fn QString OContact::businessPager() const | 367 | /*! \fn QString OContact::businessPager() const |
368 | Returns the business pager number of the contact. | 368 | Returns the business pager number of the contact. |
369 | */ | 369 | */ |
370 | 370 | ||
371 | /*! \fn QString OContact::businessWebpage() const | 371 | /*! \fn QString OContact::businessWebpage() const |
372 | Returns the business webpage of the contact. | 372 | Returns the business webpage of the contact. |
373 | */ | 373 | */ |
374 | 374 | ||
375 | /*! \fn QString OContact::spouse() const | 375 | /*! \fn QString OContact::spouse() const |
376 | Returns the spouse of the contact. | 376 | Returns the spouse of the contact. |
377 | */ | 377 | */ |
378 | 378 | ||
379 | /*! \fn QString OContact::gender() const | 379 | /*! \fn QString OContact::gender() const |
380 | Returns the gender of the contact. | 380 | Returns the gender of the contact. |
381 | */ | 381 | */ |
382 | 382 | ||
383 | /*! \fn QString OContact::nickname() const | 383 | /*! \fn QString OContact::nickname() const |
384 | Returns the nickname of the contact. | 384 | Returns the nickname of the contact. |
385 | */ | 385 | */ |
386 | 386 | ||
387 | /*! \fn QString OContact::children() const | 387 | /*! \fn QString OContact::children() const |
388 | Returns the children of the contact. | 388 | Returns the children of the contact. |
389 | */ | 389 | */ |
390 | 390 | ||
391 | /*! \fn QString OContact::notes() const | 391 | /*! \fn QString OContact::notes() const |
392 | Returns the notes relating to the the contact. | 392 | Returns the notes relating to the the contact. |
393 | */ | 393 | */ |
394 | 394 | ||
395 | /*! \fn QString OContact::groups() const | 395 | /*! \fn QString OContact::groups() const |
396 | \internal | 396 | \internal |
397 | Returns the groups for the contact. | 397 | Returns the groups for the contact. |
398 | */ | 398 | */ |
399 | 399 | ||
400 | /*! \fn QStringList OContact::groupList() const | 400 | /*! \fn QStringList OContact::groupList() const |
401 | \internal | 401 | \internal |
402 | */ | 402 | */ |
403 | 403 | ||
404 | /*! \fn QString OContact::field(int) const | 404 | /*! \fn QString OContact::field(int) const |
405 | \internal | 405 | \internal |
406 | */ | 406 | */ |
407 | 407 | ||
408 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 408 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
409 | \internal | 409 | \internal |
410 | */ | 410 | */ |
411 | 411 | ||
412 | /*! \fn void OContact::setUid( int id ) | 412 | /*! \fn void OContact::setUid( int id ) |
413 | \internal | 413 | \internal |
414 | Sets the uid for this record to \a id. | 414 | Sets the uid for this record to \a id. |
415 | */ | 415 | */ |
416 | 416 | ||
417 | /*! \enum OContact::journal_action | 417 | /*! \enum OContact::journal_action |
418 | \internal | 418 | \internal |
419 | */ | 419 | */ |
420 | 420 | ||
421 | /*! | 421 | /*! |
422 | \internal | 422 | \internal |
423 | */ | 423 | */ |
424 | QMap<int, QString> OContact::toMap() const | 424 | QMap<int, QString> OContact::toMap() const |
425 | { | 425 | { |
426 | QMap<int, QString> map = mMap; | 426 | QMap<int, QString> map = mMap; |
427 | QString cats = idsToString( categories() ); | 427 | QString cats = idsToString( categories() ); |
428 | if ( !cats.isEmpty() ) | 428 | if ( !cats.isEmpty() ) |
429 | map.insert( Qtopia::AddressCategory, cats ); | 429 | map.insert( Qtopia::AddressCategory, cats ); |
430 | return map; | 430 | return map; |
431 | } | 431 | } |
432 | 432 | ||
433 | /*! | 433 | /*! |
434 | Returns a rich text formatted QString representing the contents the contact. | 434 | Returns a rich text formatted QString representing the contents the contact. |
435 | */ | 435 | */ |
436 | QString OContact::toRichText() const | 436 | QString OContact::toRichText() const |
437 | { | 437 | { |
438 | QString text; | 438 | QString text; |
439 | QString value, comp, state; | 439 | QString value, comp, state; |
440 | 440 | ||
441 | // name, jobtitle and company | 441 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 442 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; | 443 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; |
444 | if ( !(value = jobTitle()).isEmpty() ) | 444 | if ( !(value = jobTitle()).isEmpty() ) |
445 | text += Qtopia::escapeString(value) + "<br>"; | 445 | text += Qtopia::escapeString(value) + "<br>"; |
446 | 446 | ||
447 | comp = company(); | 447 | comp = company(); |
448 | if ( !(value = department()).isEmpty() ) { | 448 | if ( !(value = department()).isEmpty() ) { |
449 | text += Qtopia::escapeString(value); | 449 | text += Qtopia::escapeString(value); |
450 | if ( comp ) | 450 | if ( comp ) |
451 | text += ", "; | 451 | text += ", "; |
452 | else | 452 | else |
453 | text += "<br>"; | 453 | text += "<br>"; |
454 | } | 454 | } |
455 | if ( !comp.isEmpty() ) | 455 | if ( !comp.isEmpty() ) |
456 | text += Qtopia::escapeString(comp) + "<br>"; | 456 | text += Qtopia::escapeString(comp) + "<br>"; |
457 | 457 | ||
458 | // business address | 458 | // business address |
459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 459 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 460 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
461 | text += "<br>"; | 461 | text += "<br>"; |
462 | text += QObject::tr( "<b>Work Address:</b>" ); | 462 | text += QObject::tr( "<b>Work Address:</b>" ); |
463 | text += "<br>"; | 463 | text += "<br>"; |
464 | } | 464 | } |
465 | 465 | ||
466 | if ( !(value = businessStreet()).isEmpty() ) | 466 | if ( !(value = businessStreet()).isEmpty() ) |
467 | text += Qtopia::escapeString(value) + "<br>"; | 467 | text += Qtopia::escapeString(value) + "<br>"; |
468 | state = businessState(); | 468 | state = businessState(); |
469 | if ( !(value = businessCity()).isEmpty() ) { | 469 | if ( !(value = businessCity()).isEmpty() ) { |
470 | text += Qtopia::escapeString(value); | 470 | text += Qtopia::escapeString(value); |
471 | if ( state ) | 471 | if ( state ) |
472 | text += ", " + Qtopia::escapeString(state); | 472 | text += ", " + Qtopia::escapeString(state); |
473 | text += "<br>"; | 473 | text += "<br>"; |
474 | } else if ( !state.isEmpty() ) | 474 | } else if ( !state.isEmpty() ) |
475 | text += Qtopia::escapeString(state) + "<br>"; | 475 | text += Qtopia::escapeString(state) + "<br>"; |
476 | if ( !(value = businessZip()).isEmpty() ) | 476 | if ( !(value = businessZip()).isEmpty() ) |
477 | text += Qtopia::escapeString(value) + "<br>"; | 477 | text += Qtopia::escapeString(value) + "<br>"; |
478 | if ( !(value = businessCountry()).isEmpty() ) | 478 | if ( !(value = businessCountry()).isEmpty() ) |
479 | text += Qtopia::escapeString(value) + "<br>"; | 479 | text += Qtopia::escapeString(value) + "<br>"; |
480 | 480 | ||
481 | // home address | 481 | // home address |
482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 482 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 483 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
484 | text += "<br>"; | 484 | text += "<br>"; |
485 | text += QObject::tr( "<b>Home Address:</b>" ); | 485 | text += QObject::tr( "<b>Home Address:</b>" ); |
486 | text += "<br>"; | 486 | text += "<br>"; |
487 | } | 487 | } |
488 | 488 | ||
489 | if ( !(value = homeStreet()).isEmpty() ) | 489 | if ( !(value = homeStreet()).isEmpty() ) |
490 | text += Qtopia::escapeString(value) + "<br>"; | 490 | text += Qtopia::escapeString(value) + "<br>"; |
491 | state = homeState(); | 491 | state = homeState(); |
492 | if ( !(value = homeCity()).isEmpty() ) { | 492 | if ( !(value = homeCity()).isEmpty() ) { |
493 | text += Qtopia::escapeString(value); | 493 | text += Qtopia::escapeString(value); |
494 | if ( !state.isEmpty() ) | 494 | if ( !state.isEmpty() ) |
495 | text += ", " + Qtopia::escapeString(state); | 495 | text += ", " + Qtopia::escapeString(state); |
496 | text += "<br>"; | 496 | text += "<br>"; |
497 | } else if (!state.isEmpty()) | 497 | } else if (!state.isEmpty()) |
498 | text += Qtopia::escapeString(state) + "<br>"; | 498 | text += Qtopia::escapeString(state) + "<br>"; |
499 | if ( !(value = homeZip()).isEmpty() ) | 499 | if ( !(value = homeZip()).isEmpty() ) |
500 | text += Qtopia::escapeString(value) + "<br>"; | 500 | text += Qtopia::escapeString(value) + "<br>"; |
501 | if ( !(value = homeCountry()).isEmpty() ) | 501 | if ( !(value = homeCountry()).isEmpty() ) |
502 | text += Qtopia::escapeString(value) + "<br>"; | 502 | text += Qtopia::escapeString(value) + "<br>"; |
503 | 503 | ||
504 | // the others... | 504 | // the others... |
505 | QString str; | 505 | QString str; |
506 | str = emails(); | 506 | str = emails(); |
507 | if ( !str.isEmpty() ) | 507 | if ( !str.isEmpty() ) |
508 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" | 508 | text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" |
509 | + Qtopia::escapeString(str) + "<br>"; | 509 | + Qtopia::escapeString(str) + "<br>"; |
510 | str = homePhone(); | 510 | str = homePhone(); |
511 | if ( !str.isEmpty() ) | 511 | if ( !str.isEmpty() ) |
512 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 512 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" |
513 | + Qtopia::escapeString(str) + "<br>"; | 513 | + Qtopia::escapeString(str) + "<br>"; |
514 | str = homeFax(); | 514 | str = homeFax(); |
515 | if ( !str.isEmpty() ) | 515 | if ( !str.isEmpty() ) |
516 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 516 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" |
517 | + Qtopia::escapeString(str) + "<br>"; | 517 | + Qtopia::escapeString(str) + "<br>"; |
518 | str = homeMobile(); | 518 | str = homeMobile(); |
519 | if ( !str.isEmpty() ) | 519 | if ( !str.isEmpty() ) |
520 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 520 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" |
521 | + Qtopia::escapeString(str) + "<br>"; | 521 | + Qtopia::escapeString(str) + "<br>"; |
522 | str = homeWebpage(); | 522 | str = homeWebpage(); |
523 | if ( !str.isEmpty() ) | 523 | if ( !str.isEmpty() ) |
524 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 524 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" |
525 | + Qtopia::escapeString(str) + "<br>"; | 525 | + Qtopia::escapeString(str) + "<br>"; |
526 | str = businessWebpage(); | 526 | str = businessWebpage(); |
527 | if ( !str.isEmpty() ) | 527 | if ( !str.isEmpty() ) |
528 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 528 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" |
529 | + Qtopia::escapeString(str) + "<br>"; | 529 | + Qtopia::escapeString(str) + "<br>"; |
530 | str = office(); | 530 | str = office(); |
531 | if ( !str.isEmpty() ) | 531 | if ( !str.isEmpty() ) |
532 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 532 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
533 | + Qtopia::escapeString(str) + "<br>"; | 533 | + Qtopia::escapeString(str) + "<br>"; |
534 | str = businessPhone(); | 534 | str = businessPhone(); |
535 | if ( !str.isEmpty() ) | 535 | if ( !str.isEmpty() ) |
536 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 536 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" |
537 | + Qtopia::escapeString(str) + "<br>"; | 537 | + Qtopia::escapeString(str) + "<br>"; |
538 | str = businessFax(); | 538 | str = businessFax(); |
539 | if ( !str.isEmpty() ) | 539 | if ( !str.isEmpty() ) |
540 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 540 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" |
541 | + Qtopia::escapeString(str) + "<br>"; | 541 | + Qtopia::escapeString(str) + "<br>"; |
542 | str = businessMobile(); | 542 | str = businessMobile(); |
543 | if ( !str.isEmpty() ) | 543 | if ( !str.isEmpty() ) |
544 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 544 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" |
545 | + Qtopia::escapeString(str) + "<br>"; | 545 | + Qtopia::escapeString(str) + "<br>"; |
546 | str = businessPager(); | 546 | str = businessPager(); |
547 | if ( !str.isEmpty() ) | 547 | if ( !str.isEmpty() ) |
548 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 548 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
549 | + Qtopia::escapeString(str) + "<br>"; | 549 | + Qtopia::escapeString(str) + "<br>"; |
550 | str = profession(); | 550 | str = profession(); |
551 | if ( !str.isEmpty() ) | 551 | if ( !str.isEmpty() ) |
552 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 552 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
553 | + Qtopia::escapeString(str) + "<br>"; | 553 | + Qtopia::escapeString(str) + "<br>"; |
554 | str = assistant(); | 554 | str = assistant(); |
555 | if ( !str.isEmpty() ) | 555 | if ( !str.isEmpty() ) |
556 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 556 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
557 | + Qtopia::escapeString(str) + "<br>"; | 557 | + Qtopia::escapeString(str) + "<br>"; |
558 | str = manager(); | 558 | str = manager(); |
559 | if ( !str.isEmpty() ) | 559 | if ( !str.isEmpty() ) |
560 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 560 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
561 | + Qtopia::escapeString(str) + "<br>"; | 561 | + Qtopia::escapeString(str) + "<br>"; |
562 | str = gender(); | 562 | str = gender(); |
563 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 563 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
564 | if ( str.toInt() == 1 ) | 564 | if ( str.toInt() == 1 ) |
565 | str = QObject::tr( "Male" ); | 565 | str = QObject::tr( "Male" ); |
566 | else if ( str.toInt() == 2 ) | 566 | else if ( str.toInt() == 2 ) |
567 | str = QObject::tr( "Female" ); | 567 | str = QObject::tr( "Female" ); |
568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
569 | } | 569 | } |
570 | str = spouse(); | 570 | str = spouse(); |
571 | if ( !str.isEmpty() ) | 571 | if ( !str.isEmpty() ) |
572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 573 | + Qtopia::escapeString(str) + "<br>"; |
574 | if ( !birthday().isNull() ){ | 574 | if ( !birthday().isValid() ){ |
575 | str = TimeString::numberDateString( birthday() ); | 575 | str = TimeString::numberDateString( birthday() ); |
576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
578 | } | 578 | } |
579 | if ( !anniversary().isNull() ){ | 579 | if ( !anniversary().isValid() ){ |
580 | str = TimeString::numberDateString( anniversary() ); | 580 | str = TimeString::numberDateString( anniversary() ); |
581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
582 | + Qtopia::escapeString(str) + "<br>"; | 582 | + Qtopia::escapeString(str) + "<br>"; |
583 | } | 583 | } |
584 | str = nickname(); | 584 | str = nickname(); |
585 | if ( !str.isEmpty() ) | 585 | if ( !str.isEmpty() ) |
586 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 586 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 587 | + Qtopia::escapeString(str) + "<br>"; |
588 | 588 | ||
589 | // notes last | 589 | // notes last |
590 | if ( (value = notes()) ) { | 590 | if ( (value = notes()) ) { |
591 | QRegExp reg("\n"); | 591 | QRegExp reg("\n"); |
592 | 592 | ||
593 | //QString tmp = Qtopia::escapeString(value); | 593 | //QString tmp = Qtopia::escapeString(value); |
594 | QString tmp = QStyleSheet::convertFromPlainText(value); | 594 | QString tmp = QStyleSheet::convertFromPlainText(value); |
595 | //tmp.replace( reg, "<br>" ); | 595 | //tmp.replace( reg, "<br>" ); |
596 | text += "<br>" + tmp + "<br>"; | 596 | text += "<br>" + tmp + "<br>"; |
597 | } | 597 | } |
598 | return text; | 598 | return text; |
599 | } | 599 | } |
600 | 600 | ||
601 | /*! | 601 | /*! |
602 | \internal | 602 | \internal |
603 | */ | 603 | */ |
604 | void OContact::insert( int key, const QString &v ) | 604 | void OContact::insert( int key, const QString &v ) |
605 | { | 605 | { |
606 | QString value = v.stripWhiteSpace(); | 606 | QString value = v.stripWhiteSpace(); |
607 | if ( value.isEmpty() ) | 607 | if ( value.isEmpty() ) |
608 | mMap.remove( key ); | 608 | mMap.remove( key ); |
609 | else | 609 | else |
610 | mMap.insert( key, value ); | 610 | mMap.insert( key, value ); |
611 | } | 611 | } |
612 | 612 | ||
613 | /*! | 613 | /*! |
614 | \internal | 614 | \internal |
615 | */ | 615 | */ |
616 | void OContact::replace( int key, const QString & v ) | 616 | void OContact::replace( int key, const QString & v ) |
617 | { | 617 | { |
618 | QString value = v.stripWhiteSpace(); | 618 | QString value = v.stripWhiteSpace(); |
619 | if ( value.isEmpty() ) | 619 | if ( value.isEmpty() ) |
620 | mMap.remove( key ); | 620 | mMap.remove( key ); |
621 | else | 621 | else |
622 | mMap.replace( key, value ); | 622 | mMap.replace( key, value ); |
623 | } | 623 | } |
624 | 624 | ||
625 | /*! | 625 | /*! |
626 | \internal | 626 | \internal |
627 | */ | 627 | */ |
628 | QString OContact::find( int key ) const | 628 | QString OContact::find( int key ) const |
629 | { | 629 | { |
630 | return mMap[key]; | 630 | return mMap[key]; |
631 | } | 631 | } |
632 | 632 | ||
633 | /*! | 633 | /*! |
634 | \internal | 634 | \internal |
635 | */ | 635 | */ |
636 | QString OContact::displayAddress( const QString &street, | 636 | QString OContact::displayAddress( const QString &street, |
637 | const QString &city, | 637 | const QString &city, |
638 | const QString &state, | 638 | const QString &state, |
639 | const QString &zip, | 639 | const QString &zip, |
640 | const QString &country ) const | 640 | const QString &country ) const |
641 | { | 641 | { |
642 | QString s = street; | 642 | QString s = street; |
643 | if ( !street.isEmpty() ) | 643 | if ( !street.isEmpty() ) |
644 | s+= "\n"; | 644 | s+= "\n"; |
645 | s += city; | 645 | s += city; |
646 | if ( !city.isEmpty() && !state.isEmpty() ) | 646 | if ( !city.isEmpty() && !state.isEmpty() ) |
647 | s += ", "; | 647 | s += ", "; |
648 | s += state; | 648 | s += state; |
649 | if ( !state.isEmpty() && !zip.isEmpty() ) | 649 | if ( !state.isEmpty() && !zip.isEmpty() ) |
650 | s += " "; | 650 | s += " "; |
651 | s += zip; | 651 | s += zip; |
652 | if ( !country.isEmpty() && !s.isEmpty() ) | 652 | if ( !country.isEmpty() && !s.isEmpty() ) |
653 | s += "\n"; | 653 | s += "\n"; |
654 | s += country; | 654 | s += country; |
655 | return s; | 655 | return s; |
656 | } | 656 | } |
657 | 657 | ||
658 | /*! | 658 | /*! |
659 | \internal | 659 | \internal |
660 | */ | 660 | */ |
661 | QString OContact::displayBusinessAddress() const | 661 | QString OContact::displayBusinessAddress() const |
662 | { | 662 | { |
663 | return displayAddress( businessStreet(), businessCity(), | 663 | return displayAddress( businessStreet(), businessCity(), |
664 | businessState(), businessZip(), | 664 | businessState(), businessZip(), |
665 | businessCountry() ); | 665 | businessCountry() ); |
666 | } | 666 | } |
667 | 667 | ||
668 | /*! | 668 | /*! |
669 | \internal | 669 | \internal |
670 | */ | 670 | */ |
671 | QString OContact::displayHomeAddress() const | 671 | QString OContact::displayHomeAddress() const |
672 | { | 672 | { |
673 | return displayAddress( homeStreet(), homeCity(), | 673 | return displayAddress( homeStreet(), homeCity(), |
674 | homeState(), homeZip(), | 674 | homeState(), homeZip(), |
675 | homeCountry() ); | 675 | homeCountry() ); |
676 | } | 676 | } |
677 | 677 | ||
678 | /*! | 678 | /*! |
679 | Returns the full name of the contact | 679 | Returns the full name of the contact |
680 | */ | 680 | */ |
681 | QString OContact::fullName() const | 681 | QString OContact::fullName() const |
682 | { | 682 | { |
683 | QString title = find( Qtopia::Title ); | 683 | QString title = find( Qtopia::Title ); |
684 | QString firstName = find( Qtopia::FirstName ); | 684 | QString firstName = find( Qtopia::FirstName ); |
685 | QString middleName = find( Qtopia::MiddleName ); | 685 | QString middleName = find( Qtopia::MiddleName ); |
686 | QString lastName = find( Qtopia::LastName ); | 686 | QString lastName = find( Qtopia::LastName ); |
687 | QString suffix = find( Qtopia::Suffix ); | 687 | QString suffix = find( Qtopia::Suffix ); |
688 | 688 | ||
689 | QString name = title; | 689 | QString name = title; |
690 | if ( !firstName.isEmpty() ) { | 690 | if ( !firstName.isEmpty() ) { |
691 | if ( !name.isEmpty() ) | 691 | if ( !name.isEmpty() ) |
692 | name += " "; | 692 | name += " "; |
693 | name += firstName; | 693 | name += firstName; |
694 | } | 694 | } |
695 | if ( !middleName.isEmpty() ) { | 695 | if ( !middleName.isEmpty() ) { |
696 | if ( !name.isEmpty() ) | 696 | if ( !name.isEmpty() ) |
697 | name += " "; | 697 | name += " "; |
698 | name += middleName; | 698 | name += middleName; |
699 | } | 699 | } |
700 | if ( !lastName.isEmpty() ) { | 700 | if ( !lastName.isEmpty() ) { |
701 | if ( !name.isEmpty() ) | 701 | if ( !name.isEmpty() ) |
702 | name += " "; | 702 | name += " "; |
703 | name += lastName; | 703 | name += lastName; |
704 | } | 704 | } |
705 | if ( !suffix.isEmpty() ) { | 705 | if ( !suffix.isEmpty() ) { |
706 | if ( !name.isEmpty() ) | 706 | if ( !name.isEmpty() ) |
707 | name += " "; | 707 | name += " "; |
708 | name += suffix; | 708 | name += suffix; |
709 | } | 709 | } |
710 | return name.simplifyWhiteSpace(); | 710 | return name.simplifyWhiteSpace(); |
711 | } | 711 | } |
712 | 712 | ||
713 | /*! | 713 | /*! |
714 | Returns a list of the names of the children of the contact. | 714 | Returns a list of the names of the children of the contact. |
715 | */ | 715 | */ |
716 | QStringList OContact::childrenList() const | 716 | QStringList OContact::childrenList() const |
717 | { | 717 | { |
718 | return QStringList::split( " ", find( Qtopia::Children ) ); | 718 | return QStringList::split( " ", find( Qtopia::Children ) ); |
719 | } | 719 | } |
720 | 720 | ||
721 | /*! \fn void OContact::insertEmail( const QString &email ) | 721 | /*! \fn void OContact::insertEmail( const QString &email ) |
722 | 722 | ||
723 | Insert \a email into the email list. Ensures \a email can only be added | 723 | Insert \a email into the email list. Ensures \a email can only be added |
724 | once. If there is no default email address set, it sets it to the \a email. | 724 | once. If there is no default email address set, it sets it to the \a email. |
725 | */ | 725 | */ |
726 | 726 | ||
727 | /*! \fn void OContact::removeEmail( const QString &email ) | 727 | /*! \fn void OContact::removeEmail( const QString &email ) |
728 | 728 | ||
729 | Removes the \a email from the email list. If the default email was \a email, | 729 | Removes the \a email from the email list. If the default email was \a email, |
730 | then the default email address is assigned to the first email in the | 730 | then the default email address is assigned to the first email in the |
731 | email list | 731 | email list |
732 | */ | 732 | */ |
733 | 733 | ||
734 | /*! \fn void OContact::clearEmails() | 734 | /*! \fn void OContact::clearEmails() |
735 | 735 | ||
736 | Clears the email list. | 736 | Clears the email list. |
737 | */ | 737 | */ |
738 | 738 | ||
739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
740 | 740 | ||
741 | Appends the \a emailList to the exiting email list | 741 | Appends the \a emailList to the exiting email list |
742 | */ | 742 | */ |
743 | 743 | ||
744 | /*! | 744 | /*! |
745 | Returns a list of email addresses belonging to the contact, including | 745 | Returns a list of email addresses belonging to the contact, including |
746 | the default email address. | 746 | the default email address. |
747 | */ | 747 | */ |
748 | QStringList OContact::emailList() const | 748 | QStringList OContact::emailList() const |
749 | { | 749 | { |
750 | QString emailStr = emails(); | 750 | QString emailStr = emails(); |
751 | 751 | ||
752 | QStringList r; | 752 | QStringList r; |
753 | if ( !emailStr.isEmpty() ) { | 753 | if ( !emailStr.isEmpty() ) { |
754 | qDebug(" emailstr "); | 754 | qDebug(" emailstr "); |
755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
757 | r += (*it).simplifyWhiteSpace(); | 757 | r += (*it).simplifyWhiteSpace(); |
758 | } | 758 | } |
759 | 759 | ||
760 | return r; | 760 | return r; |
761 | } | 761 | } |
762 | 762 | ||
763 | /*! | 763 | /*! |
764 | \overload | 764 | \overload |
765 | 765 | ||
766 | Generates the string for the contact to be filed as from the first, | 766 | Generates the string for the contact to be filed as from the first, |
767 | middle and last name of the contact. | 767 | middle and last name of the contact. |
768 | */ | 768 | */ |
769 | void OContact::setFileAs() | 769 | void OContact::setFileAs() |
770 | { | 770 | { |
771 | QString lastName, firstName, middleName, fileas; | 771 | QString lastName, firstName, middleName, fileas; |
772 | 772 | ||
773 | lastName = find( Qtopia::LastName ); | 773 | lastName = find( Qtopia::LastName ); |
774 | firstName = find( Qtopia::FirstName ); | 774 | firstName = find( Qtopia::FirstName ); |
775 | middleName = find( Qtopia::MiddleName ); | 775 | middleName = find( Qtopia::MiddleName ); |
776 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 776 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
777 | && !middleName.isEmpty() ) | 777 | && !middleName.isEmpty() ) |
778 | fileas = lastName + ", " + firstName + " " + middleName; | 778 | fileas = lastName + ", " + firstName + " " + middleName; |
779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
780 | fileas = lastName + ", " + firstName; | 780 | fileas = lastName + ", " + firstName; |
781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
782 | !middleName.isEmpty() ) | 782 | !middleName.isEmpty() ) |
783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
784 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 784 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
785 | + lastName; | 785 | + lastName; |
786 | 786 | ||
787 | replace( Qtopia::FileAs, fileas ); | 787 | replace( Qtopia::FileAs, fileas ); |
788 | } | 788 | } |
789 | 789 | ||
790 | /*! | 790 | /*! |
791 | \internal | 791 | \internal |
792 | Appends the contact information to \a buf. | 792 | Appends the contact information to \a buf. |
793 | */ | 793 | */ |
794 | void OContact::save( QString &buf ) const | 794 | void OContact::save( QString &buf ) const |
795 | { | 795 | { |
796 | static const QStringList SLFIELDS = fields(); | 796 | static const QStringList SLFIELDS = fields(); |
797 | // I'm expecting "<Contact " in front of this... | 797 | // I'm expecting "<Contact " in front of this... |
798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
799 | it != mMap.end(); ++it ) { | 799 | it != mMap.end(); ++it ) { |
800 | const QString &value = it.data(); | 800 | const QString &value = it.data(); |
801 | int key = it.key(); | 801 | int key = it.key(); |
802 | if ( !value.isEmpty() ) { | 802 | if ( !value.isEmpty() ) { |
803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
804 | continue; | 804 | continue; |
805 | 805 | ||
806 | key -= Qtopia::AddressCategory+1; | 806 | key -= Qtopia::AddressCategory+1; |
807 | buf += SLFIELDS[key]; | 807 | buf += SLFIELDS[key]; |
808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
809 | } | 809 | } |
810 | } | 810 | } |
811 | buf += customToXml(); | 811 | buf += customToXml(); |
812 | if ( categories().count() > 0 ) | 812 | if ( categories().count() > 0 ) |
813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
815 | // You need to close this yourself | 815 | // You need to close this yourself |
816 | } | 816 | } |
817 | 817 | ||
818 | /*! | 818 | /*! |
819 | \internal | 819 | \internal |
820 | Returns the list of fields belonging to a contact | 820 | Returns the list of fields belonging to a contact |
821 | */ | 821 | */ |
822 | QStringList OContact::fields() | 822 | QStringList OContact::fields() |
823 | { | 823 | { |
824 | QStringList list; | 824 | QStringList list; |
825 | 825 | ||
826 | list.append( "Title" ); // Not Used! | 826 | list.append( "Title" ); // Not Used! |
827 | list.append( "FirstName" ); | 827 | list.append( "FirstName" ); |
828 | list.append( "MiddleName" ); | 828 | list.append( "MiddleName" ); |
829 | list.append( "LastName" ); | 829 | list.append( "LastName" ); |
830 | list.append( "Suffix" ); | 830 | list.append( "Suffix" ); |
831 | list.append( "FileAs" ); | 831 | list.append( "FileAs" ); |
832 | 832 | ||
833 | list.append( "JobTitle" ); | 833 | list.append( "JobTitle" ); |
834 | list.append( "Department" ); | 834 | list.append( "Department" ); |
835 | list.append( "Company" ); | 835 | list.append( "Company" ); |
836 | list.append( "BusinessPhone" ); | 836 | list.append( "BusinessPhone" ); |
837 | list.append( "BusinessFax" ); | 837 | list.append( "BusinessFax" ); |
838 | list.append( "BusinessMobile" ); | 838 | list.append( "BusinessMobile" ); |
839 | 839 | ||
840 | list.append( "DefaultEmail" ); | 840 | list.append( "DefaultEmail" ); |
841 | list.append( "Emails" ); | 841 | list.append( "Emails" ); |
842 | 842 | ||
843 | list.append( "HomePhone" ); | 843 | list.append( "HomePhone" ); |
844 | list.append( "HomeFax" ); | 844 | list.append( "HomeFax" ); |
845 | list.append( "HomeMobile" ); | 845 | list.append( "HomeMobile" ); |
846 | 846 | ||
847 | list.append( "BusinessStreet" ); | 847 | list.append( "BusinessStreet" ); |
848 | list.append( "BusinessCity" ); | 848 | list.append( "BusinessCity" ); |
849 | list.append( "BusinessState" ); | 849 | list.append( "BusinessState" ); |
850 | list.append( "BusinessZip" ); | 850 | list.append( "BusinessZip" ); |
851 | list.append( "BusinessCountry" ); | 851 | list.append( "BusinessCountry" ); |
852 | list.append( "BusinessPager" ); | 852 | list.append( "BusinessPager" ); |
853 | list.append( "BusinessWebPage" ); | 853 | list.append( "BusinessWebPage" ); |
854 | 854 | ||
855 | list.append( "Office" ); | 855 | list.append( "Office" ); |
856 | list.append( "Profession" ); | 856 | list.append( "Profession" ); |
857 | list.append( "Assistant" ); | 857 | list.append( "Assistant" ); |
858 | list.append( "Manager" ); | 858 | list.append( "Manager" ); |
859 | 859 | ||
860 | list.append( "HomeStreet" ); | 860 | list.append( "HomeStreet" ); |
861 | list.append( "HomeCity" ); | 861 | list.append( "HomeCity" ); |
862 | list.append( "HomeState" ); | 862 | list.append( "HomeState" ); |
863 | list.append( "HomeZip" ); | 863 | list.append( "HomeZip" ); |
864 | list.append( "HomeCountry" ); | 864 | list.append( "HomeCountry" ); |
865 | list.append( "HomeWebPage" ); | 865 | list.append( "HomeWebPage" ); |
866 | 866 | ||
867 | list.append( "Spouse" ); | 867 | list.append( "Spouse" ); |
868 | list.append( "Gender" ); | 868 | list.append( "Gender" ); |
869 | list.append( "Birthday" ); | 869 | list.append( "Birthday" ); |
870 | list.append( "Anniversary" ); | 870 | list.append( "Anniversary" ); |
871 | list.append( "Nickname" ); | 871 | list.append( "Nickname" ); |
872 | list.append( "Children" ); | 872 | list.append( "Children" ); |
873 | 873 | ||
874 | list.append( "Notes" ); | 874 | list.append( "Notes" ); |
875 | list.append( "Groups" ); | 875 | list.append( "Groups" ); |
876 | 876 | ||
877 | return list; | 877 | return list; |
878 | } | 878 | } |
879 | 879 | ||
880 | /*! | 880 | /*! |
881 | \internal | 881 | \internal |
882 | Returns a translated list of field names for a contact. | 882 | Returns a translated list of field names for a contact. |
883 | */ | 883 | */ |
884 | QStringList OContact::trfields() | 884 | QStringList OContact::trfields() |
885 | { | 885 | { |
886 | QStringList list; | 886 | QStringList list; |
887 | 887 | ||
888 | list.append( QObject::tr( "Name Title") ); | 888 | list.append( QObject::tr( "Name Title") ); |
889 | list.append( QObject::tr( "First Name" ) ); | 889 | list.append( QObject::tr( "First Name" ) ); |
890 | list.append( QObject::tr( "Middle Name" ) ); | 890 | list.append( QObject::tr( "Middle Name" ) ); |
891 | list.append( QObject::tr( "Last Name" ) ); | 891 | list.append( QObject::tr( "Last Name" ) ); |
892 | list.append( QObject::tr( "Suffix" ) ); | 892 | list.append( QObject::tr( "Suffix" ) ); |
893 | list.append( QObject::tr( "File As" ) ); | 893 | list.append( QObject::tr( "File As" ) ); |
894 | 894 | ||
895 | list.append( QObject::tr( "Job Title" ) ); | 895 | list.append( QObject::tr( "Job Title" ) ); |
896 | list.append( QObject::tr( "Department" ) ); | 896 | list.append( QObject::tr( "Department" ) ); |
897 | list.append( QObject::tr( "Company" ) ); | 897 | list.append( QObject::tr( "Company" ) ); |
898 | list.append( QObject::tr( "Business Phone" ) ); | 898 | list.append( QObject::tr( "Business Phone" ) ); |
899 | list.append( QObject::tr( "Business Fax" ) ); | 899 | list.append( QObject::tr( "Business Fax" ) ); |
900 | list.append( QObject::tr( "Business Mobile" ) ); | 900 | list.append( QObject::tr( "Business Mobile" ) ); |
901 | 901 | ||
902 | list.append( QObject::tr( "Default Email" ) ); | 902 | list.append( QObject::tr( "Default Email" ) ); |
903 | list.append( QObject::tr( "Emails" ) ); | 903 | list.append( QObject::tr( "Emails" ) ); |
904 | 904 | ||
905 | list.append( QObject::tr( "Home Phone" ) ); | 905 | list.append( QObject::tr( "Home Phone" ) ); |
906 | list.append( QObject::tr( "Home Fax" ) ); | 906 | list.append( QObject::tr( "Home Fax" ) ); |
907 | list.append( QObject::tr( "Home Mobile" ) ); | 907 | list.append( QObject::tr( "Home Mobile" ) ); |
908 | 908 | ||
909 | list.append( QObject::tr( "Business Street" ) ); | 909 | list.append( QObject::tr( "Business Street" ) ); |
910 | list.append( QObject::tr( "Business City" ) ); | 910 | list.append( QObject::tr( "Business City" ) ); |
911 | list.append( QObject::tr( "Business State" ) ); | 911 | list.append( QObject::tr( "Business State" ) ); |
912 | list.append( QObject::tr( "Business Zip" ) ); | 912 | list.append( QObject::tr( "Business Zip" ) ); |
913 | list.append( QObject::tr( "Business Country" ) ); | 913 | list.append( QObject::tr( "Business Country" ) ); |
914 | list.append( QObject::tr( "Business Pager" ) ); | 914 | list.append( QObject::tr( "Business Pager" ) ); |
915 | list.append( QObject::tr( "Business WebPage" ) ); | 915 | list.append( QObject::tr( "Business WebPage" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Office" ) ); | 917 | list.append( QObject::tr( "Office" ) ); |
918 | list.append( QObject::tr( "Profession" ) ); | 918 | list.append( QObject::tr( "Profession" ) ); |
919 | list.append( QObject::tr( "Assistant" ) ); | 919 | list.append( QObject::tr( "Assistant" ) ); |
920 | list.append( QObject::tr( "Manager" ) ); | 920 | list.append( QObject::tr( "Manager" ) ); |
921 | 921 | ||
922 | list.append( QObject::tr( "Home Street" ) ); | 922 | list.append( QObject::tr( "Home Street" ) ); |
923 | list.append( QObject::tr( "Home City" ) ); | 923 | list.append( QObject::tr( "Home City" ) ); |
924 | list.append( QObject::tr( "Home State" ) ); | 924 | list.append( QObject::tr( "Home State" ) ); |
925 | list.append( QObject::tr( "Home Zip" ) ); | 925 | list.append( QObject::tr( "Home Zip" ) ); |
926 | list.append( QObject::tr( "Home Country" ) ); | 926 | list.append( QObject::tr( "Home Country" ) ); |
927 | list.append( QObject::tr( "Home Web Page" ) ); | 927 | list.append( QObject::tr( "Home Web Page" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Spouse" ) ); | 929 | list.append( QObject::tr( "Spouse" ) ); |
930 | list.append( QObject::tr( "Gender" ) ); | 930 | list.append( QObject::tr( "Gender" ) ); |
931 | list.append( QObject::tr( "Birthday" ) ); | 931 | list.append( QObject::tr( "Birthday" ) ); |
932 | list.append( QObject::tr( "Anniversary" ) ); | 932 | list.append( QObject::tr( "Anniversary" ) ); |
933 | list.append( QObject::tr( "Nickname" ) ); | 933 | list.append( QObject::tr( "Nickname" ) ); |
934 | list.append( QObject::tr( "Children" ) ); | 934 | list.append( QObject::tr( "Children" ) ); |
935 | 935 | ||
936 | list.append( QObject::tr( "Notes" ) ); | 936 | list.append( QObject::tr( "Notes" ) ); |
937 | list.append( QObject::tr( "Groups" ) ); | 937 | list.append( QObject::tr( "Groups" ) ); |
938 | 938 | ||
939 | return list; | 939 | return list; |
940 | } | 940 | } |
941 | 941 | ||
942 | /*! | 942 | /*! |
943 | \internal | 943 | \internal |
944 | Returns an untranslated list of field names for a contact. | 944 | Returns an untranslated list of field names for a contact. |
945 | */ | 945 | */ |
946 | QStringList OContact::untrfields() | 946 | QStringList OContact::untrfields() |
947 | { | 947 | { |
948 | QStringList list; | 948 | QStringList list; |
949 | 949 | ||
950 | list.append( "Name Title" ); | 950 | list.append( "Name Title" ); |
951 | list.append( "First Name" ); | 951 | list.append( "First Name" ); |
952 | list.append( "Middle Name" ); | 952 | list.append( "Middle Name" ); |
953 | list.append( "Last Name" ); | 953 | list.append( "Last Name" ); |
954 | list.append( "Suffix" ); | 954 | list.append( "Suffix" ); |
955 | list.append( "File As" ); | 955 | list.append( "File As" ); |
956 | 956 | ||
957 | list.append( "Job Title" ); | 957 | list.append( "Job Title" ); |
958 | list.append( "Department" ); | 958 | list.append( "Department" ); |
959 | list.append( "Company" ); | 959 | list.append( "Company" ); |
960 | list.append( "Business Phone" ); | 960 | list.append( "Business Phone" ); |
961 | list.append( "Business Fax" ); | 961 | list.append( "Business Fax" ); |
962 | list.append( "Business Mobile" ); | 962 | list.append( "Business Mobile" ); |
963 | 963 | ||
964 | list.append( "Default Email" ); | 964 | list.append( "Default Email" ); |
965 | list.append( "Emails" ); | 965 | list.append( "Emails" ); |
966 | 966 | ||
967 | list.append( "Home Phone" ); | 967 | list.append( "Home Phone" ); |
968 | list.append( "Home Fax" ); | 968 | list.append( "Home Fax" ); |
969 | list.append( "Home Mobile" ); | 969 | list.append( "Home Mobile" ); |
970 | 970 | ||
971 | list.append( "Business Street" ); | 971 | list.append( "Business Street" ); |
972 | list.append( "Business City" ); | 972 | list.append( "Business City" ); |
973 | list.append( "Business State" ); | 973 | list.append( "Business State" ); |
974 | list.append( "Business Zip" ); | 974 | list.append( "Business Zip" ); |
975 | list.append( "Business Country" ); | 975 | list.append( "Business Country" ); |
976 | list.append( "Business Pager" ); | 976 | list.append( "Business Pager" ); |
977 | list.append( "Business WebPage" ); | 977 | list.append( "Business WebPage" ); |
978 | 978 | ||
979 | list.append( "Office" ); | 979 | list.append( "Office" ); |
980 | list.append( "Profession" ); | 980 | list.append( "Profession" ); |
981 | list.append( "Assistant" ); | 981 | list.append( "Assistant" ); |
982 | list.append( "Manager" ); | 982 | list.append( "Manager" ); |
983 | 983 | ||
984 | list.append( "Home Street" ); | 984 | list.append( "Home Street" ); |
985 | list.append( "Home City" ); | 985 | list.append( "Home City" ); |
986 | list.append( "Home State" ); | 986 | list.append( "Home State" ); |
987 | list.append( "Home Zip" ); | 987 | list.append( "Home Zip" ); |
988 | list.append( "Home Country" ); | 988 | list.append( "Home Country" ); |
989 | list.append( "Home Web Page" ); | 989 | list.append( "Home Web Page" ); |
990 | 990 | ||
991 | list.append( "Spouse" ); | 991 | list.append( "Spouse" ); |
992 | list.append( "Gender" ); | 992 | list.append( "Gender" ); |
993 | list.append( "Birthday" ); | 993 | list.append( "Birthday" ); |
994 | list.append( "Anniversary" ); | 994 | list.append( "Anniversary" ); |
995 | list.append( "Nickname" ); | 995 | list.append( "Nickname" ); |
996 | list.append( "Children" ); | 996 | list.append( "Children" ); |
997 | 997 | ||
998 | list.append( "Notes" ); | 998 | list.append( "Notes" ); |
999 | list.append( "Groups" ); | 999 | list.append( "Groups" ); |
1000 | 1000 | ||
1001 | return list; | 1001 | return list; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /*! | 1004 | /*! |
1005 | Sets the list of email address for contact to those contained in \a str. | 1005 | Sets the list of email address for contact to those contained in \a str. |
1006 | Email address should be separated by ';'s. | 1006 | Email address should be separated by ';'s. |
1007 | */ | 1007 | */ |
1008 | void OContact::setEmails( const QString &str ) | 1008 | void OContact::setEmails( const QString &str ) |
1009 | { | 1009 | { |
1010 | replace( Qtopia::Emails, str ); | 1010 | replace( Qtopia::Emails, str ); |
1011 | if ( str.isEmpty() ) | 1011 | if ( str.isEmpty() ) |
1012 | setDefaultEmail( QString::null ); | 1012 | setDefaultEmail( QString::null ); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | /*! | 1015 | /*! |
1016 | Sets the list of children for the contact to those contained in \a str. | 1016 | Sets the list of children for the contact to those contained in \a str. |
1017 | */ | 1017 | */ |
1018 | void OContact::setChildren( const QString &str ) | 1018 | void OContact::setChildren( const QString &str ) |
1019 | { | 1019 | { |
1020 | replace( Qtopia::Children, str ); | 1020 | replace( Qtopia::Children, str ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | // vcard conversion code | 1023 | // vcard conversion code |
1024 | /*! | 1024 | /*! |
1025 | \internal | 1025 | \internal |
1026 | */ | 1026 | */ |
1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
1028 | { | 1028 | { |
1029 | VObject *ret = 0; | 1029 | VObject *ret = 0; |
1030 | if ( o && !value.isEmpty() ) | 1030 | if ( o && !value.isEmpty() ) |
1031 | ret = addPropValue( o, prop, value.latin1() ); | 1031 | ret = addPropValue( o, prop, value.latin1() ); |
1032 | return ret; | 1032 | return ret; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /*! | 1035 | /*! |
1036 | \internal | 1036 | \internal |
1037 | */ | 1037 | */ |
1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
1039 | { | 1039 | { |
1040 | VObject *ret = 0; | 1040 | VObject *ret = 0; |
1041 | if ( o ) | 1041 | if ( o ) |
1042 | ret = addProp( o, prop ); | 1042 | ret = addProp( o, prop ); |
1043 | return ret; | 1043 | return ret; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | /*! | 1046 | /*! |
1047 | \internal | 1047 | \internal |
1048 | */ | 1048 | */ |
1049 | static VObject *createVObject( const OContact &c ) | 1049 | static VObject *createVObject( const OContact &c ) |
1050 | { | 1050 | { |
1051 | VObject *vcard = newVObject( VCCardProp ); | 1051 | VObject *vcard = newVObject( VCCardProp ); |
1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1055 | 1055 | ||
1056 | // full name | 1056 | // full name |
1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1058 | 1058 | ||
1059 | // name properties | 1059 | // name properties |
1060 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1060 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1066 | 1066 | ||
1067 | // home properties | 1067 | // home properties |
1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1069 | safeAddProp( home_adr, VCHomeProp ); | 1069 | safeAddProp( home_adr, VCHomeProp ); |
1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1075 | 1075 | ||
1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1077 | safeAddProp( home_phone, VCHomeProp ); | 1077 | safeAddProp( home_phone, VCHomeProp ); |
1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1079 | safeAddProp( home_phone, VCHomeProp ); | 1079 | safeAddProp( home_phone, VCHomeProp ); |
1080 | safeAddProp( home_phone, VCCellularProp ); | 1080 | safeAddProp( home_phone, VCCellularProp ); |
1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1082 | safeAddProp( home_phone, VCHomeProp ); | 1082 | safeAddProp( home_phone, VCHomeProp ); |
1083 | safeAddProp( home_phone, VCFaxProp ); | 1083 | safeAddProp( home_phone, VCFaxProp ); |
1084 | 1084 | ||
1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1086 | safeAddProp( url, VCHomeProp ); | 1086 | safeAddProp( url, VCHomeProp ); |
1087 | 1087 | ||
1088 | // work properties | 1088 | // work properties |
1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1090 | safeAddProp( work_adr, VCWorkProp ); | 1090 | safeAddProp( work_adr, VCWorkProp ); |
1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1096 | 1096 | ||
1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1098 | safeAddProp( work_phone, VCWorkProp ); | 1098 | safeAddProp( work_phone, VCWorkProp ); |
1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1100 | safeAddProp( work_phone, VCWorkProp ); | 1100 | safeAddProp( work_phone, VCWorkProp ); |
1101 | safeAddProp( work_phone, VCCellularProp ); | 1101 | safeAddProp( work_phone, VCCellularProp ); |
1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1103 | safeAddProp( work_phone, VCWorkProp ); | 1103 | safeAddProp( work_phone, VCWorkProp ); |
1104 | safeAddProp( work_phone, VCFaxProp ); | 1104 | safeAddProp( work_phone, VCFaxProp ); |
1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1106 | safeAddProp( work_phone, VCWorkProp ); | 1106 | safeAddProp( work_phone, VCWorkProp ); |
1107 | safeAddProp( work_phone, VCPagerProp ); | 1107 | safeAddProp( work_phone, VCPagerProp ); |
1108 | 1108 | ||
1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1110 | safeAddProp( url, VCWorkProp ); | 1110 | safeAddProp( url, VCWorkProp ); |
1111 | 1111 | ||
1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1113 | safeAddProp( title, VCWorkProp ); | 1113 | safeAddProp( title, VCWorkProp ); |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | QStringList emails = c.emailList(); | 1116 | QStringList emails = c.emailList(); |
1117 | emails.prepend( c.defaultEmail() ); | 1117 | emails.prepend( c.defaultEmail() ); |
1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1120 | safeAddProp( email, VCInternetProp ); | 1120 | safeAddProp( email, VCInternetProp ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1124 | 1124 | ||
1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | 1126 | if ( !c.birthday().isValid() ){ |
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | 1127 | QString birthd_rfc2425 = QString("%1-%2-%3") |
1128 | .arg( c.birthday().year() ) | ||
1129 | .arg( c.birthday().month(), 2 ) | ||
1130 | .arg( c.birthday().day(), 2 ); | ||
1131 | // Now replace spaces with "0"... | ||
1132 | int pos = 0; | ||
1133 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) | ||
1134 | birthd_rfc2425.replace( pos, 1, "0" ); | ||
1135 | |||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | 1136 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); |
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); |
1130 | } | 1138 | } |
1131 | 1139 | ||
1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1140 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1141 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1134 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1142 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1135 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1143 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1136 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1144 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1137 | } | 1145 | } |
1138 | 1146 | ||
1139 | // some values we have to export as custom fields | 1147 | // some values we have to export as custom fields |
1140 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1141 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1149 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1142 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1150 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1143 | 1151 | ||
1144 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1152 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1145 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1153 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1146 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); | 1154 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); |
1147 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1155 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1148 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1156 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1149 | 1157 | ||
1150 | return vcard; | 1158 | return vcard; |
1151 | } | 1159 | } |
1152 | 1160 | ||
1153 | 1161 | ||
1154 | /*! | 1162 | /*! |
1155 | \internal | 1163 | \internal |
1156 | */ | 1164 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | 1165 | static QDate convVCardDateToDate( const QString& datestr ) |
1158 | { | 1166 | { |
1159 | int monthPos = datestr.find('-'); | 1167 | int monthPos = datestr.find('-'); |
1160 | int dayPos = datestr.find('-', monthPos+1 ); | 1168 | int dayPos = datestr.find('-', monthPos+1 ); |
1169 | int sep_ignore = 1; | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | 1170 | if ( monthPos == -1 || dayPos == -1 ) { |
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 1171 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
1163 | return QDate(); | 1172 | // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) |
1173 | monthPos = 4; | ||
1174 | dayPos = 6; | ||
1175 | sep_ignore = 0; | ||
1176 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1164 | } | 1177 | } |
1165 | int y = datestr.left( monthPos ).toInt(); | 1178 | int y = datestr.left( monthPos ).toInt(); |
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | 1179 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | 1180 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
1168 | QDate date ( y,m,d ); | ||
1169 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 1181 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
1182 | QDate date ( y,m,d ); | ||
1170 | return date; | 1183 | return date; |
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | static OContact parseVObject( VObject *obj ) | 1186 | static OContact parseVObject( VObject *obj ) |
1174 | { | 1187 | { |
1175 | OContact c; | 1188 | OContact c; |
1176 | 1189 | ||
1177 | VObjectIterator it; | 1190 | VObjectIterator it; |
1178 | initPropIterator( &it, obj ); | 1191 | initPropIterator( &it, obj ); |
1179 | while( moreIteration( &it ) ) { | 1192 | while( moreIteration( &it ) ) { |
1180 | VObject *o = nextVObject( &it ); | 1193 | VObject *o = nextVObject( &it ); |
1181 | QCString name = vObjectName( o ); | 1194 | QCString name = vObjectName( o ); |
1182 | QCString value = vObjectStringZValue( o ); | 1195 | QCString value = vObjectStringZValue( o ); |
1183 | if ( name == VCNameProp ) { | 1196 | if ( name == VCNameProp ) { |
1184 | VObjectIterator nit; | 1197 | VObjectIterator nit; |
1185 | initPropIterator( &nit, o ); | 1198 | initPropIterator( &nit, o ); |
1186 | while( moreIteration( &nit ) ) { | 1199 | while( moreIteration( &nit ) ) { |
1187 | VObject *o = nextVObject( &nit ); | 1200 | VObject *o = nextVObject( &nit ); |
1188 | QCString name = vObjectTypeInfo( o ); | 1201 | QCString name = vObjectTypeInfo( o ); |
1189 | QString value = vObjectStringZValue( o ); | 1202 | QString value = vObjectStringZValue( o ); |
1190 | if ( name == VCNamePrefixesProp ) | 1203 | if ( name == VCNamePrefixesProp ) |
1191 | c.setTitle( value ); | 1204 | c.setTitle( value ); |
1192 | else if ( name == VCNameSuffixesProp ) | 1205 | else if ( name == VCNameSuffixesProp ) |
1193 | c.setSuffix( value ); | 1206 | c.setSuffix( value ); |
1194 | else if ( name == VCFamilyNameProp ) | 1207 | else if ( name == VCFamilyNameProp ) |
1195 | c.setLastName( value ); | 1208 | c.setLastName( value ); |
1196 | else if ( name == VCGivenNameProp ) | 1209 | else if ( name == VCGivenNameProp ) |
1197 | c.setFirstName( value ); | 1210 | c.setFirstName( value ); |
1198 | else if ( name == VCAdditionalNamesProp ) | 1211 | else if ( name == VCAdditionalNamesProp ) |
1199 | c.setMiddleName( value ); | 1212 | c.setMiddleName( value ); |
1200 | } | 1213 | } |
1201 | } | 1214 | } |
1202 | else if ( name == VCAdrProp ) { | 1215 | else if ( name == VCAdrProp ) { |
1203 | bool work = TRUE; // default address is work address | 1216 | bool work = TRUE; // default address is work address |
1204 | QString street; | 1217 | QString street; |
1205 | QString city; | 1218 | QString city; |
1206 | QString region; | 1219 | QString region; |
1207 | QString postal; | 1220 | QString postal; |
1208 | QString country; | 1221 | QString country; |
1209 | 1222 | ||
1210 | VObjectIterator nit; | 1223 | VObjectIterator nit; |
1211 | initPropIterator( &nit, o ); | 1224 | initPropIterator( &nit, o ); |
1212 | while( moreIteration( &nit ) ) { | 1225 | while( moreIteration( &nit ) ) { |
1213 | VObject *o = nextVObject( &nit ); | 1226 | VObject *o = nextVObject( &nit ); |
1214 | QCString name = vObjectName( o ); | 1227 | QCString name = vObjectName( o ); |
1215 | QString value = vObjectStringZValue( o ); | 1228 | QString value = vObjectStringZValue( o ); |
1216 | if ( name == VCHomeProp ) | 1229 | if ( name == VCHomeProp ) |
1217 | work = FALSE; | 1230 | work = FALSE; |
1218 | else if ( name == VCWorkProp ) | 1231 | else if ( name == VCWorkProp ) |
1219 | work = TRUE; | 1232 | work = TRUE; |
1220 | else if ( name == VCStreetAddressProp ) | 1233 | else if ( name == VCStreetAddressProp ) |
1221 | street = value; | 1234 | street = value; |
1222 | else if ( name == VCCityProp ) | 1235 | else if ( name == VCCityProp ) |
1223 | city = value; | 1236 | city = value; |
1224 | else if ( name == VCRegionProp ) | 1237 | else if ( name == VCRegionProp ) |
1225 | region = value; | 1238 | region = value; |
1226 | else if ( name == VCPostalCodeProp ) | 1239 | else if ( name == VCPostalCodeProp ) |
1227 | postal = value; | 1240 | postal = value; |
1228 | else if ( name == VCCountryNameProp ) | 1241 | else if ( name == VCCountryNameProp ) |
1229 | country = value; | 1242 | country = value; |
1230 | } | 1243 | } |
1231 | if ( work ) { | 1244 | if ( work ) { |
1232 | c.setBusinessStreet( street ); | 1245 | c.setBusinessStreet( street ); |
1233 | c.setBusinessCity( city ); | 1246 | c.setBusinessCity( city ); |
1234 | c.setBusinessCountry( country ); | 1247 | c.setBusinessCountry( country ); |
1235 | c.setBusinessZip( postal ); | 1248 | c.setBusinessZip( postal ); |
1236 | c.setBusinessState( region ); | 1249 | c.setBusinessState( region ); |
1237 | } else { | 1250 | } else { |
1238 | c.setHomeStreet( street ); | 1251 | c.setHomeStreet( street ); |
1239 | c.setHomeCity( city ); | 1252 | c.setHomeCity( city ); |
1240 | c.setHomeCountry( country ); | 1253 | c.setHomeCountry( country ); |
1241 | c.setHomeZip( postal ); | 1254 | c.setHomeZip( postal ); |
1242 | c.setHomeState( region ); | 1255 | c.setHomeState( region ); |
1243 | } | 1256 | } |
1244 | } | 1257 | } |
1245 | else if ( name == VCTelephoneProp ) { | 1258 | else if ( name == VCTelephoneProp ) { |
1246 | enum { | 1259 | enum { |
1247 | HOME = 0x01, | 1260 | HOME = 0x01, |
1248 | WORK = 0x02, | 1261 | WORK = 0x02, |
1249 | VOICE = 0x04, | 1262 | VOICE = 0x04, |
1250 | CELL = 0x08, | 1263 | CELL = 0x08, |
1251 | FAX = 0x10, | 1264 | FAX = 0x10, |
1252 | PAGER = 0x20, | 1265 | PAGER = 0x20, |
1253 | UNKNOWN = 0x80 | 1266 | UNKNOWN = 0x80 |
1254 | }; | 1267 | }; |
1255 | int type = 0; | 1268 | int type = 0; |
1256 | 1269 | ||
1257 | VObjectIterator nit; | 1270 | VObjectIterator nit; |
1258 | initPropIterator( &nit, o ); | 1271 | initPropIterator( &nit, o ); |
1259 | while( moreIteration( &nit ) ) { | 1272 | while( moreIteration( &nit ) ) { |
1260 | VObject *o = nextVObject( &nit ); | 1273 | VObject *o = nextVObject( &nit ); |
1261 | QCString name = vObjectTypeInfo( o ); | 1274 | QCString name = vObjectTypeInfo( o ); |
1262 | if ( name == VCHomeProp ) | 1275 | if ( name == VCHomeProp ) |
1263 | type |= HOME; | 1276 | type |= HOME; |
1264 | else if ( name == VCWorkProp ) | 1277 | else if ( name == VCWorkProp ) |
1265 | type |= WORK; | 1278 | type |= WORK; |
1266 | else if ( name == VCVoiceProp ) | 1279 | else if ( name == VCVoiceProp ) |
1267 | type |= VOICE; | 1280 | type |= VOICE; |
1268 | else if ( name == VCCellularProp ) | 1281 | else if ( name == VCCellularProp ) |
1269 | type |= CELL; | 1282 | type |= CELL; |
1270 | else if ( name == VCFaxProp ) | 1283 | else if ( name == VCFaxProp ) |
1271 | type |= FAX; | 1284 | type |= FAX; |
1272 | else if ( name == VCPagerProp ) | 1285 | else if ( name == VCPagerProp ) |
1273 | type |= PAGER; | 1286 | type |= PAGER; |
1274 | else if ( name == VCPreferredProp ) | 1287 | else if ( name == VCPreferredProp ) |
1275 | ; | 1288 | ; |
1276 | else | 1289 | else |
1277 | type |= UNKNOWN; | 1290 | type |= UNKNOWN; |
1278 | } | 1291 | } |
1279 | if ( (type & UNKNOWN) != UNKNOWN ) { | 1292 | if ( (type & UNKNOWN) != UNKNOWN ) { |
1280 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 1293 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
1281 | type |= HOME; | 1294 | type |= HOME; |
1282 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 1295 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
1283 | type |= VOICE; | 1296 | type |= VOICE; |
1284 | 1297 | ||
1285 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 1298 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
1286 | c.setHomePhone( value ); | 1299 | c.setHomePhone( value ); |
1287 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 1300 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
1288 | c.setHomeFax( value ); | 1301 | c.setHomeFax( value ); |
1289 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 1302 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
1290 | c.setHomeMobile( value ); | 1303 | c.setHomeMobile( value ); |
1291 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 1304 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
1292 | c.setBusinessPhone( value ); | 1305 | c.setBusinessPhone( value ); |
1293 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 1306 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
1294 | c.setBusinessFax( value ); | 1307 | c.setBusinessFax( value ); |
1295 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 1308 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
1296 | c.setBusinessMobile( value ); | 1309 | c.setBusinessMobile( value ); |
1297 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 1310 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
1298 | c.setBusinessPager( value ); | 1311 | c.setBusinessPager( value ); |
1299 | } | 1312 | } |
1300 | } | 1313 | } |
1301 | else if ( name == VCEmailAddressProp ) { | 1314 | else if ( name == VCEmailAddressProp ) { |
1302 | QString email = vObjectStringZValue( o ); | 1315 | QString email = vObjectStringZValue( o ); |
1303 | bool valid = TRUE; | 1316 | bool valid = TRUE; |
1304 | VObjectIterator nit; | 1317 | VObjectIterator nit; |
1305 | initPropIterator( &nit, o ); | 1318 | initPropIterator( &nit, o ); |
1306 | while( moreIteration( &nit ) ) { | 1319 | while( moreIteration( &nit ) ) { |
1307 | VObject *o = nextVObject( &nit ); | 1320 | VObject *o = nextVObject( &nit ); |
1308 | QCString name = vObjectTypeInfo( o ); | 1321 | QCString name = vObjectTypeInfo( o ); |
1309 | if ( name != VCInternetProp && name != VCHomeProp && | 1322 | if ( name != VCInternetProp && name != VCHomeProp && |
1310 | name != VCWorkProp && | 1323 | name != VCWorkProp && |
1311 | name != VCPreferredProp ) | 1324 | name != VCPreferredProp ) |
1312 | // ### preffered should map to default email | 1325 | // ### preffered should map to default email |
1313 | valid = FALSE; | 1326 | valid = FALSE; |
1314 | } | 1327 | } |
1315 | if ( valid ) { | 1328 | if ( valid ) { |
1316 | c.insertEmail( email ); | 1329 | c.insertEmail( email ); |
1317 | } | 1330 | } |
1318 | } | 1331 | } |
1319 | else if ( name == VCURLProp ) { | 1332 | else if ( name == VCURLProp ) { |
1320 | VObjectIterator nit; | 1333 | VObjectIterator nit; |
1321 | initPropIterator( &nit, o ); | 1334 | initPropIterator( &nit, o ); |
1322 | while( moreIteration( &nit ) ) { | 1335 | while( moreIteration( &nit ) ) { |
1323 | VObject *o = nextVObject( &nit ); | 1336 | VObject *o = nextVObject( &nit ); |
1324 | QCString name = vObjectTypeInfo( o ); | 1337 | QCString name = vObjectTypeInfo( o ); |
1325 | if ( name == VCHomeProp ) | 1338 | if ( name == VCHomeProp ) |
1326 | c.setHomeWebpage( value ); | 1339 | c.setHomeWebpage( value ); |
1327 | else if ( name == VCWorkProp ) | 1340 | else if ( name == VCWorkProp ) |
1328 | c.setBusinessWebpage( value ); | 1341 | c.setBusinessWebpage( value ); |
1329 | } | 1342 | } |
1330 | } | 1343 | } |
1331 | else if ( name == VCOrgProp ) { | 1344 | else if ( name == VCOrgProp ) { |
1332 | VObjectIterator nit; | 1345 | VObjectIterator nit; |
1333 | initPropIterator( &nit, o ); | 1346 | initPropIterator( &nit, o ); |
1334 | while( moreIteration( &nit ) ) { | 1347 | while( moreIteration( &nit ) ) { |
1335 | VObject *o = nextVObject( &nit ); | 1348 | VObject *o = nextVObject( &nit ); |
1336 | QCString name = vObjectName( o ); | 1349 | QCString name = vObjectName( o ); |
1337 | QString value = vObjectStringZValue( o ); | 1350 | QString value = vObjectStringZValue( o ); |
1338 | if ( name == VCOrgNameProp ) | 1351 | if ( name == VCOrgNameProp ) |
1339 | c.setCompany( value ); | 1352 | c.setCompany( value ); |
1340 | else if ( name == VCOrgUnitProp ) | 1353 | else if ( name == VCOrgUnitProp ) |
1341 | c.setDepartment( value ); | 1354 | c.setDepartment( value ); |
1342 | else if ( name == VCOrgUnit2Prop ) | 1355 | else if ( name == VCOrgUnit2Prop ) |
1343 | c.setOffice( value ); | 1356 | c.setOffice( value ); |
1344 | } | 1357 | } |
1345 | } | 1358 | } |
1346 | else if ( name == VCTitleProp ) { | 1359 | else if ( name == VCTitleProp ) { |
1347 | c.setJobTitle( value ); | 1360 | c.setJobTitle( value ); |
1348 | } | 1361 | } |
1349 | else if ( name == "X-Qtopia-Profession" ) { | 1362 | else if ( name == "X-Qtopia-Profession" ) { |
1350 | c.setProfession( value ); | 1363 | c.setProfession( value ); |
1351 | } | 1364 | } |
1352 | else if ( name == "X-Qtopia-Manager" ) { | 1365 | else if ( name == "X-Qtopia-Manager" ) { |
1353 | c.setManager( value ); | 1366 | c.setManager( value ); |
1354 | } | 1367 | } |
1355 | else if ( name == "X-Qtopia-Assistant" ) { | 1368 | else if ( name == "X-Qtopia-Assistant" ) { |
1356 | c.setAssistant( value ); | 1369 | c.setAssistant( value ); |
1357 | } | 1370 | } |
1358 | else if ( name == "X-Qtopia-Spouse" ) { | 1371 | else if ( name == "X-Qtopia-Spouse" ) { |
1359 | c.setSpouse( value ); | 1372 | c.setSpouse( value ); |
1360 | } | 1373 | } |
1361 | else if ( name == "X-Qtopia-Gender" ) { | 1374 | else if ( name == "X-Qtopia-Gender" ) { |
1362 | c.setGender( value ); | 1375 | c.setGender( value ); |
1363 | } | 1376 | } |
1364 | else if ( name == "X-Qtopia-Anniversary" ) { | 1377 | else if ( name == "X-Qtopia-Anniversary" ) { |
1365 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1378 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1366 | } | 1379 | } |
1367 | else if ( name == "X-Qtopia-Nickname" ) { | 1380 | else if ( name == "X-Qtopia-Nickname" ) { |
1368 | c.setNickname( value ); | 1381 | c.setNickname( value ); |
1369 | } | 1382 | } |
1370 | else if ( name == "X-Qtopia-Children" ) { | 1383 | else if ( name == "X-Qtopia-Children" ) { |
1371 | c.setChildren( value ); | 1384 | c.setChildren( value ); |
1372 | } | 1385 | } |
1373 | else if ( name == VCBirthDateProp ) { | 1386 | else if ( name == VCBirthDateProp ) { |
1374 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 1387 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
1375 | c.setBirthday( convVCardDateToDate( value ) ); | 1388 | c.setBirthday( convVCardDateToDate( value ) ); |
1376 | 1389 | ||
1377 | } | 1390 | } |
1378 | 1391 | ||
1379 | #if 0 | 1392 | #if 0 |
1380 | else { | 1393 | else { |
1381 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1394 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1382 | VObjectIterator nit; | 1395 | VObjectIterator nit; |
1383 | initPropIterator( &nit, o ); | 1396 | initPropIterator( &nit, o ); |
1384 | while( moreIteration( &nit ) ) { | 1397 | while( moreIteration( &nit ) ) { |
1385 | VObject *o = nextVObject( &nit ); | 1398 | VObject *o = nextVObject( &nit ); |
1386 | QCString name = vObjectName( o ); | 1399 | QCString name = vObjectName( o ); |
1387 | QString value = vObjectStringZValue( o ); | 1400 | QString value = vObjectStringZValue( o ); |
1388 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1401 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1389 | } | 1402 | } |
1390 | } | 1403 | } |
1391 | #endif | 1404 | #endif |
1392 | } | 1405 | } |
1393 | c.setFileAs(); | 1406 | c.setFileAs(); |
1394 | return c; | 1407 | return c; |
1395 | } | 1408 | } |
1396 | 1409 | ||
1397 | /*! | 1410 | /*! |
1398 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1411 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1399 | */ | 1412 | */ |
1400 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1413 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1401 | { | 1414 | { |
1402 | QFileDirect f( filename.utf8().data() ); | 1415 | QFileDirect f( filename.utf8().data() ); |
1403 | if ( !f.open( IO_WriteOnly ) ) { | 1416 | if ( !f.open( IO_WriteOnly ) ) { |
1404 | qWarning("Unable to open vcard write"); | 1417 | qWarning("Unable to open vcard write"); |
1405 | return; | 1418 | return; |
1406 | } | 1419 | } |
1407 | 1420 | ||
1408 | QValueList<OContact>::ConstIterator it; | 1421 | QValueList<OContact>::ConstIterator it; |
1409 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1422 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1410 | VObject *obj = createVObject( *it ); | 1423 | VObject *obj = createVObject( *it ); |
1411 | writeVObject(f.directHandle() , obj ); | 1424 | writeVObject(f.directHandle() , obj ); |
1412 | cleanVObject( obj ); | 1425 | cleanVObject( obj ); |
1413 | } | 1426 | } |
1414 | cleanStrTbl(); | 1427 | cleanStrTbl(); |
1415 | } | 1428 | } |
1416 | 1429 | ||
1417 | /*! | 1430 | /*! |
1418 | writes \a contact as a VCard to the file \a filename. | 1431 | writes \a contact as a VCard to the file \a filename. |
1419 | */ | 1432 | */ |
1420 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1433 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1421 | { | 1434 | { |
1422 | QFileDirect f( filename.utf8().data() ); | 1435 | QFileDirect f( filename.utf8().data() ); |
1423 | if ( !f.open( IO_WriteOnly ) ) { | 1436 | if ( !f.open( IO_WriteOnly ) ) { |
1424 | qWarning("Unable to open vcard write"); | 1437 | qWarning("Unable to open vcard write"); |
1425 | return; | 1438 | return; |
1426 | } | 1439 | } |
1427 | 1440 | ||
1428 | VObject *obj = createVObject( contact ); | 1441 | VObject *obj = createVObject( contact ); |
1429 | writeVObject( f.directHandle() , obj ); | 1442 | writeVObject( f.directHandle() , obj ); |
1430 | cleanVObject( obj ); | 1443 | cleanVObject( obj ); |
1431 | 1444 | ||
1432 | cleanStrTbl(); | 1445 | cleanStrTbl(); |
1433 | } | 1446 | } |
1434 | 1447 | ||
1435 | /*! | 1448 | /*! |
1436 | Returns the set of contacts read as VCards from the file \a filename. | 1449 | Returns the set of contacts read as VCards from the file \a filename. |
1437 | */ | 1450 | */ |
1438 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1451 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1439 | { | 1452 | { |
1440 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1453 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1441 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1454 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1442 | 1455 | ||
1443 | qDebug("vobject = %p", obj ); | 1456 | qDebug("vobject = %p", obj ); |
1444 | 1457 | ||
1445 | QValueList<OContact> contacts; | 1458 | QValueList<OContact> contacts; |
1446 | 1459 | ||
1447 | while ( obj ) { | 1460 | while ( obj ) { |
1448 | contacts.append( parseVObject( obj ) ); | 1461 | contacts.append( parseVObject( obj ) ); |
1449 | 1462 | ||
1450 | VObject *t = obj; | 1463 | VObject *t = obj; |
1451 | obj = nextVObjectInList(obj); | 1464 | obj = nextVObjectInList(obj); |
1452 | cleanVObject( t ); | 1465 | cleanVObject( t ); |
1453 | } | 1466 | } |
1454 | 1467 | ||
1455 | return contacts; | 1468 | return contacts; |
1456 | } | 1469 | } |
1457 | 1470 | ||
1458 | /*! | 1471 | /*! |
1459 | Returns TRUE if the contact matches the regular expression \a regexp. | 1472 | Returns TRUE if the contact matches the regular expression \a regexp. |
1460 | Otherwise returns FALSE. | 1473 | Otherwise returns FALSE. |
1461 | */ | 1474 | */ |
1462 | bool OContact::match( const QString ®exp ) const | 1475 | bool OContact::match( const QString ®exp ) const |
1463 | { | 1476 | { |
1464 | return match(QRegExp(regexp)); | 1477 | return match(QRegExp(regexp)); |
1465 | } | 1478 | } |
1466 | 1479 | ||
1467 | /*! | 1480 | /*! |
1468 | \overload | 1481 | \overload |
1469 | Returns TRUE if the contact matches the regular expression \a regexp. | 1482 | Returns TRUE if the contact matches the regular expression \a regexp. |
1470 | Otherwise returns FALSE. | 1483 | Otherwise returns FALSE. |
1471 | */ | 1484 | */ |
1472 | bool OContact::match( const QRegExp &r ) const | 1485 | bool OContact::match( const QRegExp &r ) const |
1473 | { | 1486 | { |
1474 | bool match; | 1487 | bool match; |
1475 | match = false; | 1488 | match = false; |
1476 | QMap<int, QString>::ConstIterator it; | 1489 | QMap<int, QString>::ConstIterator it; |
1477 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1490 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1478 | if ( (*it).find( r ) > -1 ) { | 1491 | if ( (*it).find( r ) > -1 ) { |
1479 | match = true; | 1492 | match = true; |
1480 | break; | 1493 | break; |
1481 | } | 1494 | } |
1482 | } | 1495 | } |
1483 | return match; | 1496 | return match; |
1484 | } | 1497 | } |
1485 | 1498 | ||
1486 | 1499 | ||
1487 | QString OContact::toShortText() const | 1500 | QString OContact::toShortText() const |
1488 | { | 1501 | { |
1489 | return ( fullName() ); | 1502 | return ( fullName() ); |
1490 | } | 1503 | } |
1491 | QString OContact::type() const | 1504 | QString OContact::type() const |
1492 | { | 1505 | { |
1493 | return QString::fromLatin1( "OContact" ); | 1506 | return QString::fromLatin1( "OContact" ); |
1494 | } | 1507 | } |
1495 | 1508 | ||
1496 | // Definition is missing ! (se) | 1509 | // Definition is missing ! (se) |
1497 | QMap<QString,QString> OContact::toExtraMap() const | 1510 | QMap<QString,QString> OContact::toExtraMap() const |
1498 | { | 1511 | { |
1499 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1512 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1500 | QMap <QString,QString> useless; | 1513 | QMap <QString,QString> useless; |
1501 | return useless; | 1514 | return useless; |
1502 | } | 1515 | } |
1503 | 1516 | ||
1504 | class QString OContact::recordField( int pos ) const | 1517 | class QString OContact::recordField( int pos ) const |
1505 | { | 1518 | { |
1506 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1519 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1507 | return SLFIELDS[pos]; | 1520 | return SLFIELDS[pos]; |
1508 | } | 1521 | } |
1509 | 1522 | ||
1510 | // In future releases, we should store birthday and anniversary | 1523 | // In future releases, we should store birthday and anniversary |
1511 | // internally as QDate instead of QString ! | 1524 | // internally as QDate instead of QString ! |
1512 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1525 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1513 | 1526 | ||
1514 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1527 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1515 | Sets the birthday for the contact to \a date. | 1528 | Sets the birthday for the contact to \a date. |
1516 | */ | 1529 | */ |
1517 | void OContact::setBirthday( const QDate &v ) | 1530 | void OContact::setBirthday( const QDate &v ) |
1518 | { | 1531 | { |
1519 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1532 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1520 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1533 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1521 | 1534 | ||
1522 | } | 1535 | } |
1523 | 1536 | ||
1524 | 1537 | ||
1525 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1538 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1526 | Sets the anniversary of the contact to \a date. | 1539 | Sets the anniversary of the contact to \a date. |
1527 | */ | 1540 | */ |
1528 | void OContact::setAnniversary( const QDate &v ) | 1541 | void OContact::setAnniversary( const QDate &v ) |
1529 | { | 1542 | { |
1530 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1543 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1531 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1544 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1532 | } | 1545 | } |
1533 | 1546 | ||
1534 | /*! \fn QDate OContact::birthday() const | 1547 | /*! \fn QDate OContact::birthday() const |
1535 | Returns the birthday of the contact. | 1548 | Returns the birthday of the contact. |
1536 | */ | 1549 | */ |
1537 | QDate OContact::birthday() const | 1550 | QDate OContact::birthday() const |
1538 | { | 1551 | { |
1539 | QDate empty; | 1552 | QDate empty; |
1540 | QString str = find( Qtopia::Birthday ); | 1553 | QString str = find( Qtopia::Birthday ); |
1541 | qWarning ("Birthday %s", str.latin1() ); | 1554 | qWarning ("Birthday %s", str.latin1() ); |
1542 | if ( !str.isEmpty() ) | 1555 | if ( !str.isEmpty() ) |
1543 | return TimeConversion::fromString ( str ); | 1556 | return TimeConversion::fromString ( str ); |
1544 | else | 1557 | else |
1545 | return empty; | 1558 | return empty; |
1546 | } | 1559 | } |
1547 | 1560 | ||
1548 | 1561 | ||
1549 | /*! \fn QDate OContact::anniversary() const | 1562 | /*! \fn QDate OContact::anniversary() const |
1550 | Returns the anniversary of the contact. | 1563 | Returns the anniversary of the contact. |
1551 | */ | 1564 | */ |
1552 | QDate OContact::anniversary() const | 1565 | QDate OContact::anniversary() const |
1553 | { | 1566 | { |
1554 | QDate empty; | 1567 | QDate empty; |
1555 | QString str = find( Qtopia::Anniversary ); | 1568 | QString str = find( Qtopia::Anniversary ); |
1556 | qWarning ("Anniversary %s", str.latin1() ); | 1569 | qWarning ("Anniversary %s", str.latin1() ); |
1557 | if ( !str.isEmpty() ) | 1570 | if ( !str.isEmpty() ) |
1558 | return TimeConversion::fromString ( str ); | 1571 | return TimeConversion::fromString ( str ); |
1559 | else | 1572 | else |
1560 | return empty; | 1573 | return empty; |
1561 | } | 1574 | } |
1562 | 1575 | ||
1563 | 1576 | ||
1564 | void OContact::insertEmail( const QString &v ) | 1577 | void OContact::insertEmail( const QString &v ) |
1565 | { | 1578 | { |
1566 | //qDebug("insertEmail %s", v.latin1()); | 1579 | //qDebug("insertEmail %s", v.latin1()); |
1567 | QString e = v.simplifyWhiteSpace(); | 1580 | QString e = v.simplifyWhiteSpace(); |
1568 | QString def = defaultEmail(); | 1581 | QString def = defaultEmail(); |
1569 | 1582 | ||
1570 | // if no default, set it as the default email and don't insert | 1583 | // if no default, set it as the default email and don't insert |
1571 | if ( def.isEmpty() ) { | 1584 | if ( def.isEmpty() ) { |
1572 | setDefaultEmail( e ); // will insert into the list for us | 1585 | setDefaultEmail( e ); // will insert into the list for us |
1573 | return; | 1586 | return; |
1574 | } | 1587 | } |
1575 | 1588 | ||
1576 | // otherwise, insert assuming doesn't already exist | 1589 | // otherwise, insert assuming doesn't already exist |
1577 | QString emailsStr = find( Qtopia::Emails ); | 1590 | QString emailsStr = find( Qtopia::Emails ); |
1578 | if ( emailsStr.contains( e )) | 1591 | if ( emailsStr.contains( e )) |
1579 | return; | 1592 | return; |
1580 | if ( !emailsStr.isEmpty() ) | 1593 | if ( !emailsStr.isEmpty() ) |
1581 | emailsStr += emailSeparator(); | 1594 | emailsStr += emailSeparator(); |
1582 | emailsStr += e; | 1595 | emailsStr += e; |
1583 | replace( Qtopia::Emails, emailsStr ); | 1596 | replace( Qtopia::Emails, emailsStr ); |
1584 | } | 1597 | } |
1585 | 1598 | ||
1586 | void OContact::removeEmail( const QString &v ) | 1599 | void OContact::removeEmail( const QString &v ) |
1587 | { | 1600 | { |
1588 | QString e = v.simplifyWhiteSpace(); | 1601 | QString e = v.simplifyWhiteSpace(); |
1589 | QString def = defaultEmail(); | 1602 | QString def = defaultEmail(); |
1590 | QString emailsStr = find( Qtopia::Emails ); | 1603 | QString emailsStr = find( Qtopia::Emails ); |
1591 | QStringList emails = emailList(); | 1604 | QStringList emails = emailList(); |
1592 | 1605 | ||
1593 | // otherwise, must first contain it | 1606 | // otherwise, must first contain it |
1594 | if ( !emailsStr.contains( e ) ) | 1607 | if ( !emailsStr.contains( e ) ) |
1595 | return; | 1608 | return; |
1596 | 1609 | ||
1597 | // remove it | 1610 | // remove it |
1598 | //qDebug(" removing email from list %s", e.latin1()); | 1611 | //qDebug(" removing email from list %s", e.latin1()); |
1599 | emails.remove( e ); | 1612 | emails.remove( e ); |
1600 | // reset the string | 1613 | // reset the string |
1601 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1614 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1602 | replace( Qtopia::Emails, emailsStr ); | 1615 | replace( Qtopia::Emails, emailsStr ); |
1603 | 1616 | ||
1604 | // if default, then replace the default email with the first one | 1617 | // if default, then replace the default email with the first one |
1605 | if ( def == e ) { | 1618 | if ( def == e ) { |
1606 | //qDebug("removeEmail is default; setting new default"); | 1619 | //qDebug("removeEmail is default; setting new default"); |
1607 | if ( !emails.count() ) | 1620 | if ( !emails.count() ) |
1608 | clearEmails(); | 1621 | clearEmails(); |
1609 | else // setDefaultEmail will remove e from the list | 1622 | else // setDefaultEmail will remove e from the list |
1610 | setDefaultEmail( emails.first() ); | 1623 | setDefaultEmail( emails.first() ); |
1611 | } | 1624 | } |
1612 | } | 1625 | } |
1613 | void OContact::clearEmails() | 1626 | void OContact::clearEmails() |
1614 | { | 1627 | { |
1615 | mMap.remove( Qtopia::DefaultEmail ); | 1628 | mMap.remove( Qtopia::DefaultEmail ); |
1616 | mMap.remove( Qtopia::Emails ); | 1629 | mMap.remove( Qtopia::Emails ); |
1617 | } | 1630 | } |
1618 | void OContact::setDefaultEmail( const QString &v ) | 1631 | void OContact::setDefaultEmail( const QString &v ) |
1619 | { | 1632 | { |
1620 | QString e = v.simplifyWhiteSpace(); | 1633 | QString e = v.simplifyWhiteSpace(); |
1621 | 1634 | ||
1622 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1635 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1623 | replace( Qtopia::DefaultEmail, e ); | 1636 | replace( Qtopia::DefaultEmail, e ); |
1624 | 1637 | ||
1625 | if ( !e.isEmpty() ) | 1638 | if ( !e.isEmpty() ) |
1626 | insertEmail( e ); | 1639 | insertEmail( e ); |
1627 | 1640 | ||
1628 | } | 1641 | } |
1629 | 1642 | ||
1630 | void OContact::insertEmails( const QStringList &v ) | 1643 | void OContact::insertEmails( const QStringList &v ) |
1631 | { | 1644 | { |
1632 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1645 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1633 | insertEmail( *it ); | 1646 | insertEmail( *it ); |
1634 | } | 1647 | } |
1635 | 1648 | ||