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