summaryrefslogtreecommitdiff
authoreilers <eilers>2003-02-18 11:55:59 (UTC)
committer eilers <eilers>2003-02-18 11:55:59 (UTC)
commit00e9f7731c19604a8e79df9e935ec833fc1937f8 (patch) (unidiff)
tree7bf9b8230832e2138af7e73740b28eafc4c33101
parent065f26b161f6df269cfbf9c75751c09453350995 (diff)
downloadopie-00e9f7731c19604a8e79df9e935ec833fc1937f8.zip
opie-00e9f7731c19604a8e79df9e935ec833fc1937f8.tar.gz
opie-00e9f7731c19604a8e79df9e935ec833fc1937f8.tar.bz2
Fixing categoryNames in opimrecord which was just checking for Todo List
Now we get the categories in addressbook, too !
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp4
-rw-r--r--libopie/pim/opimrecord.cpp4
-rw-r--r--libopie/pim/opimrecord.h2
-rw-r--r--libopie/pim/otodo.cpp2
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp4
-rw-r--r--libopie2/opiepim/core/opimrecord.h2
-rw-r--r--libopie2/opiepim/ocontact.cpp4
-rw-r--r--libopie2/opiepim/otodo.cpp2
8 files changed, 12 insertions, 12 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 178559b..9cccfc8 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,1148 +1,1148 @@
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 "opimresolver.h" 25#include "opimresolver.h"
26 26
27#include <qpe/stringutil.h> 27#include <qpe/stringutil.h>
28#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30 30
31#include <qobject.h> 31#include <qobject.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qstylesheet.h> 33#include <qstylesheet.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qmap.h> 35#include <qmap.h>
36 36
37#include <stdio.h> 37#include <stdio.h>
38 38
39/*! 39/*!
40 \class Contact contact.h 40 \class Contact contact.h
41 \brief The Contact class holds the data of an address book entry. 41 \brief The Contact class holds the data of an address book entry.
42 42
43 This data includes information the name of the person, contact 43 This data includes information the name of the person, contact
44 information, and business information such as deparment and job title. 44 information, and business information such as deparment and job title.
45 45
46 \ingroup qtopiaemb 46 \ingroup qtopiaemb
47 \ingroup qtopiadesktop 47 \ingroup qtopiadesktop
48*/ 48*/
49 49
50 50
51/*! 51/*!
52 Creates a new, empty contact. 52 Creates a new, empty contact.
53*/ 53*/
54OContact::OContact() 54OContact::OContact()
55 : OPimRecord(), mMap(), d( 0 ) 55 : OPimRecord(), mMap(), d( 0 )
56{ 56{
57} 57}
58 58
59/*! 59/*!
60 \internal 60 \internal
61 Creates a new contact. The properties of the contact are 61 Creates a new contact. The properties of the contact are
62 set from \a fromMap. 62 set from \a fromMap.
63*/ 63*/
64OContact::OContact( const QMap<int, QString> &fromMap ) : 64OContact::OContact( const QMap<int, QString> &fromMap ) :
65 OPimRecord(), mMap( fromMap ), d( 0 ) 65 OPimRecord(), mMap( fromMap ), d( 0 )
66{ 66{
67 QString cats = mMap[ Qtopia::AddressCategory ]; 67 QString cats = mMap[ Qtopia::AddressCategory ];
68 if ( !cats.isEmpty() ) 68 if ( !cats.isEmpty() )
69 setCategories( idsFromString( cats ) ); 69 setCategories( idsFromString( cats ) );
70 70
71 QString uidStr = find( Qtopia::AddressUid ); 71 QString uidStr = find( Qtopia::AddressUid );
72 72
73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
74 qWarning( "Invalid UID found. Generate new one.." ); 74 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 75 setUid( uidGen().generate() );
76 }else 76 }else
77 setUid( uidStr.toInt() ); 77 setUid( uidStr.toInt() );
78 78
79// if ( !uidStr.isEmpty() ) 79// if ( !uidStr.isEmpty() )
80 // setUid( uidStr.toInt() ); 80 // setUid( uidStr.toInt() );
81} 81}
82 82
83/*! 83/*!
84 Destroys a contact. 84 Destroys a contact.
85*/ 85*/
86OContact::~OContact() 86OContact::~OContact()
87{ 87{
88} 88}
89 89
90/*! \fn void OContact::setTitle( const QString &str ) 90/*! \fn void OContact::setTitle( const QString &str )
91 Sets the title of the contact to \a str. 91 Sets the title of the contact to \a str.
92*/ 92*/
93 93
94/*! \fn void OContact::setFirstName( const QString &str ) 94/*! \fn void OContact::setFirstName( const QString &str )
95 Sets the first name of the contact to \a str. 95 Sets the first name of the contact to \a str.
96*/ 96*/
97 97
98/*! \fn void OContact::setMiddleName( const QString &str ) 98/*! \fn void OContact::setMiddleName( const QString &str )
99 Sets the middle name of the contact to \a str. 99 Sets the middle name of the contact to \a str.
100*/ 100*/
101 101
102/*! \fn void OContact::setLastName( const QString &str ) 102/*! \fn void OContact::setLastName( const QString &str )
103 Sets the last name of the contact to \a str. 103 Sets the last name of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OContact::setSuffix( const QString &str ) 106/*! \fn void OContact::setSuffix( const QString &str )
107 Sets the suffix of the contact to \a str. 107 Sets the suffix of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OContact::setFileAs( const QString &str ) 110/*! \fn void OContact::setFileAs( const QString &str )
111 Sets the contact to filed as \a str. 111 Sets the contact to filed as \a str.
112*/ 112*/
113 113
114/*! \fn void OContact::setDefaultEmail( const QString &str ) 114/*! \fn void OContact::setDefaultEmail( const QString &str )
115 Sets the default email of the contact to \a str. 115 Sets the default email of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OContact::setHomeStreet( const QString &str ) 118/*! \fn void OContact::setHomeStreet( const QString &str )
119 Sets the home street address of the contact to \a str. 119 Sets the home street address of the contact to \a str.
120*/ 120*/
121 121
122/*! \fn void OContact::setHomeCity( const QString &str ) 122/*! \fn void OContact::setHomeCity( const QString &str )
123 Sets the home city of the contact to \a str. 123 Sets the home city of the contact to \a str.
124*/ 124*/
125 125
126/*! \fn void OContact::setHomeState( const QString &str ) 126/*! \fn void OContact::setHomeState( const QString &str )
127 Sets the home state of the contact to \a str. 127 Sets the home state of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OContact::setHomeZip( const QString &str ) 130/*! \fn void OContact::setHomeZip( const QString &str )
131 Sets the home zip code of the contact to \a str. 131 Sets the home zip code of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OContact::setHomeCountry( const QString &str ) 134/*! \fn void OContact::setHomeCountry( const QString &str )
135 Sets the home country of the contact to \a str. 135 Sets the home country of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OContact::setHomePhone( const QString &str ) 138/*! \fn void OContact::setHomePhone( const QString &str )
139 Sets the home phone number of the contact to \a str. 139 Sets the home phone number of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OContact::setHomeFax( const QString &str ) 142/*! \fn void OContact::setHomeFax( const QString &str )
143 Sets the home fax number of the contact to \a str. 143 Sets the home fax number of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OContact::setHomeMobile( const QString &str ) 146/*! \fn void OContact::setHomeMobile( const QString &str )
147 Sets the home mobile phone number of the contact to \a str. 147 Sets the home mobile phone number of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OContact::setHomeWebpage( const QString &str ) 150/*! \fn void OContact::setHomeWebpage( const QString &str )
151 Sets the home webpage of the contact to \a str. 151 Sets the home webpage of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OContact::setCompany( const QString &str ) 154/*! \fn void OContact::setCompany( const QString &str )
155 Sets the company for contact to \a str. 155 Sets the company for contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OContact::setJobTitle( const QString &str ) 158/*! \fn void OContact::setJobTitle( const QString &str )
159 Sets the job title of the contact to \a str. 159 Sets the job title of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OContact::setDepartment( const QString &str ) 162/*! \fn void OContact::setDepartment( const QString &str )
163 Sets the department for contact to \a str. 163 Sets the department for contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OContact::setOffice( const QString &str ) 166/*! \fn void OContact::setOffice( const QString &str )
167 Sets the office for contact to \a str. 167 Sets the office for contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OContact::setBusinessStreet( const QString &str ) 170/*! \fn void OContact::setBusinessStreet( const QString &str )
171 Sets the business street address of the contact to \a str. 171 Sets the business street address of the contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OContact::setBusinessCity( const QString &str ) 174/*! \fn void OContact::setBusinessCity( const QString &str )
175 Sets the business city of the contact to \a str. 175 Sets the business city of the contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OContact::setBusinessState( const QString &str ) 178/*! \fn void OContact::setBusinessState( const QString &str )
179 Sets the business state of the contact to \a str. 179 Sets the business state of the contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OContact::setBusinessZip( const QString &str ) 182/*! \fn void OContact::setBusinessZip( const QString &str )
183 Sets the business zip code of the contact to \a str. 183 Sets the business zip code of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OContact::setBusinessCountry( const QString &str ) 186/*! \fn void OContact::setBusinessCountry( const QString &str )
187 Sets the business country of the contact to \a str. 187 Sets the business country of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OContact::setBusinessPhone( const QString &str ) 190/*! \fn void OContact::setBusinessPhone( const QString &str )
191 Sets the business phone number of the contact to \a str. 191 Sets the business phone number of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OContact::setBusinessFax( const QString &str ) 194/*! \fn void OContact::setBusinessFax( const QString &str )
195 Sets the business fax number of the contact to \a str. 195 Sets the business fax number of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OContact::setBusinessMobile( const QString &str ) 198/*! \fn void OContact::setBusinessMobile( const QString &str )
199 Sets the business mobile phone number of the contact to \a str. 199 Sets the business mobile phone number of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OContact::setBusinessPager( const QString &str ) 202/*! \fn void OContact::setBusinessPager( const QString &str )
203 Sets the business pager number of the contact to \a str. 203 Sets the business pager number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OContact::setBusinessWebpage( const QString &str ) 206/*! \fn void OContact::setBusinessWebpage( const QString &str )
207 Sets the business webpage of the contact to \a str. 207 Sets the business webpage of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OContact::setProfession( const QString &str ) 210/*! \fn void OContact::setProfession( const QString &str )
211 Sets the profession of the contact to \a str. 211 Sets the profession of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OContact::setAssistant( const QString &str ) 214/*! \fn void OContact::setAssistant( const QString &str )
215 Sets the assistant of the contact to \a str. 215 Sets the assistant of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OContact::setManager( const QString &str ) 218/*! \fn void OContact::setManager( const QString &str )
219 Sets the manager of the contact to \a str. 219 Sets the manager of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OContact::setSpouse( const QString &str ) 222/*! \fn void OContact::setSpouse( const QString &str )
223 Sets the spouse of the contact to \a str. 223 Sets the spouse of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OContact::setGender( const QString &str ) 226/*! \fn void OContact::setGender( const QString &str )
227 Sets the gender of the contact to \a str. 227 Sets the gender of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OContact::setNickname( const QString &str ) 230/*! \fn void OContact::setNickname( const QString &str )
231 Sets the nickname of the contact to \a str. 231 Sets the nickname of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OContact::setNotes( const QString &str ) 234/*! \fn void OContact::setNotes( const QString &str )
235 Sets the notes about the contact to \a str. 235 Sets the notes about the contact to \a str.
236*/ 236*/
237 237
238/*! \fn QString OContact::title() const 238/*! \fn QString OContact::title() const
239 Returns the title of the contact. 239 Returns the title of the contact.
240*/ 240*/
241 241
242/*! \fn QString OContact::firstName() const 242/*! \fn QString OContact::firstName() const
243 Returns the first name of the contact. 243 Returns the first name of the contact.
244*/ 244*/
245 245
246/*! \fn QString OContact::middleName() const 246/*! \fn QString OContact::middleName() const
247 Returns the middle name of the contact. 247 Returns the middle name of the contact.
248*/ 248*/
249 249
250/*! \fn QString OContact::lastName() const 250/*! \fn QString OContact::lastName() const
251 Returns the last name of the contact. 251 Returns the last name of the contact.
252*/ 252*/
253 253
254/*! \fn QString OContact::suffix() const 254/*! \fn QString OContact::suffix() const
255 Returns the suffix of the contact. 255 Returns the suffix of the contact.
256*/ 256*/
257 257
258/*! \fn QString OContact::fileAs() const 258/*! \fn QString OContact::fileAs() const
259 Returns the string the contact is filed as. 259 Returns the string the contact is filed as.
260*/ 260*/
261 261
262/*! \fn QString OContact::defaultEmail() const 262/*! \fn QString OContact::defaultEmail() const
263 Returns the default email address of the contact. 263 Returns the default email address of the contact.
264*/ 264*/
265 265
266/*! \fn QString OContact::emails() const 266/*! \fn QString OContact::emails() const
267 Returns the list of email address for a contact separated by ';'s in a single 267 Returns the list of email address for a contact separated by ';'s in a single
268 string. 268 string.
269*/ 269*/
270 270
271/*! \fn QString OContact::homeStreet() const 271/*! \fn QString OContact::homeStreet() const
272 Returns the home street address of the contact. 272 Returns the home street address of the contact.
273*/ 273*/
274 274
275/*! \fn QString OContact::homeCity() const 275/*! \fn QString OContact::homeCity() const
276 Returns the home city of the contact. 276 Returns the home city of the contact.
277*/ 277*/
278 278
279/*! \fn QString OContact::homeState() const 279/*! \fn QString OContact::homeState() const
280 Returns the home state of the contact. 280 Returns the home state of the contact.
281*/ 281*/
282 282
283/*! \fn QString OContact::homeZip() const 283/*! \fn QString OContact::homeZip() const
284 Returns the home zip of the contact. 284 Returns the home zip of the contact.
285*/ 285*/
286 286
287/*! \fn QString OContact::homeCountry() const 287/*! \fn QString OContact::homeCountry() const
288 Returns the home country of the contact. 288 Returns the home country of the contact.
289*/ 289*/
290 290
291/*! \fn QString OContact::homePhone() const 291/*! \fn QString OContact::homePhone() const
292 Returns the home phone number of the contact. 292 Returns the home phone number of the contact.
293*/ 293*/
294 294
295/*! \fn QString OContact::homeFax() const 295/*! \fn QString OContact::homeFax() const
296 Returns the home fax number of the contact. 296 Returns the home fax number of the contact.
297*/ 297*/
298 298
299/*! \fn QString OContact::homeMobile() const 299/*! \fn QString OContact::homeMobile() const
300 Returns the home mobile number of the contact. 300 Returns the home mobile number of the contact.
301*/ 301*/
302 302
303/*! \fn QString OContact::homeWebpage() const 303/*! \fn QString OContact::homeWebpage() const
304 Returns the home webpage of the contact. 304 Returns the home webpage of the contact.
305*/ 305*/
306 306
307/*! \fn QString OContact::company() const 307/*! \fn QString OContact::company() const
308 Returns the company for the contact. 308 Returns the company for the contact.
309*/ 309*/
310 310
311/*! \fn QString OContact::department() const 311/*! \fn QString OContact::department() const
312 Returns the department for the contact. 312 Returns the department for the contact.
313*/ 313*/
314 314
315/*! \fn QString OContact::office() const 315/*! \fn QString OContact::office() const
316 Returns the office for the contact. 316 Returns the office for the contact.
317*/ 317*/
318 318
319/*! \fn QString OContact::jobTitle() const 319/*! \fn QString OContact::jobTitle() const
320 Returns the job title of the contact. 320 Returns the job title of the contact.
321*/ 321*/
322 322
323/*! \fn QString OContact::profession() const 323/*! \fn QString OContact::profession() const
324 Returns the profession of the contact. 324 Returns the profession of the contact.
325*/ 325*/
326 326
327/*! \fn QString OContact::assistant() const 327/*! \fn QString OContact::assistant() const
328 Returns the assistant of the contact. 328 Returns the assistant of the contact.
329*/ 329*/
330 330
331/*! \fn QString OContact::manager() const 331/*! \fn QString OContact::manager() const
332 Returns the manager of the contact. 332 Returns the manager of the contact.
333*/ 333*/
334 334
335/*! \fn QString OContact::businessStreet() const 335/*! \fn QString OContact::businessStreet() const
336 Returns the business street address of the contact. 336 Returns the business street address of the contact.
337*/ 337*/
338 338
339/*! \fn QString OContact::businessCity() const 339/*! \fn QString OContact::businessCity() const
340 Returns the business city of the contact. 340 Returns the business city of the contact.
341*/ 341*/
342 342
343/*! \fn QString OContact::businessState() const 343/*! \fn QString OContact::businessState() const
344 Returns the business state of the contact. 344 Returns the business state of the contact.
345*/ 345*/
346 346
347/*! \fn QString OContact::businessZip() const 347/*! \fn QString OContact::businessZip() const
348 Returns the business zip of the contact. 348 Returns the business zip of the contact.
349*/ 349*/
350 350
351/*! \fn QString OContact::businessCountry() const 351/*! \fn QString OContact::businessCountry() const
352 Returns the business country of the contact. 352 Returns the business country of the contact.
353*/ 353*/
354 354
355/*! \fn QString OContact::businessPhone() const 355/*! \fn QString OContact::businessPhone() const
356 Returns the business phone number of the contact. 356 Returns the business phone number of the contact.
357*/ 357*/
358 358
359/*! \fn QString OContact::businessFax() const 359/*! \fn QString OContact::businessFax() const
360 Returns the business fax number of the contact. 360 Returns the business fax number of the contact.
361*/ 361*/
362 362
363/*! \fn QString OContact::businessMobile() const 363/*! \fn QString OContact::businessMobile() const
364 Returns the business mobile number of the contact. 364 Returns the business mobile number of the contact.
365*/ 365*/
366 366
367/*! \fn QString OContact::businessPager() const 367/*! \fn QString OContact::businessPager() const
368 Returns the business pager number of the contact. 368 Returns the business pager number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OContact::businessWebpage() const 371/*! \fn QString OContact::businessWebpage() const
372 Returns the business webpage of the contact. 372 Returns the business webpage of the contact.
373*/ 373*/
374 374
375/*! \fn QString OContact::spouse() const 375/*! \fn QString OContact::spouse() const
376 Returns the spouse of the contact. 376 Returns the spouse of the contact.
377*/ 377*/
378 378
379/*! \fn QString OContact::gender() const 379/*! \fn QString OContact::gender() const
380 Returns the gender of the contact. 380 Returns the gender of the contact.
381*/ 381*/
382 382
383/*! \fn QString OContact::nickname() const 383/*! \fn QString OContact::nickname() const
384 Returns the nickname of the contact. 384 Returns the nickname of the contact.
385*/ 385*/
386 386
387/*! \fn QString OContact::children() const 387/*! \fn QString OContact::children() const
388 Returns the children of the contact. 388 Returns the children of the contact.
389*/ 389*/
390 390
391/*! \fn QString OContact::notes() const 391/*! \fn QString OContact::notes() const
392 Returns the notes relating to the the contact. 392 Returns the notes relating to the the contact.
393*/ 393*/
394 394
395/*! \fn QString OContact::groups() const 395/*! \fn QString OContact::groups() const
396 \internal 396 \internal
397 Returns the groups for the contact. 397 Returns the groups for the contact.
398*/ 398*/
399 399
400/*! \fn QStringList OContact::groupList() const 400/*! \fn QStringList OContact::groupList() const
401 \internal 401 \internal
402*/ 402*/
403 403
404/*! \fn QString OContact::field(int) const 404/*! \fn QString OContact::field(int) const
405 \internal 405 \internal
406*/ 406*/
407 407
408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
409 \internal 409 \internal
410*/ 410*/
411 411
412/*! \fn void OContact::setUid( int id ) 412/*! \fn void OContact::setUid( int id )
413 \internal 413 \internal
414 Sets the uid for this record to \a id. 414 Sets the uid for this record to \a id.
415*/ 415*/
416 416
417/*! \enum OContact::journal_action 417/*! \enum OContact::journal_action
418 \internal 418 \internal
419*/ 419*/
420 420
421/*! 421/*!
422 \internal 422 \internal
423*/ 423*/
424QMap<int, QString> OContact::toMap() const 424QMap<int, QString> OContact::toMap() const
425{ 425{
426 QMap<int, QString> map = mMap; 426 QMap<int, QString> map = mMap;
427 QString cats = idsToString( categories() ); 427 QString cats = idsToString( categories() );
428 if ( !cats.isEmpty() ) 428 if ( !cats.isEmpty() )
429 map.insert( Qtopia::AddressCategory, cats ); 429 map.insert( Qtopia::AddressCategory, cats );
430 return map; 430 return map;
431} 431}
432 432
433/*! 433/*!
434 Returns a rich text formatted QString representing the contents the contact. 434 Returns a rich text formatted QString representing the contents the contact.
435*/ 435*/
436QString OContact::toRichText() const 436QString OContact::toRichText() const
437{ 437{
438 QString text; 438 QString text;
439 QString value, comp, state; 439 QString value, comp, state;
440 QString str; 440 QString str;
441 bool marker = false; 441 bool marker = false;
442 442
443 // name, jobtitle and company 443 // name, jobtitle and company
444 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
446 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
447 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
448 448
449 comp = company(); 449 comp = company();
450 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
451 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
452 if ( comp ) 452 if ( comp )
453 text += ", "; 453 text += ", ";
454 else 454 else
455 text += "<br>"; 455 text += "<br>";
456 } 456 }
457 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
458 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
459 459
460 QString defEmail = defaultEmail(); 460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() ) 461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>" 462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>"; 463 + Qtopia::escapeString(defEmail) + "<br>";
464 464
465 text += "<hr>"; 465 text += "<hr>";
466 466
467 // business address 467 // business address
468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
470 text += "<br>"; 470 text += "<br>";
471 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
472 text += "<br>"; 472 text += "<br>";
473 marker = true; 473 marker = true;
474 } 474 }
475 475
476 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
478 state = businessState(); 478 state = businessState();
479 if ( !(value = businessZip()).isEmpty() ) 479 if ( !(value = businessZip()).isEmpty() )
480 text += Qtopia::escapeString(value) + " "; 480 text += Qtopia::escapeString(value) + " ";
481 if ( !(value = businessCity()).isEmpty() ) { 481 if ( !(value = businessCity()).isEmpty() ) {
482 text += Qtopia::escapeString(value); 482 text += Qtopia::escapeString(value);
483 if ( state ) 483 if ( state )
484 text += ", " + Qtopia::escapeString(state); 484 text += ", " + Qtopia::escapeString(state);
485 text += "<br>"; 485 text += "<br>";
486 } else if ( !state.isEmpty() ) 486 } else if ( !state.isEmpty() )
487 text += Qtopia::escapeString(state) + "<br>"; 487 text += Qtopia::escapeString(state) + "<br>";
488 488
489 if ( !(value = businessCountry()).isEmpty() ) 489 if ( !(value = businessCountry()).isEmpty() )
490 text += Qtopia::escapeString(value) + "<br>"; 490 text += Qtopia::escapeString(value) + "<br>";
491 491
492 // rest of Business data 492 // rest of Business data
493 str = office(); 493 str = office();
494 if ( !str.isEmpty() ){ 494 if ( !str.isEmpty() ){
495 text += "<b>" + QObject::tr("Office: ") + "</b>" 495 text += "<b>" + QObject::tr("Office: ") + "</b>"
496 + Qtopia::escapeString(str) + "<br>"; 496 + Qtopia::escapeString(str) + "<br>";
497 marker = true; 497 marker = true;
498 } 498 }
499 str = businessWebpage(); 499 str = businessWebpage();
500 if ( !str.isEmpty() ){ 500 if ( !str.isEmpty() ){
501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
502 + Qtopia::escapeString(str) + "<br>"; 502 + Qtopia::escapeString(str) + "<br>";
503 marker = true; 503 marker = true;
504 } 504 }
505 str = businessPhone(); 505 str = businessPhone();
506 if ( !str.isEmpty() ){ 506 if ( !str.isEmpty() ){
507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
508 + Qtopia::escapeString(str) + "<br>"; 508 + Qtopia::escapeString(str) + "<br>";
509 marker = true; 509 marker = true;
510 } 510 }
511 str = businessFax(); 511 str = businessFax();
512 if ( !str.isEmpty() ){ 512 if ( !str.isEmpty() ){
513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
514 + Qtopia::escapeString(str) + "<br>"; 514 + Qtopia::escapeString(str) + "<br>";
515 marker = true; 515 marker = true;
516 } 516 }
517 str = businessMobile(); 517 str = businessMobile();
518 if ( !str.isEmpty() ){ 518 if ( !str.isEmpty() ){
519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
520 + Qtopia::escapeString(str) + "<br>"; 520 + Qtopia::escapeString(str) + "<br>";
521 marker = true; 521 marker = true;
522 } 522 }
523 str = businessPager(); 523 str = businessPager();
524 if ( !str.isEmpty() ){ 524 if ( !str.isEmpty() ){
525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
526 + Qtopia::escapeString(str) + "<br>"; 526 + Qtopia::escapeString(str) + "<br>";
527 marker = true; 527 marker = true;
528 } 528 }
529 529
530 // home address 530 // home address
531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
533 text += "<br>"; 533 text += "<br>";
534 text += QObject::tr( "<b>Home Address:</b>" ); 534 text += QObject::tr( "<b>Home Address:</b>" );
535 text += "<br>"; 535 text += "<br>";
536 } 536 }
537 537
538 if ( !(value = homeStreet()).isEmpty() ) 538 if ( !(value = homeStreet()).isEmpty() )
539 text += Qtopia::escapeString(value) + "<br>"; 539 text += Qtopia::escapeString(value) + "<br>";
540 state = homeState(); 540 state = homeState();
541 if ( !(value = homeZip()).isEmpty() ) 541 if ( !(value = homeZip()).isEmpty() )
542 text += Qtopia::escapeString(value) + " "; 542 text += Qtopia::escapeString(value) + " ";
543 if ( !(value = homeCity()).isEmpty() ) { 543 if ( !(value = homeCity()).isEmpty() ) {
544 text += Qtopia::escapeString(value); 544 text += Qtopia::escapeString(value);
545 if ( !state.isEmpty() ) 545 if ( !state.isEmpty() )
546 text += ", " + Qtopia::escapeString(state); 546 text += ", " + Qtopia::escapeString(state);
547 text += "<br>"; 547 text += "<br>";
548 } else if (!state.isEmpty()) 548 } else if (!state.isEmpty())
549 text += Qtopia::escapeString(state) + "<br>"; 549 text += Qtopia::escapeString(state) + "<br>";
550 if ( !(value = homeCountry()).isEmpty() ) 550 if ( !(value = homeCountry()).isEmpty() )
551 text += Qtopia::escapeString(value) + "<br>"; 551 text += Qtopia::escapeString(value) + "<br>";
552 552
553 // rest of Home data 553 // rest of Home data
554 str = homeWebpage(); 554 str = homeWebpage();
555 if ( !str.isEmpty() ){ 555 if ( !str.isEmpty() ){
556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
557 + Qtopia::escapeString(str) + "<br>"; 557 + Qtopia::escapeString(str) + "<br>";
558 marker = true; 558 marker = true;
559 } 559 }
560 str = homePhone(); 560 str = homePhone();
561 if ( !str.isEmpty() ){ 561 if ( !str.isEmpty() ){
562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
563 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
564 marker = true; 564 marker = true;
565 } 565 }
566 str = homeFax(); 566 str = homeFax();
567 if ( !str.isEmpty() ){ 567 if ( !str.isEmpty() ){
568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
569 + Qtopia::escapeString(str) + "<br>"; 569 + Qtopia::escapeString(str) + "<br>";
570 marker = true; 570 marker = true;
571 } 571 }
572 str = homeMobile(); 572 str = homeMobile();
573 if ( !str.isEmpty() ){ 573 if ( !str.isEmpty() ){
574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
575 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
576 marker = true; 576 marker = true;
577 } 577 }
578 578
579 if ( marker ) 579 if ( marker )
580 text += "<br><hr><br>"; 580 text += "<br><hr><br>";
581 // the others... 581 // the others...
582 str = emails(); 582 str = emails();
583 if ( !str.isEmpty() && ( str != defEmail ) ) 583 if ( !str.isEmpty() && ( str != defEmail ) )
584 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 584 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
585 + Qtopia::escapeString(str) + "<br>"; 585 + Qtopia::escapeString(str) + "<br>";
586 str = profession(); 586 str = profession();
587 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
588 text += "<b>" + QObject::tr("Profession: ") + "</b>" 588 text += "<b>" + QObject::tr("Profession: ") + "</b>"
589 + Qtopia::escapeString(str) + "<br>"; 589 + Qtopia::escapeString(str) + "<br>";
590 str = assistant(); 590 str = assistant();
591 if ( !str.isEmpty() ) 591 if ( !str.isEmpty() )
592 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 592 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
593 + Qtopia::escapeString(str) + "<br>"; 593 + Qtopia::escapeString(str) + "<br>";
594 str = manager(); 594 str = manager();
595 if ( !str.isEmpty() ) 595 if ( !str.isEmpty() )
596 text += "<b>" + QObject::tr("Manager: ") + "</b>" 596 text += "<b>" + QObject::tr("Manager: ") + "</b>"
597 + Qtopia::escapeString(str) + "<br>"; 597 + Qtopia::escapeString(str) + "<br>";
598 str = gender(); 598 str = gender();
599 if ( !str.isEmpty() && str.toInt() != 0 ) { 599 if ( !str.isEmpty() && str.toInt() != 0 ) {
600 if ( str.toInt() == 1 ) 600 if ( str.toInt() == 1 )
601 str = QObject::tr( "Male" ); 601 str = QObject::tr( "Male" );
602 else if ( str.toInt() == 2 ) 602 else if ( str.toInt() == 2 )
603 str = QObject::tr( "Female" ); 603 str = QObject::tr( "Female" );
604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
605 } 605 }
606 str = spouse(); 606 str = spouse();
607 if ( !str.isEmpty() ) 607 if ( !str.isEmpty() )
608 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 608 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
609 + Qtopia::escapeString(str) + "<br>"; 609 + Qtopia::escapeString(str) + "<br>";
610 if ( birthday().isValid() ){ 610 if ( birthday().isValid() ){
611 str = TimeString::numberDateString( birthday() ); 611 str = TimeString::numberDateString( birthday() );
612 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 612 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
613 + Qtopia::escapeString(str) + "<br>"; 613 + Qtopia::escapeString(str) + "<br>";
614 } 614 }
615 if ( anniversary().isValid() ){ 615 if ( anniversary().isValid() ){
616 str = TimeString::numberDateString( anniversary() ); 616 str = TimeString::numberDateString( anniversary() );
617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
618 + Qtopia::escapeString(str) + "<br>"; 618 + Qtopia::escapeString(str) + "<br>";
619 } 619 }
620 str = children(); 620 str = children();
621 if ( !str.isEmpty() ) 621 if ( !str.isEmpty() )
622 text += "<b>" + QObject::tr("Children: ") + "</b>" 622 text += "<b>" + QObject::tr("Children: ") + "</b>"
623 + Qtopia::escapeString(str) + "<br>"; 623 + Qtopia::escapeString(str) + "<br>";
624 624
625 str = nickname(); 625 str = nickname();
626 if ( !str.isEmpty() ) 626 if ( !str.isEmpty() )
627 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 627 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
628 + Qtopia::escapeString(str) + "<br>"; 628 + Qtopia::escapeString(str) + "<br>";
629 629
630 if ( categoryNames().count() ){ 630 if ( categoryNames("Contacts").count() ){
631 text += "<b>" + QObject::tr( "Category:") + "</b> "; 631 text += "<b>" + QObject::tr( "Category:") + "</b> ";
632 text += categoryNames().join(", "); 632 text += categoryNames("Contacts").join(", ");
633 text += "<br>"; 633 text += "<br>";
634 } 634 }
635 635
636 // notes last 636 // notes last
637 if ( !(value = notes()).isEmpty() ) { 637 if ( !(value = notes()).isEmpty() ) {
638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
639 QRegExp reg("\n"); 639 QRegExp reg("\n");
640 640
641 //QString tmp = Qtopia::escapeString(value); 641 //QString tmp = Qtopia::escapeString(value);
642 QString tmp = QStyleSheet::convertFromPlainText(value); 642 QString tmp = QStyleSheet::convertFromPlainText(value);
643 //tmp.replace( reg, "<br>" ); 643 //tmp.replace( reg, "<br>" );
644 text += "<br>" + tmp + "<br>"; 644 text += "<br>" + tmp + "<br>";
645 } 645 }
646 return text; 646 return text;
647} 647}
648 648
649/*! 649/*!
650 \internal 650 \internal
651*/ 651*/
652void OContact::insert( int key, const QString &v ) 652void OContact::insert( int key, const QString &v )
653{ 653{
654 QString value = v.stripWhiteSpace(); 654 QString value = v.stripWhiteSpace();
655 if ( value.isEmpty() ) 655 if ( value.isEmpty() )
656 mMap.remove( key ); 656 mMap.remove( key );
657 else 657 else
658 mMap.insert( key, value ); 658 mMap.insert( key, value );
659} 659}
660 660
661/*! 661/*!
662 \internal 662 \internal
663*/ 663*/
664void OContact::replace( int key, const QString & v ) 664void OContact::replace( int key, const QString & v )
665{ 665{
666 QString value = v.stripWhiteSpace(); 666 QString value = v.stripWhiteSpace();
667 if ( value.isEmpty() ) 667 if ( value.isEmpty() )
668 mMap.remove( key ); 668 mMap.remove( key );
669 else 669 else
670 mMap.replace( key, value ); 670 mMap.replace( key, value );
671} 671}
672 672
673/*! 673/*!
674 \internal 674 \internal
675*/ 675*/
676QString OContact::find( int key ) const 676QString OContact::find( int key ) const
677{ 677{
678 return mMap[key]; 678 return mMap[key];
679} 679}
680 680
681/*! 681/*!
682 \internal 682 \internal
683*/ 683*/
684QString OContact::displayAddress( const QString &street, 684QString OContact::displayAddress( const QString &street,
685 const QString &city, 685 const QString &city,
686 const QString &state, 686 const QString &state,
687 const QString &zip, 687 const QString &zip,
688 const QString &country ) const 688 const QString &country ) const
689{ 689{
690 QString s = street; 690 QString s = street;
691 if ( !street.isEmpty() ) 691 if ( !street.isEmpty() )
692 s+= "\n"; 692 s+= "\n";
693 s += city; 693 s += city;
694 if ( !city.isEmpty() && !state.isEmpty() ) 694 if ( !city.isEmpty() && !state.isEmpty() )
695 s += ", "; 695 s += ", ";
696 s += state; 696 s += state;
697 if ( !state.isEmpty() && !zip.isEmpty() ) 697 if ( !state.isEmpty() && !zip.isEmpty() )
698 s += " "; 698 s += " ";
699 s += zip; 699 s += zip;
700 if ( !country.isEmpty() && !s.isEmpty() ) 700 if ( !country.isEmpty() && !s.isEmpty() )
701 s += "\n"; 701 s += "\n";
702 s += country; 702 s += country;
703 return s; 703 return s;
704} 704}
705 705
706/*! 706/*!
707 \internal 707 \internal
708*/ 708*/
709QString OContact::displayBusinessAddress() const 709QString OContact::displayBusinessAddress() const
710{ 710{
711 return displayAddress( businessStreet(), businessCity(), 711 return displayAddress( businessStreet(), businessCity(),
712 businessState(), businessZip(), 712 businessState(), businessZip(),
713 businessCountry() ); 713 businessCountry() );
714} 714}
715 715
716/*! 716/*!
717 \internal 717 \internal
718*/ 718*/
719QString OContact::displayHomeAddress() const 719QString OContact::displayHomeAddress() const
720{ 720{
721 return displayAddress( homeStreet(), homeCity(), 721 return displayAddress( homeStreet(), homeCity(),
722 homeState(), homeZip(), 722 homeState(), homeZip(),
723 homeCountry() ); 723 homeCountry() );
724} 724}
725 725
726/*! 726/*!
727 Returns the full name of the contact 727 Returns the full name of the contact
728*/ 728*/
729QString OContact::fullName() const 729QString OContact::fullName() const
730{ 730{
731 QString title = find( Qtopia::Title ); 731 QString title = find( Qtopia::Title );
732 QString firstName = find( Qtopia::FirstName ); 732 QString firstName = find( Qtopia::FirstName );
733 QString middleName = find( Qtopia::MiddleName ); 733 QString middleName = find( Qtopia::MiddleName );
734 QString lastName = find( Qtopia::LastName ); 734 QString lastName = find( Qtopia::LastName );
735 QString suffix = find( Qtopia::Suffix ); 735 QString suffix = find( Qtopia::Suffix );
736 736
737 QString name = title; 737 QString name = title;
738 if ( !firstName.isEmpty() ) { 738 if ( !firstName.isEmpty() ) {
739 if ( !name.isEmpty() ) 739 if ( !name.isEmpty() )
740 name += " "; 740 name += " ";
741 name += firstName; 741 name += firstName;
742 } 742 }
743 if ( !middleName.isEmpty() ) { 743 if ( !middleName.isEmpty() ) {
744 if ( !name.isEmpty() ) 744 if ( !name.isEmpty() )
745 name += " "; 745 name += " ";
746 name += middleName; 746 name += middleName;
747 } 747 }
748 if ( !lastName.isEmpty() ) { 748 if ( !lastName.isEmpty() ) {
749 if ( !name.isEmpty() ) 749 if ( !name.isEmpty() )
750 name += " "; 750 name += " ";
751 name += lastName; 751 name += lastName;
752 } 752 }
753 if ( !suffix.isEmpty() ) { 753 if ( !suffix.isEmpty() ) {
754 if ( !name.isEmpty() ) 754 if ( !name.isEmpty() )
755 name += " "; 755 name += " ";
756 name += suffix; 756 name += suffix;
757 } 757 }
758 return name.simplifyWhiteSpace(); 758 return name.simplifyWhiteSpace();
759} 759}
760 760
761/*! 761/*!
762 Returns a list of the names of the children of the contact. 762 Returns a list of the names of the children of the contact.
763*/ 763*/
764QStringList OContact::childrenList() const 764QStringList OContact::childrenList() const
765{ 765{
766 return QStringList::split( " ", find( Qtopia::Children ) ); 766 return QStringList::split( " ", find( Qtopia::Children ) );
767} 767}
768 768
769/*! \fn void OContact::insertEmail( const QString &email ) 769/*! \fn void OContact::insertEmail( const QString &email )
770 770
771 Insert \a email into the email list. Ensures \a email can only be added 771 Insert \a email into the email list. Ensures \a email can only be added
772 once. If there is no default email address set, it sets it to the \a email. 772 once. If there is no default email address set, it sets it to the \a email.
773*/ 773*/
774 774
775/*! \fn void OContact::removeEmail( const QString &email ) 775/*! \fn void OContact::removeEmail( const QString &email )
776 776
777 Removes the \a email from the email list. If the default email was \a email, 777 Removes the \a email from the email list. If the default email was \a email,
778 then the default email address is assigned to the first email in the 778 then the default email address is assigned to the first email in the
779 email list 779 email list
780*/ 780*/
781 781
782/*! \fn void OContact::clearEmails() 782/*! \fn void OContact::clearEmails()
783 783
784 Clears the email list. 784 Clears the email list.
785 */ 785 */
786 786
787/*! \fn void OContact::insertEmails( const QStringList &emailList ) 787/*! \fn void OContact::insertEmails( const QStringList &emailList )
788 788
789 Appends the \a emailList to the exiting email list 789 Appends the \a emailList to the exiting email list
790 */ 790 */
791 791
792/*! 792/*!
793 Returns a list of email addresses belonging to the contact, including 793 Returns a list of email addresses belonging to the contact, including
794 the default email address. 794 the default email address.
795*/ 795*/
796QStringList OContact::emailList() const 796QStringList OContact::emailList() const
797{ 797{
798 QString emailStr = emails(); 798 QString emailStr = emails();
799 799
800 QStringList r; 800 QStringList r;
801 if ( !emailStr.isEmpty() ) { 801 if ( !emailStr.isEmpty() ) {
802 qDebug(" emailstr "); 802 qDebug(" emailstr ");
803 QStringList l = QStringList::split( emailSeparator(), emailStr ); 803 QStringList l = QStringList::split( emailSeparator(), emailStr );
804 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 804 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
805 r += (*it).simplifyWhiteSpace(); 805 r += (*it).simplifyWhiteSpace();
806 } 806 }
807 807
808 return r; 808 return r;
809} 809}
810 810
811/*! 811/*!
812 \overload 812 \overload
813 813
814 Generates the string for the contact to be filed as from the first, 814 Generates the string for the contact to be filed as from the first,
815 middle and last name of the contact. 815 middle and last name of the contact.
816*/ 816*/
817void OContact::setFileAs() 817void OContact::setFileAs()
818{ 818{
819 QString lastName, firstName, middleName, fileas; 819 QString lastName, firstName, middleName, fileas;
820 820
821 lastName = find( Qtopia::LastName ); 821 lastName = find( Qtopia::LastName );
822 firstName = find( Qtopia::FirstName ); 822 firstName = find( Qtopia::FirstName );
823 middleName = find( Qtopia::MiddleName ); 823 middleName = find( Qtopia::MiddleName );
824 if ( !lastName.isEmpty() && !firstName.isEmpty() 824 if ( !lastName.isEmpty() && !firstName.isEmpty()
825 && !middleName.isEmpty() ) 825 && !middleName.isEmpty() )
826 fileas = lastName + ", " + firstName + " " + middleName; 826 fileas = lastName + ", " + firstName + " " + middleName;
827 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 827 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
828 fileas = lastName + ", " + firstName; 828 fileas = lastName + ", " + firstName;
829 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 829 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
830 !middleName.isEmpty() ) 830 !middleName.isEmpty() )
831 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 831 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
832 + middleName + ( middleName.isEmpty() ? "" : " " ) 832 + middleName + ( middleName.isEmpty() ? "" : " " )
833 + lastName; 833 + lastName;
834 834
835 replace( Qtopia::FileAs, fileas ); 835 replace( Qtopia::FileAs, fileas );
836} 836}
837 837
838/*! 838/*!
839 \internal 839 \internal
840 Appends the contact information to \a buf. 840 Appends the contact information to \a buf.
841*/ 841*/
842void OContact::save( QString &buf ) const 842void OContact::save( QString &buf ) const
843{ 843{
844 static const QStringList SLFIELDS = fields(); 844 static const QStringList SLFIELDS = fields();
845 // I'm expecting "<Contact " in front of this... 845 // I'm expecting "<Contact " in front of this...
846 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 846 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
847 it != mMap.end(); ++it ) { 847 it != mMap.end(); ++it ) {
848 const QString &value = it.data(); 848 const QString &value = it.data();
849 int key = it.key(); 849 int key = it.key();
850 if ( !value.isEmpty() ) { 850 if ( !value.isEmpty() ) {
851 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 851 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
852 continue; 852 continue;
853 853
854 key -= Qtopia::AddressCategory+1; 854 key -= Qtopia::AddressCategory+1;
855 buf += SLFIELDS[key]; 855 buf += SLFIELDS[key];
856 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 856 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
857 } 857 }
858 } 858 }
859 buf += customToXml(); 859 buf += customToXml();
860 if ( categories().count() > 0 ) 860 if ( categories().count() > 0 )
861 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 861 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
862 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 862 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
863 // You need to close this yourself 863 // You need to close this yourself
864} 864}
865 865
866 866
867/*! 867/*!
868 \internal 868 \internal
869 Returns the list of fields belonging to a contact 869 Returns the list of fields belonging to a contact
870 Never change order of this list ! It has to be regarding 870 Never change order of this list ! It has to be regarding
871 enum AddressBookFields !! 871 enum AddressBookFields !!
872*/ 872*/
873QStringList OContact::fields() 873QStringList OContact::fields()
874{ 874{
875 QStringList list; 875 QStringList list;
876 876
877 list.append( "Title" ); // Not Used! 877 list.append( "Title" ); // Not Used!
878 list.append( "FirstName" ); 878 list.append( "FirstName" );
879 list.append( "MiddleName" ); 879 list.append( "MiddleName" );
880 list.append( "LastName" ); 880 list.append( "LastName" );
881 list.append( "Suffix" ); 881 list.append( "Suffix" );
882 list.append( "FileAs" ); 882 list.append( "FileAs" );
883 883
884 list.append( "JobTitle" ); 884 list.append( "JobTitle" );
885 list.append( "Department" ); 885 list.append( "Department" );
886 list.append( "Company" ); 886 list.append( "Company" );
887 list.append( "BusinessPhone" ); 887 list.append( "BusinessPhone" );
888 list.append( "BusinessFax" ); 888 list.append( "BusinessFax" );
889 list.append( "BusinessMobile" ); 889 list.append( "BusinessMobile" );
890 890
891 list.append( "DefaultEmail" ); 891 list.append( "DefaultEmail" );
892 list.append( "Emails" ); 892 list.append( "Emails" );
893 893
894 list.append( "HomePhone" ); 894 list.append( "HomePhone" );
895 list.append( "HomeFax" ); 895 list.append( "HomeFax" );
896 list.append( "HomeMobile" ); 896 list.append( "HomeMobile" );
897 897
898 list.append( "BusinessStreet" ); 898 list.append( "BusinessStreet" );
899 list.append( "BusinessCity" ); 899 list.append( "BusinessCity" );
900 list.append( "BusinessState" ); 900 list.append( "BusinessState" );
901 list.append( "BusinessZip" ); 901 list.append( "BusinessZip" );
902 list.append( "BusinessCountry" ); 902 list.append( "BusinessCountry" );
903 list.append( "BusinessPager" ); 903 list.append( "BusinessPager" );
904 list.append( "BusinessWebPage" ); 904 list.append( "BusinessWebPage" );
905 905
906 list.append( "Office" ); 906 list.append( "Office" );
907 list.append( "Profession" ); 907 list.append( "Profession" );
908 list.append( "Assistant" ); 908 list.append( "Assistant" );
909 list.append( "Manager" ); 909 list.append( "Manager" );
910 910
911 list.append( "HomeStreet" ); 911 list.append( "HomeStreet" );
912 list.append( "HomeCity" ); 912 list.append( "HomeCity" );
913 list.append( "HomeState" ); 913 list.append( "HomeState" );
914 list.append( "HomeZip" ); 914 list.append( "HomeZip" );
915 list.append( "HomeCountry" ); 915 list.append( "HomeCountry" );
916 list.append( "HomeWebPage" ); 916 list.append( "HomeWebPage" );
917 917
918 list.append( "Spouse" ); 918 list.append( "Spouse" );
919 list.append( "Gender" ); 919 list.append( "Gender" );
920 list.append( "Birthday" ); 920 list.append( "Birthday" );
921 list.append( "Anniversary" ); 921 list.append( "Anniversary" );
922 list.append( "Nickname" ); 922 list.append( "Nickname" );
923 list.append( "Children" ); 923 list.append( "Children" );
924 924
925 list.append( "Notes" ); 925 list.append( "Notes" );
926 list.append( "Groups" ); 926 list.append( "Groups" );
927 927
928 return list; 928 return list;
929} 929}
930 930
931 931
932/*! 932/*!
933 Sets the list of email address for contact to those contained in \a str. 933 Sets the list of email address for contact to those contained in \a str.
934 Email address should be separated by ';'s. 934 Email address should be separated by ';'s.
935*/ 935*/
936void OContact::setEmails( const QString &str ) 936void OContact::setEmails( const QString &str )
937{ 937{
938 replace( Qtopia::Emails, str ); 938 replace( Qtopia::Emails, str );
939 if ( str.isEmpty() ) 939 if ( str.isEmpty() )
940 setDefaultEmail( QString::null ); 940 setDefaultEmail( QString::null );
941} 941}
942 942
943/*! 943/*!
944 Sets the list of children for the contact to those contained in \a str. 944 Sets the list of children for the contact to those contained in \a str.
945*/ 945*/
946void OContact::setChildren( const QString &str ) 946void OContact::setChildren( const QString &str )
947{ 947{
948 replace( Qtopia::Children, str ); 948 replace( Qtopia::Children, str );
949} 949}
950 950
951/*! 951/*!
952 Returns TRUE if the contact matches the regular expression \a regexp. 952 Returns TRUE if the contact matches the regular expression \a regexp.
953 Otherwise returns FALSE. 953 Otherwise returns FALSE.
954*/ 954*/
955bool OContact::match( const QString &regexp ) const 955bool OContact::match( const QString &regexp ) const
956{ 956{
957 return match(QRegExp(regexp)); 957 return match(QRegExp(regexp));
958} 958}
959 959
960/*! 960/*!
961 \overload 961 \overload
962 Returns TRUE if the contact matches the regular expression \a regexp. 962 Returns TRUE if the contact matches the regular expression \a regexp.
963 Otherwise returns FALSE. 963 Otherwise returns FALSE.
964*/ 964*/
965bool OContact::match( const QRegExp &r ) const 965bool OContact::match( const QRegExp &r ) const
966{ 966{
967 bool match; 967 bool match;
968 match = false; 968 match = false;
969 QMap<int, QString>::ConstIterator it; 969 QMap<int, QString>::ConstIterator it;
970 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 970 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
971 if ( (*it).find( r ) > -1 ) { 971 if ( (*it).find( r ) > -1 ) {
972 match = true; 972 match = true;
973 break; 973 break;
974 } 974 }
975 } 975 }
976 return match; 976 return match;
977} 977}
978 978
979 979
980QString OContact::toShortText() const 980QString OContact::toShortText() const
981{ 981{
982 return ( fullName() ); 982 return ( fullName() );
983} 983}
984QString OContact::type() const 984QString OContact::type() const
985{ 985{
986 return QString::fromLatin1( "OContact" ); 986 return QString::fromLatin1( "OContact" );
987} 987}
988 988
989// Definition is missing ! (se) 989// Definition is missing ! (se)
990QMap<QString,QString> OContact::toExtraMap() const 990QMap<QString,QString> OContact::toExtraMap() const
991{ 991{
992 qWarning ("Function not implemented: OContact::toExtraMap()"); 992 qWarning ("Function not implemented: OContact::toExtraMap()");
993 QMap <QString,QString> useless; 993 QMap <QString,QString> useless;
994 return useless; 994 return useless;
995} 995}
996 996
997class QString OContact::recordField( int pos ) const 997class QString OContact::recordField( int pos ) const
998{ 998{
999 QStringList SLFIELDS = fields(); // ?? why this ? (se) 999 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1000 return SLFIELDS[pos]; 1000 return SLFIELDS[pos];
1001} 1001}
1002 1002
1003// In future releases, we should store birthday and anniversary 1003// In future releases, we should store birthday and anniversary
1004// internally as QDate instead of QString ! 1004// internally as QDate instead of QString !
1005// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1005// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1006 1006
1007/*! \fn void OContact::setBirthday( const QDate& date ) 1007/*! \fn void OContact::setBirthday( const QDate& date )
1008 Sets the birthday for the contact to \a date. If date is null 1008 Sets the birthday for the contact to \a date. If date is null
1009 the current stored date will be removed. 1009 the current stored date will be removed.
1010*/ 1010*/
1011void OContact::setBirthday( const QDate &v ) 1011void OContact::setBirthday( const QDate &v )
1012{ 1012{
1013 if ( v.isNull() ){ 1013 if ( v.isNull() ){
1014 qWarning( "Remove Birthday"); 1014 qWarning( "Remove Birthday");
1015 replace( Qtopia::Birthday, QString::null ); 1015 replace( Qtopia::Birthday, QString::null );
1016 return; 1016 return;
1017 } 1017 }
1018 1018
1019 if ( v.isValid() ) 1019 if ( v.isValid() )
1020 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1020 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
1021 1021
1022} 1022}
1023 1023
1024 1024
1025/*! \fn void OContact::setAnniversary( const QDate &date ) 1025/*! \fn void OContact::setAnniversary( const QDate &date )
1026 Sets the anniversary of the contact to \a date. If date is 1026 Sets the anniversary of the contact to \a date. If date is
1027 null, the current stored date will be removed. 1027 null, the current stored date will be removed.
1028*/ 1028*/
1029void OContact::setAnniversary( const QDate &v ) 1029void OContact::setAnniversary( const QDate &v )
1030{ 1030{
1031 if ( v.isNull() ){ 1031 if ( v.isNull() ){
1032 qWarning( "Remove Anniversary"); 1032 qWarning( "Remove Anniversary");
1033 replace( Qtopia::Anniversary, QString::null ); 1033 replace( Qtopia::Anniversary, QString::null );
1034 return; 1034 return;
1035 } 1035 }
1036 1036
1037 if ( v.isValid() ) 1037 if ( v.isValid() )
1038 replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); 1038 replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
1039} 1039}
1040 1040
1041/*! \fn QDate OContact::birthday() const 1041/*! \fn QDate OContact::birthday() const
1042 Returns the birthday of the contact. 1042 Returns the birthday of the contact.
1043*/ 1043*/
1044QDate OContact::birthday() const 1044QDate OContact::birthday() const
1045{ 1045{
1046 QString str = find( Qtopia::Birthday ); 1046 QString str = find( Qtopia::Birthday );
1047 qWarning ("Birthday %s", str.latin1() ); 1047 qWarning ("Birthday %s", str.latin1() );
1048 if ( !str.isEmpty() ) 1048 if ( !str.isEmpty() )
1049 return TimeConversion::fromString ( str ); 1049 return TimeConversion::fromString ( str );
1050 else 1050 else
1051 return QDate(); 1051 return QDate();
1052} 1052}
1053 1053
1054 1054
1055/*! \fn QDate OContact::anniversary() const 1055/*! \fn QDate OContact::anniversary() const
1056 Returns the anniversary of the contact. 1056 Returns the anniversary of the contact.
1057*/ 1057*/
1058QDate OContact::anniversary() const 1058QDate OContact::anniversary() const
1059{ 1059{
1060 QDate empty; 1060 QDate empty;
1061 QString str = find( Qtopia::Anniversary ); 1061 QString str = find( Qtopia::Anniversary );
1062 qWarning ("Anniversary %s", str.latin1() ); 1062 qWarning ("Anniversary %s", str.latin1() );
1063 if ( !str.isEmpty() ) 1063 if ( !str.isEmpty() )
1064 return TimeConversion::fromString ( str ); 1064 return TimeConversion::fromString ( str );
1065 else 1065 else
1066 return empty; 1066 return empty;
1067} 1067}
1068 1068
1069 1069
1070void OContact::insertEmail( const QString &v ) 1070void OContact::insertEmail( const QString &v )
1071{ 1071{
1072 //qDebug("insertEmail %s", v.latin1()); 1072 //qDebug("insertEmail %s", v.latin1());
1073 QString e = v.simplifyWhiteSpace(); 1073 QString e = v.simplifyWhiteSpace();
1074 QString def = defaultEmail(); 1074 QString def = defaultEmail();
1075 1075
1076 // if no default, set it as the default email and don't insert 1076 // if no default, set it as the default email and don't insert
1077 if ( def.isEmpty() ) { 1077 if ( def.isEmpty() ) {
1078 setDefaultEmail( e ); // will insert into the list for us 1078 setDefaultEmail( e ); // will insert into the list for us
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 // otherwise, insert assuming doesn't already exist 1082 // otherwise, insert assuming doesn't already exist
1083 QString emailsStr = find( Qtopia::Emails ); 1083 QString emailsStr = find( Qtopia::Emails );
1084 if ( emailsStr.contains( e )) 1084 if ( emailsStr.contains( e ))
1085 return; 1085 return;
1086 if ( !emailsStr.isEmpty() ) 1086 if ( !emailsStr.isEmpty() )
1087 emailsStr += emailSeparator(); 1087 emailsStr += emailSeparator();
1088 emailsStr += e; 1088 emailsStr += e;
1089 replace( Qtopia::Emails, emailsStr ); 1089 replace( Qtopia::Emails, emailsStr );
1090} 1090}
1091 1091
1092void OContact::removeEmail( const QString &v ) 1092void OContact::removeEmail( const QString &v )
1093{ 1093{
1094 QString e = v.simplifyWhiteSpace(); 1094 QString e = v.simplifyWhiteSpace();
1095 QString def = defaultEmail(); 1095 QString def = defaultEmail();
1096 QString emailsStr = find( Qtopia::Emails ); 1096 QString emailsStr = find( Qtopia::Emails );
1097 QStringList emails = emailList(); 1097 QStringList emails = emailList();
1098 1098
1099 // otherwise, must first contain it 1099 // otherwise, must first contain it
1100 if ( !emailsStr.contains( e ) ) 1100 if ( !emailsStr.contains( e ) )
1101 return; 1101 return;
1102 1102
1103 // remove it 1103 // remove it
1104 //qDebug(" removing email from list %s", e.latin1()); 1104 //qDebug(" removing email from list %s", e.latin1());
1105 emails.remove( e ); 1105 emails.remove( e );
1106 // reset the string 1106 // reset the string
1107 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 1107 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1108 replace( Qtopia::Emails, emailsStr ); 1108 replace( Qtopia::Emails, emailsStr );
1109 1109
1110 // if default, then replace the default email with the first one 1110 // if default, then replace the default email with the first one
1111 if ( def == e ) { 1111 if ( def == e ) {
1112 //qDebug("removeEmail is default; setting new default"); 1112 //qDebug("removeEmail is default; setting new default");
1113 if ( !emails.count() ) 1113 if ( !emails.count() )
1114 clearEmails(); 1114 clearEmails();
1115 else // setDefaultEmail will remove e from the list 1115 else // setDefaultEmail will remove e from the list
1116 setDefaultEmail( emails.first() ); 1116 setDefaultEmail( emails.first() );
1117 } 1117 }
1118} 1118}
1119void OContact::clearEmails() 1119void OContact::clearEmails()
1120{ 1120{
1121 mMap.remove( Qtopia::DefaultEmail ); 1121 mMap.remove( Qtopia::DefaultEmail );
1122 mMap.remove( Qtopia::Emails ); 1122 mMap.remove( Qtopia::Emails );
1123} 1123}
1124void OContact::setDefaultEmail( const QString &v ) 1124void OContact::setDefaultEmail( const QString &v )
1125{ 1125{
1126 QString e = v.simplifyWhiteSpace(); 1126 QString e = v.simplifyWhiteSpace();
1127 1127
1128 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1128 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1129 replace( Qtopia::DefaultEmail, e ); 1129 replace( Qtopia::DefaultEmail, e );
1130 1130
1131 if ( !e.isEmpty() ) 1131 if ( !e.isEmpty() )
1132 insertEmail( e ); 1132 insertEmail( e );
1133 1133
1134} 1134}
1135 1135
1136void OContact::insertEmails( const QStringList &v ) 1136void OContact::insertEmails( const QStringList &v )
1137{ 1137{
1138 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1138 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1139 insertEmail( *it ); 1139 insertEmail( *it );
1140} 1140}
1141int OContact::rtti() { 1141int OContact::rtti() {
1142 return OPimResolver::AddressBook; 1142 return OPimResolver::AddressBook;
1143} 1143}
1144void OContact::setUid( int i ) 1144void OContact::setUid( int i )
1145{ 1145{
1146 OPimRecord::setUid(i); 1146 OPimRecord::setUid(i);
1147 replace( Qtopia::AddressUid , QString::number(i)); 1147 replace( Qtopia::AddressUid , QString::number(i));
1148} 1148}
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index ac0f4a9..d45417a 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,166 +1,166 @@
1#include <qarray.h> 1#include <qarray.h>
2 2
3#include <qpe/categories.h> 3#include <qpe/categories.h>
4#include <qpe/categoryselect.h> 4#include <qpe/categoryselect.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
9 9
10 10
11OPimRecord::OPimRecord( int uid ) 11OPimRecord::OPimRecord( int uid )
12 : Qtopia::Record() { 12 : Qtopia::Record() {
13 13
14 setUid( uid ); 14 setUid( uid );
15} 15}
16OPimRecord::~OPimRecord() { 16OPimRecord::~OPimRecord() {
17} 17}
18OPimRecord::OPimRecord( const OPimRecord& rec ) 18OPimRecord::OPimRecord( const OPimRecord& rec )
19 : Qtopia::Record( rec ) 19 : Qtopia::Record( rec )
20{ 20{
21 (*this) = rec; 21 (*this) = rec;
22} 22}
23 23
24OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 24OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
25 Qtopia::Record::operator=( rec ); 25 Qtopia::Record::operator=( rec );
26 m_xrefman = rec.m_xrefman; 26 m_xrefman = rec.m_xrefman;
27 27
28 return *this; 28 return *this;
29} 29}
30/* 30/*
31 * category names 31 * category names
32 */ 32 */
33QStringList OPimRecord::categoryNames()const { 33QStringList OPimRecord::categoryNames( const QString& appname ) const {
34 QStringList list; 34 QStringList list;
35 QArray<int> cats = categories(); 35 QArray<int> cats = categories();
36 Categories catDB; 36 Categories catDB;
37 catDB.load( categoryFileName() ); 37 catDB.load( categoryFileName() );
38 38
39 for (uint i = 0; i < cats.count(); i++ ) { 39 for (uint i = 0; i < cats.count(); i++ ) {
40 list << catDB.label("Todo List", cats[i] ); 40 list << catDB.label( appname, cats[i] );
41 } 41 }
42 42
43 return list; 43 return list;
44} 44}
45void OPimRecord::setCategoryNames( const QStringList& ) { 45void OPimRecord::setCategoryNames( const QStringList& ) {
46 46
47} 47}
48void OPimRecord::addCategoryName( const QString& ) { 48void OPimRecord::addCategoryName( const QString& ) {
49 Categories catDB; 49 Categories catDB;
50 catDB.load( categoryFileName() ); 50 catDB.load( categoryFileName() );
51 51
52 52
53} 53}
54bool OPimRecord::isEmpty()const { 54bool OPimRecord::isEmpty()const {
55 return ( uid() == 0 ); 55 return ( uid() == 0 );
56} 56}
57/*QString OPimRecord::crossToString()const { 57/*QString OPimRecord::crossToString()const {
58 QString str; 58 QString str;
59 QMap<QString, QArray<int> >::ConstIterator it; 59 QMap<QString, QArray<int> >::ConstIterator it;
60 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 60 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
61 QArray<int> id = it.data(); 61 QArray<int> id = it.data();
62 for ( uint i = 0; i < id.size(); ++i ) { 62 for ( uint i = 0; i < id.size(); ++i ) {
63 str += it.key() + "," + QString::number( i ) + ";"; 63 str += it.key() + "," + QString::number( i ) + ";";
64 } 64 }
65 } 65 }
66 str = str.remove( str.length()-1, 1); // strip the ; 66 str = str.remove( str.length()-1, 1); // strip the ;
67 //qWarning("IDS " + str ); 67 //qWarning("IDS " + str );
68 68
69 return str; 69 return str;
70 }*/ 70 }*/
71/* if uid = 1 assign a new one */ 71/* if uid = 1 assign a new one */
72void OPimRecord::setUid( int uid ) { 72void OPimRecord::setUid( int uid ) {
73 if ( uid == 1) 73 if ( uid == 1)
74 uid = uidGen().generate(); 74 uid = uidGen().generate();
75 75
76 Qtopia::Record::setUid( uid ); 76 Qtopia::Record::setUid( uid );
77}; 77};
78Qtopia::UidGen &OPimRecord::uidGen() { 78Qtopia::UidGen &OPimRecord::uidGen() {
79 return m_uidGen; 79 return m_uidGen;
80} 80}
81OPimXRefManager &OPimRecord::xrefmanager() { 81OPimXRefManager &OPimRecord::xrefmanager() {
82 return m_xrefman; 82 return m_xrefman;
83} 83}
84int OPimRecord::rtti(){ 84int OPimRecord::rtti(){
85 return 0; 85 return 0;
86} 86}
87 87
88/** 88/**
89 * now let's put our data into the stream 89 * now let's put our data into the stream
90 */ 90 */
91/* 91/*
92 * First read UID 92 * First read UID
93 * Categories 93 * Categories
94 * XRef 94 * XRef
95 */ 95 */
96bool OPimRecord::loadFromStream( QDataStream& stream ) { 96bool OPimRecord::loadFromStream( QDataStream& stream ) {
97 int Int; 97 int Int;
98 uint UInt; 98 uint UInt;
99 stream >> Int; 99 stream >> Int;
100 setUid(Int); 100 setUid(Int);
101 101
102 /** Categories */ 102 /** Categories */
103 stream >> UInt; 103 stream >> UInt;
104 QArray<int> array(UInt); 104 QArray<int> array(UInt);
105 for (uint i = 0; i < UInt; i++ ) { 105 for (uint i = 0; i < UInt; i++ ) {
106 stream >> array[i]; 106 stream >> array[i];
107 } 107 }
108 setCategories( array ); 108 setCategories( array );
109 109
110 /* 110 /*
111 * now we do the X-Ref stuff 111 * now we do the X-Ref stuff
112 */ 112 */
113 OPimXRef xref; 113 OPimXRef xref;
114 stream >> UInt; 114 stream >> UInt;
115 for ( uint i = 0; i < UInt; i++ ) { 115 for ( uint i = 0; i < UInt; i++ ) {
116 xref.setPartner( OPimXRef::One, partner( stream ) ); 116 xref.setPartner( OPimXRef::One, partner( stream ) );
117 xref.setPartner( OPimXRef::Two, partner( stream ) ); 117 xref.setPartner( OPimXRef::Two, partner( stream ) );
118 m_xrefman.add( xref ); 118 m_xrefman.add( xref );
119 } 119 }
120 120
121 return true; 121 return true;
122} 122}
123bool OPimRecord::saveToStream( QDataStream& stream )const { 123bool OPimRecord::saveToStream( QDataStream& stream )const {
124 /** UIDs */ 124 /** UIDs */
125 125
126 stream << uid(); 126 stream << uid();
127 127
128 /** Categories */ 128 /** Categories */
129 stream << categories().count(); 129 stream << categories().count();
130 for ( uint i = 0; i < categories().count(); i++ ) { 130 for ( uint i = 0; i < categories().count(); i++ ) {
131 stream << categories()[i]; 131 stream << categories()[i];
132 } 132 }
133 133
134 /* 134 /*
135 * first the XRef count 135 * first the XRef count
136 * then the xrefs 136 * then the xrefs
137 */ 137 */
138 stream << m_xrefman.list().count(); 138 stream << m_xrefman.list().count();
139 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 139 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
140 it != m_xrefman.list().end(); ++it ) { 140 it != m_xrefman.list().end(); ++it ) {
141 flush( (*it).partner( OPimXRef::One), stream ); 141 flush( (*it).partner( OPimXRef::One), stream );
142 flush( (*it).partner( OPimXRef::Two), stream ); 142 flush( (*it).partner( OPimXRef::Two), stream );
143 } 143 }
144 return true; 144 return true;
145} 145}
146void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 146void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
147 str << par.service(); 147 str << par.service();
148 str << par.uid(); 148 str << par.uid();
149 str << par.field(); 149 str << par.field();
150} 150}
151OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 151OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
152 OPimXRefPartner par; 152 OPimXRefPartner par;
153 QString str; 153 QString str;
154 int i; 154 int i;
155 155
156 stream >> str; 156 stream >> str;
157 par.setService( str ); 157 par.setService( str );
158 158
159 stream >> i; 159 stream >> i;
160 par.setUid( i ); 160 par.setUid( i );
161 161
162 stream >> i ; 162 stream >> i ;
163 par.setField( i ); 163 par.setField( i );
164 164
165 return par; 165 return par;
166} 166}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index 665530f..c7f9460 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -1,134 +1,134 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qdatastream.h> 4#include <qdatastream.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10 10
11#include <opie/opimxrefmanager.h> 11#include <opie/opimxrefmanager.h>
12 12
13/** 13/**
14 * This is the base class for 14 * This is the base class for
15 * all PIM Records 15 * all PIM Records
16 * 16 *
17 */ 17 */
18class OPimRecord : public Qtopia::Record { 18class OPimRecord : public Qtopia::Record {
19public: 19public:
20 /** 20 /**
21 * c'tor 21 * c'tor
22 * uid of 0 isEmpty 22 * uid of 0 isEmpty
23 * uid of 1 will be assigned a new one 23 * uid of 1 will be assigned a new one
24 */ 24 */
25 OPimRecord(int uid = 0); 25 OPimRecord(int uid = 0);
26 ~OPimRecord(); 26 ~OPimRecord();
27 27
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames()const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * converts the internal structure to a map 76 * converts the internal structure to a map
77 */ 77 */
78 virtual QMap<int, QString> toMap()const = 0; 78 virtual QMap<int, QString> toMap()const = 0;
79 79
80 /** 80 /**
81 * key value representation of extra items 81 * key value representation of extra items
82 */ 82 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 83 virtual QMap<QString, QString> toExtraMap()const = 0;
84 84
85 /** 85 /**
86 * the name for a recordField 86 * the name for a recordField
87 */ 87 */
88 virtual QString recordField(int)const = 0; 88 virtual QString recordField(int)const = 0;
89 89
90 /** 90 /**
91 * returns a reference of the 91 * returns a reference of the
92 * Cross Reference Manager 92 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 93 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 94 * 'Two' is the Partner where we link to
95 */ 95 */
96 OPimXRefManager& xrefmanager(); 96 OPimXRefManager& xrefmanager();
97 97
98 /** 98 /**
99 * set the uid 99 * set the uid
100 */ 100 */
101 virtual void setUid( int uid ); 101 virtual void setUid( int uid );
102 102
103 /* 103 /*
104 * used inside the Templates for casting 104 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 105 * REIMPLEMENT in your ....
106 */ 106 */
107 static int rtti(); 107 static int rtti();
108 108
109 /** 109 /**
110 * some marshalling and de marshalling code 110 * some marshalling and de marshalling code
111 * saves the OPimRecord 111 * saves the OPimRecord
112 * to and from a DataStream 112 * to and from a DataStream
113 */ 113 */
114 virtual bool loadFromStream(QDataStream& ); 114 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 115 virtual bool saveToStream( QDataStream& stream )const;
116 116
117protected: 117protected:
118 Qtopia::UidGen &uidGen(); 118 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 119// QString crossToString()const;
120 120
121private: 121private:
122 class OPimRecordPrivate; 122 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 123 OPimRecordPrivate *d;
124 OPimXRefManager m_xrefman; 124 OPimXRefManager m_xrefman;
125 static Qtopia::UidGen m_uidGen; 125 static Qtopia::UidGen m_uidGen;
126 126
127private: 127private:
128 void flush( const OPimXRefPartner&, QDataStream& stream )const; 128 void flush( const OPimXRefPartner&, QDataStream& stream )const;
129 OPimXRefPartner partner( QDataStream& ); 129 OPimXRefPartner partner( QDataStream& );
130}; 130};
131 131
132 132
133 133
134#endif 134#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index cde2b3d..b4d4aa9 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,422 +1,422 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h" 18#include "opimnotifymanager.h"
19#include "opimresolver.h" 19#include "opimresolver.h"
20 20
21#include "otodo.h" 21#include "otodo.h"
22 22
23 23
24struct OTodo::OTodoData : public QShared { 24struct OTodo::OTodoData : public QShared {
25 OTodoData() : QShared() { 25 OTodoData() : QShared() {
26 }; 26 };
27 27
28 QDate date; 28 QDate date;
29 bool isCompleted:1; 29 bool isCompleted:1;
30 bool hasDate:1; 30 bool hasDate:1;
31 int priority; 31 int priority;
32 QString desc; 32 QString desc;
33 QString sum; 33 QString sum;
34 QMap<QString, QString> extra; 34 QMap<QString, QString> extra;
35 ushort prog; 35 ushort prog;
36 OPimState state; 36 OPimState state;
37 ORecur recur; 37 ORecur recur;
38 OPimMaintainer maintainer; 38 OPimMaintainer maintainer;
39 QDate start; 39 QDate start;
40 QDate completed; 40 QDate completed;
41 OPimNotifyManager notifiers; 41 OPimNotifyManager notifiers;
42}; 42};
43 43
44OTodo::OTodo(const OTodo &event ) 44OTodo::OTodo(const OTodo &event )
45 : OPimRecord( event ), data( event.data ) 45 : OPimRecord( event ), data( event.data )
46{ 46{
47 data->ref(); 47 data->ref();
48// qWarning("ref up"); 48// qWarning("ref up");
49} 49}
50OTodo::~OTodo() { 50OTodo::~OTodo() {
51 51
52// qWarning("~OTodo " ); 52// qWarning("~OTodo " );
53 if ( data->deref() ) { 53 if ( data->deref() ) {
54// qWarning("OTodo::dereffing"); 54// qWarning("OTodo::dereffing");
55 delete data; 55 delete data;
56 data = 0l; 56 data = 0l;
57 } 57 }
58} 58}
59OTodo::OTodo(bool completed, int priority, 59OTodo::OTodo(bool completed, int priority,
60 const QArray<int> &category, 60 const QArray<int> &category,
61 const QString& summary, 61 const QString& summary,
62 const QString &description, 62 const QString &description,
63 ushort progress, 63 ushort progress,
64 bool hasDate, QDate date, int uid ) 64 bool hasDate, QDate date, int uid )
65 : OPimRecord( uid ) 65 : OPimRecord( uid )
66{ 66{
67// qWarning("OTodoData " + summary); 67// qWarning("OTodoData " + summary);
68 setCategories( category ); 68 setCategories( category );
69 69
70 data = new OTodoData; 70 data = new OTodoData;
71 71
72 data->date = date; 72 data->date = date;
73 data->isCompleted = completed; 73 data->isCompleted = completed;
74 data->hasDate = hasDate; 74 data->hasDate = hasDate;
75 data->priority = priority; 75 data->priority = priority;
76 data->sum = summary; 76 data->sum = summary;
77 data->prog = progress; 77 data->prog = progress;
78 data->desc = Qtopia::simplifyMultiLineSpace(description ); 78 data->desc = Qtopia::simplifyMultiLineSpace(description );
79} 79}
80OTodo::OTodo(bool completed, int priority, 80OTodo::OTodo(bool completed, int priority,
81 const QStringList &category, 81 const QStringList &category,
82 const QString& summary, 82 const QString& summary,
83 const QString &description, 83 const QString &description,
84 ushort progress, 84 ushort progress,
85 bool hasDate, QDate date, int uid ) 85 bool hasDate, QDate date, int uid )
86 : OPimRecord( uid ) 86 : OPimRecord( uid )
87{ 87{
88// qWarning("OTodoData" + summary); 88// qWarning("OTodoData" + summary);
89 setCategories( idsFromString( category.join(";") ) ); 89 setCategories( idsFromString( category.join(";") ) );
90 90
91 data = new OTodoData; 91 data = new OTodoData;
92 92
93 data->date = date; 93 data->date = date;
94 data->isCompleted = completed; 94 data->isCompleted = completed;
95 data->hasDate = hasDate; 95 data->hasDate = hasDate;
96 data->priority = priority; 96 data->priority = priority;
97 data->sum = summary; 97 data->sum = summary;
98 data->prog = progress; 98 data->prog = progress;
99 data->desc = Qtopia::simplifyMultiLineSpace(description ); 99 data->desc = Qtopia::simplifyMultiLineSpace(description );
100} 100}
101bool OTodo::match( const QRegExp &regExp )const 101bool OTodo::match( const QRegExp &regExp )const
102{ 102{
103 if( QString::number( data->priority ).find( regExp ) != -1 ){ 103 if( QString::number( data->priority ).find( regExp ) != -1 ){
104 return true; 104 return true;
105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
106 return true; 106 return true;
107 }else if(data->desc.find( regExp ) != -1 ){ 107 }else if(data->desc.find( regExp ) != -1 ){
108 return true; 108 return true;
109 }else if(data->sum.find( regExp ) != -1 ) { 109 }else if(data->sum.find( regExp ) != -1 ) {
110 return true; 110 return true;
111 } 111 }
112 return false; 112 return false;
113} 113}
114bool OTodo::isCompleted() const 114bool OTodo::isCompleted() const
115{ 115{
116 return data->isCompleted; 116 return data->isCompleted;
117} 117}
118bool OTodo::hasDueDate() const 118bool OTodo::hasDueDate() const
119{ 119{
120 return data->hasDate; 120 return data->hasDate;
121} 121}
122bool OTodo::hasStartDate()const { 122bool OTodo::hasStartDate()const {
123 return data->start.isValid(); 123 return data->start.isValid();
124} 124}
125bool OTodo::hasCompletedDate()const { 125bool OTodo::hasCompletedDate()const {
126 return data->completed.isValid(); 126 return data->completed.isValid();
127} 127}
128int OTodo::priority()const 128int OTodo::priority()const
129{ 129{
130 return data->priority; 130 return data->priority;
131} 131}
132QString OTodo::summary() const 132QString OTodo::summary() const
133{ 133{
134 return data->sum; 134 return data->sum;
135} 135}
136ushort OTodo::progress() const 136ushort OTodo::progress() const
137{ 137{
138 return data->prog; 138 return data->prog;
139} 139}
140QDate OTodo::dueDate()const 140QDate OTodo::dueDate()const
141{ 141{
142 return data->date; 142 return data->date;
143} 143}
144QDate OTodo::startDate()const { 144QDate OTodo::startDate()const {
145 return data->start; 145 return data->start;
146} 146}
147QDate OTodo::completedDate()const { 147QDate OTodo::completedDate()const {
148 return data->completed; 148 return data->completed;
149} 149}
150QString OTodo::description()const 150QString OTodo::description()const
151{ 151{
152 return data->desc; 152 return data->desc;
153} 153}
154OPimState OTodo::state()const { 154OPimState OTodo::state()const {
155 return data->state; 155 return data->state;
156} 156}
157ORecur OTodo::recurrence()const { 157ORecur OTodo::recurrence()const {
158 return data->recur; 158 return data->recur;
159} 159}
160OPimMaintainer OTodo::maintainer()const { 160OPimMaintainer OTodo::maintainer()const {
161 return data->maintainer; 161 return data->maintainer;
162} 162}
163void OTodo::setCompleted( bool completed ) 163void OTodo::setCompleted( bool completed )
164{ 164{
165 changeOrModify(); 165 changeOrModify();
166 data->isCompleted = completed; 166 data->isCompleted = completed;
167} 167}
168void OTodo::setHasDueDate( bool hasDate ) 168void OTodo::setHasDueDate( bool hasDate )
169{ 169{
170 changeOrModify(); 170 changeOrModify();
171 data->hasDate = hasDate; 171 data->hasDate = hasDate;
172} 172}
173void OTodo::setDescription(const QString &desc ) 173void OTodo::setDescription(const QString &desc )
174{ 174{
175// qWarning( "desc " + desc ); 175// qWarning( "desc " + desc );
176 changeOrModify(); 176 changeOrModify();
177 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 177 data->desc = Qtopia::simplifyMultiLineSpace(desc );
178} 178}
179void OTodo::setSummary( const QString& sum ) 179void OTodo::setSummary( const QString& sum )
180{ 180{
181 changeOrModify(); 181 changeOrModify();
182 data->sum = sum; 182 data->sum = sum;
183} 183}
184void OTodo::setPriority(int prio ) 184void OTodo::setPriority(int prio )
185{ 185{
186 changeOrModify(); 186 changeOrModify();
187 data->priority = prio; 187 data->priority = prio;
188} 188}
189void OTodo::setDueDate( const QDate& date ) 189void OTodo::setDueDate( const QDate& date )
190{ 190{
191 changeOrModify(); 191 changeOrModify();
192 data->date = date; 192 data->date = date;
193} 193}
194void OTodo::setStartDate( const QDate& date ) { 194void OTodo::setStartDate( const QDate& date ) {
195 changeOrModify(); 195 changeOrModify();
196 data->start = date; 196 data->start = date;
197} 197}
198void OTodo::setCompletedDate( const QDate& date ) { 198void OTodo::setCompletedDate( const QDate& date ) {
199 changeOrModify(); 199 changeOrModify();
200 data->completed = date; 200 data->completed = date;
201} 201}
202void OTodo::setState( const OPimState& state ) { 202void OTodo::setState( const OPimState& state ) {
203 changeOrModify(); 203 changeOrModify();
204 data->state = state; 204 data->state = state;
205} 205}
206void OTodo::setRecurrence( const ORecur& rec) { 206void OTodo::setRecurrence( const ORecur& rec) {
207 changeOrModify(); 207 changeOrModify();
208 data->recur = rec; 208 data->recur = rec;
209} 209}
210void OTodo::setMaintainer( const OPimMaintainer& pim ) { 210void OTodo::setMaintainer( const OPimMaintainer& pim ) {
211 changeOrModify(); 211 changeOrModify();
212 data->maintainer = pim; 212 data->maintainer = pim;
213} 213}
214bool OTodo::isOverdue( ) 214bool OTodo::isOverdue( )
215{ 215{
216 if( data->hasDate && !data->isCompleted) 216 if( data->hasDate && !data->isCompleted)
217 return QDate::currentDate() > data->date; 217 return QDate::currentDate() > data->date;
218 return false; 218 return false;
219} 219}
220void OTodo::setProgress(ushort progress ) 220void OTodo::setProgress(ushort progress )
221{ 221{
222 changeOrModify(); 222 changeOrModify();
223 data->prog = progress; 223 data->prog = progress;
224} 224}
225QString OTodo::toShortText() const { 225QString OTodo::toShortText() const {
226 return summary(); 226 return summary();
227} 227}
228/*! 228/*!
229 Returns a richt text string 229 Returns a richt text string
230*/ 230*/
231QString OTodo::toRichText() const 231QString OTodo::toRichText() const
232{ 232{
233 QString text; 233 QString text;
234 QStringList catlist; 234 QStringList catlist;
235 235
236 // Description of the todo 236 // Description of the todo
237 if ( !summary().isEmpty() ) { 237 if ( !summary().isEmpty() ) {
238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
240 } 240 }
241 if( !description().isEmpty() ){ 241 if( !description().isEmpty() ){
242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
244 } 244 }
245 text += "<br><br><br>"; 245 text += "<br><br><br>";
246 246
247 text += "<b>" + QObject::tr( "Priority:") +" </b>" 247 text += "<b>" + QObject::tr( "Priority:") +" </b>"
248 + QString::number( priority() ) + " <br>"; 248 + QString::number( priority() ) + " <br>";
249 text += "<b>" + QObject::tr( "Progress:") + " </b>" 249 text += "<b>" + QObject::tr( "Progress:") + " </b>"
250 + QString::number( progress() ) + " %<br>"; 250 + QString::number( progress() ) + " %<br>";
251 if (hasDueDate() ){ 251 if (hasDueDate() ){
252 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 252 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
253 text += dueDate().toString(); 253 text += dueDate().toString();
254 text += "<br>"; 254 text += "<br>";
255 } 255 }
256 256
257 text += "<b>" + QObject::tr( "Category:") + "</b> "; 257 text += "<b>" + QObject::tr( "Category:") + "</b> ";
258 text += categoryNames().join(", "); 258 text += categoryNames( "Todo List" ).join(", ");
259 text += "<br>"; 259 text += "<br>";
260 260
261 return text; 261 return text;
262} 262}
263OPimNotifyManager& OTodo::notifiers() { 263OPimNotifyManager& OTodo::notifiers() {
264 return data->notifiers; 264 return data->notifiers;
265} 265}
266 266
267bool OTodo::operator<( const OTodo &toDoEvent )const{ 267bool OTodo::operator<( const OTodo &toDoEvent )const{
268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
270 if( hasDueDate() && toDoEvent.hasDueDate() ){ 270 if( hasDueDate() && toDoEvent.hasDueDate() ){
271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
272 return priority() < toDoEvent.priority(); 272 return priority() < toDoEvent.priority();
273 }else{ 273 }else{
274 return dueDate() < toDoEvent.dueDate(); 274 return dueDate() < toDoEvent.dueDate();
275 } 275 }
276 } 276 }
277 return false; 277 return false;
278} 278}
279bool OTodo::operator<=(const OTodo &toDoEvent )const 279bool OTodo::operator<=(const OTodo &toDoEvent )const
280{ 280{
281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
283 if( hasDueDate() && toDoEvent.hasDueDate() ){ 283 if( hasDueDate() && toDoEvent.hasDueDate() ){
284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
285 return priority() <= toDoEvent.priority(); 285 return priority() <= toDoEvent.priority();
286 }else{ 286 }else{
287 return dueDate() <= toDoEvent.dueDate(); 287 return dueDate() <= toDoEvent.dueDate();
288 } 288 }
289 } 289 }
290 return true; 290 return true;
291} 291}
292bool OTodo::operator>(const OTodo &toDoEvent )const 292bool OTodo::operator>(const OTodo &toDoEvent )const
293{ 293{
294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
296 if( hasDueDate() && toDoEvent.hasDueDate() ){ 296 if( hasDueDate() && toDoEvent.hasDueDate() ){
297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
298 return priority() > toDoEvent.priority(); 298 return priority() > toDoEvent.priority();
299 }else{ 299 }else{
300 return dueDate() > toDoEvent.dueDate(); 300 return dueDate() > toDoEvent.dueDate();
301 } 301 }
302 } 302 }
303 return false; 303 return false;
304} 304}
305bool OTodo::operator>=(const OTodo &toDoEvent )const 305bool OTodo::operator>=(const OTodo &toDoEvent )const
306{ 306{
307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
309 if( hasDueDate() && toDoEvent.hasDueDate() ){ 309 if( hasDueDate() && toDoEvent.hasDueDate() ){
310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
311 return priority() > toDoEvent.priority(); 311 return priority() > toDoEvent.priority();
312 }else{ 312 }else{
313 return dueDate() > toDoEvent.dueDate(); 313 return dueDate() > toDoEvent.dueDate();
314 } 314 }
315 } 315 }
316 return true; 316 return true;
317} 317}
318bool OTodo::operator==(const OTodo &toDoEvent )const 318bool OTodo::operator==(const OTodo &toDoEvent )const
319{ 319{
320 if ( data->priority != toDoEvent.data->priority ) return false; 320 if ( data->priority != toDoEvent.data->priority ) return false;
321 if ( data->priority != toDoEvent.data->prog ) return false; 321 if ( data->priority != toDoEvent.data->prog ) return false;
322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
323 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 323 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
324 if ( data->date != toDoEvent.data->date ) return false; 324 if ( data->date != toDoEvent.data->date ) return false;
325 if ( data->sum != toDoEvent.data->sum ) return false; 325 if ( data->sum != toDoEvent.data->sum ) return false;
326 if ( data->desc != toDoEvent.data->desc ) return false; 326 if ( data->desc != toDoEvent.data->desc ) return false;
327 if ( data->maintainer != toDoEvent.data->maintainer ) 327 if ( data->maintainer != toDoEvent.data->maintainer )
328 return false; 328 return false;
329 329
330 return OPimRecord::operator==( toDoEvent ); 330 return OPimRecord::operator==( toDoEvent );
331} 331}
332void OTodo::deref() { 332void OTodo::deref() {
333 333
334// qWarning("deref in ToDoEvent"); 334// qWarning("deref in ToDoEvent");
335 if ( data->deref() ) { 335 if ( data->deref() ) {
336// qWarning("deleting"); 336// qWarning("deleting");
337 delete data; 337 delete data;
338 data= 0; 338 data= 0;
339 } 339 }
340} 340}
341OTodo &OTodo::operator=(const OTodo &item ) 341OTodo &OTodo::operator=(const OTodo &item )
342{ 342{
343 OPimRecord::operator=( item ); 343 OPimRecord::operator=( item );
344 //qWarning("operator= ref "); 344 //qWarning("operator= ref ");
345 item.data->ref(); 345 item.data->ref();
346 deref(); 346 deref();
347 data = item.data; 347 data = item.data;
348 348
349 return *this; 349 return *this;
350} 350}
351 351
352QMap<int, QString> OTodo::toMap() const { 352QMap<int, QString> OTodo::toMap() const {
353 QMap<int, QString> map; 353 QMap<int, QString> map;
354 354
355 map.insert( Uid, QString::number( uid() ) ); 355 map.insert( Uid, QString::number( uid() ) );
356 map.insert( Category, idsToString( categories() ) ); 356 map.insert( Category, idsToString( categories() ) );
357 map.insert( HasDate, QString::number( data->hasDate ) ); 357 map.insert( HasDate, QString::number( data->hasDate ) );
358 map.insert( Completed, QString::number( data->isCompleted ) ); 358 map.insert( Completed, QString::number( data->isCompleted ) );
359 map.insert( Description, data->desc ); 359 map.insert( Description, data->desc );
360 map.insert( Summary, data->sum ); 360 map.insert( Summary, data->sum );
361 map.insert( Priority, QString::number( data->priority ) ); 361 map.insert( Priority, QString::number( data->priority ) );
362 map.insert( DateDay, QString::number( data->date.day() ) ); 362 map.insert( DateDay, QString::number( data->date.day() ) );
363 map.insert( DateMonth, QString::number( data->date.month() ) ); 363 map.insert( DateMonth, QString::number( data->date.month() ) );
364 map.insert( DateYear, QString::number( data->date.year() ) ); 364 map.insert( DateYear, QString::number( data->date.year() ) );
365 map.insert( Progress, QString::number( data->prog ) ); 365 map.insert( Progress, QString::number( data->prog ) );
366// map.insert( CrossReference, crossToString() ); 366// map.insert( CrossReference, crossToString() );
367 /* FIXME!!! map.insert( State, ); 367 /* FIXME!!! map.insert( State, );
368 map.insert( Recurrence, ); 368 map.insert( Recurrence, );
369 map.insert( Reminders, ); 369 map.insert( Reminders, );
370 map. 370 map.
371 */ 371 */
372 return map; 372 return map;
373} 373}
374 374
375QMap<QString, QString> OTodo::toExtraMap()const { 375QMap<QString, QString> OTodo::toExtraMap()const {
376 return data->extra; 376 return data->extra;
377} 377}
378/** 378/**
379 * change or modify looks at the ref count and either 379 * change or modify looks at the ref count and either
380 * creates a new QShared Object or it can modify it 380 * creates a new QShared Object or it can modify it
381 * right in place 381 * right in place
382 */ 382 */
383void OTodo::changeOrModify() { 383void OTodo::changeOrModify() {
384 if ( data->count != 1 ) { 384 if ( data->count != 1 ) {
385 qWarning("changeOrModify"); 385 qWarning("changeOrModify");
386 data->deref(); 386 data->deref();
387 OTodoData* d2 = new OTodoData(); 387 OTodoData* d2 = new OTodoData();
388 copy(data, d2 ); 388 copy(data, d2 );
389 data = d2; 389 data = d2;
390 } 390 }
391} 391}
392// WATCHOUT 392// WATCHOUT
393/* 393/*
394 * if you add something to the Data struct 394 * if you add something to the Data struct
395 * be sure to copy it here 395 * be sure to copy it here
396 */ 396 */
397void OTodo::copy( OTodoData* src, OTodoData* dest ) { 397void OTodo::copy( OTodoData* src, OTodoData* dest ) {
398 dest->date = src->date; 398 dest->date = src->date;
399 dest->isCompleted = src->isCompleted; 399 dest->isCompleted = src->isCompleted;
400 dest->hasDate = src->hasDate; 400 dest->hasDate = src->hasDate;
401 dest->priority = src->priority; 401 dest->priority = src->priority;
402 dest->desc = src->desc; 402 dest->desc = src->desc;
403 dest->sum = src->sum; 403 dest->sum = src->sum;
404 dest->extra = src->extra; 404 dest->extra = src->extra;
405 dest->prog = src->prog; 405 dest->prog = src->prog;
406 dest->state = src->state; 406 dest->state = src->state;
407 dest->recur = src->recur; 407 dest->recur = src->recur;
408 dest->maintainer = src->maintainer; 408 dest->maintainer = src->maintainer;
409 dest->start = src->start; 409 dest->start = src->start;
410 dest->completed = src->completed; 410 dest->completed = src->completed;
411 dest->notifiers = src->notifiers; 411 dest->notifiers = src->notifiers;
412} 412}
413QString OTodo::type() const { 413QString OTodo::type() const {
414 return QString::fromLatin1("OTodo"); 414 return QString::fromLatin1("OTodo");
415} 415}
416QString OTodo::recordField(int /*id*/ )const { 416QString OTodo::recordField(int /*id*/ )const {
417 return QString::null; 417 return QString::null;
418} 418}
419 419
420int OTodo::rtti(){ 420int OTodo::rtti(){
421 return OPimResolver::TodoList; 421 return OPimResolver::TodoList;
422} 422}
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index ac0f4a9..d45417a 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,166 +1,166 @@
1#include <qarray.h> 1#include <qarray.h>
2 2
3#include <qpe/categories.h> 3#include <qpe/categories.h>
4#include <qpe/categoryselect.h> 4#include <qpe/categoryselect.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
9 9
10 10
11OPimRecord::OPimRecord( int uid ) 11OPimRecord::OPimRecord( int uid )
12 : Qtopia::Record() { 12 : Qtopia::Record() {
13 13
14 setUid( uid ); 14 setUid( uid );
15} 15}
16OPimRecord::~OPimRecord() { 16OPimRecord::~OPimRecord() {
17} 17}
18OPimRecord::OPimRecord( const OPimRecord& rec ) 18OPimRecord::OPimRecord( const OPimRecord& rec )
19 : Qtopia::Record( rec ) 19 : Qtopia::Record( rec )
20{ 20{
21 (*this) = rec; 21 (*this) = rec;
22} 22}
23 23
24OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 24OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
25 Qtopia::Record::operator=( rec ); 25 Qtopia::Record::operator=( rec );
26 m_xrefman = rec.m_xrefman; 26 m_xrefman = rec.m_xrefman;
27 27
28 return *this; 28 return *this;
29} 29}
30/* 30/*
31 * category names 31 * category names
32 */ 32 */
33QStringList OPimRecord::categoryNames()const { 33QStringList OPimRecord::categoryNames( const QString& appname ) const {
34 QStringList list; 34 QStringList list;
35 QArray<int> cats = categories(); 35 QArray<int> cats = categories();
36 Categories catDB; 36 Categories catDB;
37 catDB.load( categoryFileName() ); 37 catDB.load( categoryFileName() );
38 38
39 for (uint i = 0; i < cats.count(); i++ ) { 39 for (uint i = 0; i < cats.count(); i++ ) {
40 list << catDB.label("Todo List", cats[i] ); 40 list << catDB.label( appname, cats[i] );
41 } 41 }
42 42
43 return list; 43 return list;
44} 44}
45void OPimRecord::setCategoryNames( const QStringList& ) { 45void OPimRecord::setCategoryNames( const QStringList& ) {
46 46
47} 47}
48void OPimRecord::addCategoryName( const QString& ) { 48void OPimRecord::addCategoryName( const QString& ) {
49 Categories catDB; 49 Categories catDB;
50 catDB.load( categoryFileName() ); 50 catDB.load( categoryFileName() );
51 51
52 52
53} 53}
54bool OPimRecord::isEmpty()const { 54bool OPimRecord::isEmpty()const {
55 return ( uid() == 0 ); 55 return ( uid() == 0 );
56} 56}
57/*QString OPimRecord::crossToString()const { 57/*QString OPimRecord::crossToString()const {
58 QString str; 58 QString str;
59 QMap<QString, QArray<int> >::ConstIterator it; 59 QMap<QString, QArray<int> >::ConstIterator it;
60 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 60 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
61 QArray<int> id = it.data(); 61 QArray<int> id = it.data();
62 for ( uint i = 0; i < id.size(); ++i ) { 62 for ( uint i = 0; i < id.size(); ++i ) {
63 str += it.key() + "," + QString::number( i ) + ";"; 63 str += it.key() + "," + QString::number( i ) + ";";
64 } 64 }
65 } 65 }
66 str = str.remove( str.length()-1, 1); // strip the ; 66 str = str.remove( str.length()-1, 1); // strip the ;
67 //qWarning("IDS " + str ); 67 //qWarning("IDS " + str );
68 68
69 return str; 69 return str;
70 }*/ 70 }*/
71/* if uid = 1 assign a new one */ 71/* if uid = 1 assign a new one */
72void OPimRecord::setUid( int uid ) { 72void OPimRecord::setUid( int uid ) {
73 if ( uid == 1) 73 if ( uid == 1)
74 uid = uidGen().generate(); 74 uid = uidGen().generate();
75 75
76 Qtopia::Record::setUid( uid ); 76 Qtopia::Record::setUid( uid );
77}; 77};
78Qtopia::UidGen &OPimRecord::uidGen() { 78Qtopia::UidGen &OPimRecord::uidGen() {
79 return m_uidGen; 79 return m_uidGen;
80} 80}
81OPimXRefManager &OPimRecord::xrefmanager() { 81OPimXRefManager &OPimRecord::xrefmanager() {
82 return m_xrefman; 82 return m_xrefman;
83} 83}
84int OPimRecord::rtti(){ 84int OPimRecord::rtti(){
85 return 0; 85 return 0;
86} 86}
87 87
88/** 88/**
89 * now let's put our data into the stream 89 * now let's put our data into the stream
90 */ 90 */
91/* 91/*
92 * First read UID 92 * First read UID
93 * Categories 93 * Categories
94 * XRef 94 * XRef
95 */ 95 */
96bool OPimRecord::loadFromStream( QDataStream& stream ) { 96bool OPimRecord::loadFromStream( QDataStream& stream ) {
97 int Int; 97 int Int;
98 uint UInt; 98 uint UInt;
99 stream >> Int; 99 stream >> Int;
100 setUid(Int); 100 setUid(Int);
101 101
102 /** Categories */ 102 /** Categories */
103 stream >> UInt; 103 stream >> UInt;
104 QArray<int> array(UInt); 104 QArray<int> array(UInt);
105 for (uint i = 0; i < UInt; i++ ) { 105 for (uint i = 0; i < UInt; i++ ) {
106 stream >> array[i]; 106 stream >> array[i];
107 } 107 }
108 setCategories( array ); 108 setCategories( array );
109 109
110 /* 110 /*
111 * now we do the X-Ref stuff 111 * now we do the X-Ref stuff
112 */ 112 */
113 OPimXRef xref; 113 OPimXRef xref;
114 stream >> UInt; 114 stream >> UInt;
115 for ( uint i = 0; i < UInt; i++ ) { 115 for ( uint i = 0; i < UInt; i++ ) {
116 xref.setPartner( OPimXRef::One, partner( stream ) ); 116 xref.setPartner( OPimXRef::One, partner( stream ) );
117 xref.setPartner( OPimXRef::Two, partner( stream ) ); 117 xref.setPartner( OPimXRef::Two, partner( stream ) );
118 m_xrefman.add( xref ); 118 m_xrefman.add( xref );
119 } 119 }
120 120
121 return true; 121 return true;
122} 122}
123bool OPimRecord::saveToStream( QDataStream& stream )const { 123bool OPimRecord::saveToStream( QDataStream& stream )const {
124 /** UIDs */ 124 /** UIDs */
125 125
126 stream << uid(); 126 stream << uid();
127 127
128 /** Categories */ 128 /** Categories */
129 stream << categories().count(); 129 stream << categories().count();
130 for ( uint i = 0; i < categories().count(); i++ ) { 130 for ( uint i = 0; i < categories().count(); i++ ) {
131 stream << categories()[i]; 131 stream << categories()[i];
132 } 132 }
133 133
134 /* 134 /*
135 * first the XRef count 135 * first the XRef count
136 * then the xrefs 136 * then the xrefs
137 */ 137 */
138 stream << m_xrefman.list().count(); 138 stream << m_xrefman.list().count();
139 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 139 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
140 it != m_xrefman.list().end(); ++it ) { 140 it != m_xrefman.list().end(); ++it ) {
141 flush( (*it).partner( OPimXRef::One), stream ); 141 flush( (*it).partner( OPimXRef::One), stream );
142 flush( (*it).partner( OPimXRef::Two), stream ); 142 flush( (*it).partner( OPimXRef::Two), stream );
143 } 143 }
144 return true; 144 return true;
145} 145}
146void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 146void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
147 str << par.service(); 147 str << par.service();
148 str << par.uid(); 148 str << par.uid();
149 str << par.field(); 149 str << par.field();
150} 150}
151OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 151OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
152 OPimXRefPartner par; 152 OPimXRefPartner par;
153 QString str; 153 QString str;
154 int i; 154 int i;
155 155
156 stream >> str; 156 stream >> str;
157 par.setService( str ); 157 par.setService( str );
158 158
159 stream >> i; 159 stream >> i;
160 par.setUid( i ); 160 par.setUid( i );
161 161
162 stream >> i ; 162 stream >> i ;
163 par.setField( i ); 163 par.setField( i );
164 164
165 return par; 165 return par;
166} 166}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 665530f..c7f9460 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -1,134 +1,134 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qdatastream.h> 4#include <qdatastream.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10 10
11#include <opie/opimxrefmanager.h> 11#include <opie/opimxrefmanager.h>
12 12
13/** 13/**
14 * This is the base class for 14 * This is the base class for
15 * all PIM Records 15 * all PIM Records
16 * 16 *
17 */ 17 */
18class OPimRecord : public Qtopia::Record { 18class OPimRecord : public Qtopia::Record {
19public: 19public:
20 /** 20 /**
21 * c'tor 21 * c'tor
22 * uid of 0 isEmpty 22 * uid of 0 isEmpty
23 * uid of 1 will be assigned a new one 23 * uid of 1 will be assigned a new one
24 */ 24 */
25 OPimRecord(int uid = 0); 25 OPimRecord(int uid = 0);
26 ~OPimRecord(); 26 ~OPimRecord();
27 27
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames()const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * converts the internal structure to a map 76 * converts the internal structure to a map
77 */ 77 */
78 virtual QMap<int, QString> toMap()const = 0; 78 virtual QMap<int, QString> toMap()const = 0;
79 79
80 /** 80 /**
81 * key value representation of extra items 81 * key value representation of extra items
82 */ 82 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 83 virtual QMap<QString, QString> toExtraMap()const = 0;
84 84
85 /** 85 /**
86 * the name for a recordField 86 * the name for a recordField
87 */ 87 */
88 virtual QString recordField(int)const = 0; 88 virtual QString recordField(int)const = 0;
89 89
90 /** 90 /**
91 * returns a reference of the 91 * returns a reference of the
92 * Cross Reference Manager 92 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 93 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 94 * 'Two' is the Partner where we link to
95 */ 95 */
96 OPimXRefManager& xrefmanager(); 96 OPimXRefManager& xrefmanager();
97 97
98 /** 98 /**
99 * set the uid 99 * set the uid
100 */ 100 */
101 virtual void setUid( int uid ); 101 virtual void setUid( int uid );
102 102
103 /* 103 /*
104 * used inside the Templates for casting 104 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 105 * REIMPLEMENT in your ....
106 */ 106 */
107 static int rtti(); 107 static int rtti();
108 108
109 /** 109 /**
110 * some marshalling and de marshalling code 110 * some marshalling and de marshalling code
111 * saves the OPimRecord 111 * saves the OPimRecord
112 * to and from a DataStream 112 * to and from a DataStream
113 */ 113 */
114 virtual bool loadFromStream(QDataStream& ); 114 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 115 virtual bool saveToStream( QDataStream& stream )const;
116 116
117protected: 117protected:
118 Qtopia::UidGen &uidGen(); 118 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 119// QString crossToString()const;
120 120
121private: 121private:
122 class OPimRecordPrivate; 122 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 123 OPimRecordPrivate *d;
124 OPimXRefManager m_xrefman; 124 OPimXRefManager m_xrefman;
125 static Qtopia::UidGen m_uidGen; 125 static Qtopia::UidGen m_uidGen;
126 126
127private: 127private:
128 void flush( const OPimXRefPartner&, QDataStream& stream )const; 128 void flush( const OPimXRefPartner&, QDataStream& stream )const;
129 OPimXRefPartner partner( QDataStream& ); 129 OPimXRefPartner partner( QDataStream& );
130}; 130};
131 131
132 132
133 133
134#endif 134#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 178559b..9cccfc8 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,1148 +1,1148 @@
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 "opimresolver.h" 25#include "opimresolver.h"
26 26
27#include <qpe/stringutil.h> 27#include <qpe/stringutil.h>
28#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30 30
31#include <qobject.h> 31#include <qobject.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qstylesheet.h> 33#include <qstylesheet.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qmap.h> 35#include <qmap.h>
36 36
37#include <stdio.h> 37#include <stdio.h>
38 38
39/*! 39/*!
40 \class Contact contact.h 40 \class Contact contact.h
41 \brief The Contact class holds the data of an address book entry. 41 \brief The Contact class holds the data of an address book entry.
42 42
43 This data includes information the name of the person, contact 43 This data includes information the name of the person, contact
44 information, and business information such as deparment and job title. 44 information, and business information such as deparment and job title.
45 45
46 \ingroup qtopiaemb 46 \ingroup qtopiaemb
47 \ingroup qtopiadesktop 47 \ingroup qtopiadesktop
48*/ 48*/
49 49
50 50
51/*! 51/*!
52 Creates a new, empty contact. 52 Creates a new, empty contact.
53*/ 53*/
54OContact::OContact() 54OContact::OContact()
55 : OPimRecord(), mMap(), d( 0 ) 55 : OPimRecord(), mMap(), d( 0 )
56{ 56{
57} 57}
58 58
59/*! 59/*!
60 \internal 60 \internal
61 Creates a new contact. The properties of the contact are 61 Creates a new contact. The properties of the contact are
62 set from \a fromMap. 62 set from \a fromMap.
63*/ 63*/
64OContact::OContact( const QMap<int, QString> &fromMap ) : 64OContact::OContact( const QMap<int, QString> &fromMap ) :
65 OPimRecord(), mMap( fromMap ), d( 0 ) 65 OPimRecord(), mMap( fromMap ), d( 0 )
66{ 66{
67 QString cats = mMap[ Qtopia::AddressCategory ]; 67 QString cats = mMap[ Qtopia::AddressCategory ];
68 if ( !cats.isEmpty() ) 68 if ( !cats.isEmpty() )
69 setCategories( idsFromString( cats ) ); 69 setCategories( idsFromString( cats ) );
70 70
71 QString uidStr = find( Qtopia::AddressUid ); 71 QString uidStr = find( Qtopia::AddressUid );
72 72
73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 73 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
74 qWarning( "Invalid UID found. Generate new one.." ); 74 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 75 setUid( uidGen().generate() );
76 }else 76 }else
77 setUid( uidStr.toInt() ); 77 setUid( uidStr.toInt() );
78 78
79// if ( !uidStr.isEmpty() ) 79// if ( !uidStr.isEmpty() )
80 // setUid( uidStr.toInt() ); 80 // setUid( uidStr.toInt() );
81} 81}
82 82
83/*! 83/*!
84 Destroys a contact. 84 Destroys a contact.
85*/ 85*/
86OContact::~OContact() 86OContact::~OContact()
87{ 87{
88} 88}
89 89
90/*! \fn void OContact::setTitle( const QString &str ) 90/*! \fn void OContact::setTitle( const QString &str )
91 Sets the title of the contact to \a str. 91 Sets the title of the contact to \a str.
92*/ 92*/
93 93
94/*! \fn void OContact::setFirstName( const QString &str ) 94/*! \fn void OContact::setFirstName( const QString &str )
95 Sets the first name of the contact to \a str. 95 Sets the first name of the contact to \a str.
96*/ 96*/
97 97
98/*! \fn void OContact::setMiddleName( const QString &str ) 98/*! \fn void OContact::setMiddleName( const QString &str )
99 Sets the middle name of the contact to \a str. 99 Sets the middle name of the contact to \a str.
100*/ 100*/
101 101
102/*! \fn void OContact::setLastName( const QString &str ) 102/*! \fn void OContact::setLastName( const QString &str )
103 Sets the last name of the contact to \a str. 103 Sets the last name of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OContact::setSuffix( const QString &str ) 106/*! \fn void OContact::setSuffix( const QString &str )
107 Sets the suffix of the contact to \a str. 107 Sets the suffix of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OContact::setFileAs( const QString &str ) 110/*! \fn void OContact::setFileAs( const QString &str )
111 Sets the contact to filed as \a str. 111 Sets the contact to filed as \a str.
112*/ 112*/
113 113
114/*! \fn void OContact::setDefaultEmail( const QString &str ) 114/*! \fn void OContact::setDefaultEmail( const QString &str )
115 Sets the default email of the contact to \a str. 115 Sets the default email of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OContact::setHomeStreet( const QString &str ) 118/*! \fn void OContact::setHomeStreet( const QString &str )
119 Sets the home street address of the contact to \a str. 119 Sets the home street address of the contact to \a str.
120*/ 120*/
121 121
122/*! \fn void OContact::setHomeCity( const QString &str ) 122/*! \fn void OContact::setHomeCity( const QString &str )
123 Sets the home city of the contact to \a str. 123 Sets the home city of the contact to \a str.
124*/ 124*/
125 125
126/*! \fn void OContact::setHomeState( const QString &str ) 126/*! \fn void OContact::setHomeState( const QString &str )
127 Sets the home state of the contact to \a str. 127 Sets the home state of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OContact::setHomeZip( const QString &str ) 130/*! \fn void OContact::setHomeZip( const QString &str )
131 Sets the home zip code of the contact to \a str. 131 Sets the home zip code of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OContact::setHomeCountry( const QString &str ) 134/*! \fn void OContact::setHomeCountry( const QString &str )
135 Sets the home country of the contact to \a str. 135 Sets the home country of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OContact::setHomePhone( const QString &str ) 138/*! \fn void OContact::setHomePhone( const QString &str )
139 Sets the home phone number of the contact to \a str. 139 Sets the home phone number of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OContact::setHomeFax( const QString &str ) 142/*! \fn void OContact::setHomeFax( const QString &str )
143 Sets the home fax number of the contact to \a str. 143 Sets the home fax number of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OContact::setHomeMobile( const QString &str ) 146/*! \fn void OContact::setHomeMobile( const QString &str )
147 Sets the home mobile phone number of the contact to \a str. 147 Sets the home mobile phone number of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OContact::setHomeWebpage( const QString &str ) 150/*! \fn void OContact::setHomeWebpage( const QString &str )
151 Sets the home webpage of the contact to \a str. 151 Sets the home webpage of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OContact::setCompany( const QString &str ) 154/*! \fn void OContact::setCompany( const QString &str )
155 Sets the company for contact to \a str. 155 Sets the company for contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OContact::setJobTitle( const QString &str ) 158/*! \fn void OContact::setJobTitle( const QString &str )
159 Sets the job title of the contact to \a str. 159 Sets the job title of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OContact::setDepartment( const QString &str ) 162/*! \fn void OContact::setDepartment( const QString &str )
163 Sets the department for contact to \a str. 163 Sets the department for contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OContact::setOffice( const QString &str ) 166/*! \fn void OContact::setOffice( const QString &str )
167 Sets the office for contact to \a str. 167 Sets the office for contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OContact::setBusinessStreet( const QString &str ) 170/*! \fn void OContact::setBusinessStreet( const QString &str )
171 Sets the business street address of the contact to \a str. 171 Sets the business street address of the contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OContact::setBusinessCity( const QString &str ) 174/*! \fn void OContact::setBusinessCity( const QString &str )
175 Sets the business city of the contact to \a str. 175 Sets the business city of the contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OContact::setBusinessState( const QString &str ) 178/*! \fn void OContact::setBusinessState( const QString &str )
179 Sets the business state of the contact to \a str. 179 Sets the business state of the contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OContact::setBusinessZip( const QString &str ) 182/*! \fn void OContact::setBusinessZip( const QString &str )
183 Sets the business zip code of the contact to \a str. 183 Sets the business zip code of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OContact::setBusinessCountry( const QString &str ) 186/*! \fn void OContact::setBusinessCountry( const QString &str )
187 Sets the business country of the contact to \a str. 187 Sets the business country of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OContact::setBusinessPhone( const QString &str ) 190/*! \fn void OContact::setBusinessPhone( const QString &str )
191 Sets the business phone number of the contact to \a str. 191 Sets the business phone number of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OContact::setBusinessFax( const QString &str ) 194/*! \fn void OContact::setBusinessFax( const QString &str )
195 Sets the business fax number of the contact to \a str. 195 Sets the business fax number of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OContact::setBusinessMobile( const QString &str ) 198/*! \fn void OContact::setBusinessMobile( const QString &str )
199 Sets the business mobile phone number of the contact to \a str. 199 Sets the business mobile phone number of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OContact::setBusinessPager( const QString &str ) 202/*! \fn void OContact::setBusinessPager( const QString &str )
203 Sets the business pager number of the contact to \a str. 203 Sets the business pager number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OContact::setBusinessWebpage( const QString &str ) 206/*! \fn void OContact::setBusinessWebpage( const QString &str )
207 Sets the business webpage of the contact to \a str. 207 Sets the business webpage of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OContact::setProfession( const QString &str ) 210/*! \fn void OContact::setProfession( const QString &str )
211 Sets the profession of the contact to \a str. 211 Sets the profession of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OContact::setAssistant( const QString &str ) 214/*! \fn void OContact::setAssistant( const QString &str )
215 Sets the assistant of the contact to \a str. 215 Sets the assistant of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OContact::setManager( const QString &str ) 218/*! \fn void OContact::setManager( const QString &str )
219 Sets the manager of the contact to \a str. 219 Sets the manager of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OContact::setSpouse( const QString &str ) 222/*! \fn void OContact::setSpouse( const QString &str )
223 Sets the spouse of the contact to \a str. 223 Sets the spouse of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OContact::setGender( const QString &str ) 226/*! \fn void OContact::setGender( const QString &str )
227 Sets the gender of the contact to \a str. 227 Sets the gender of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OContact::setNickname( const QString &str ) 230/*! \fn void OContact::setNickname( const QString &str )
231 Sets the nickname of the contact to \a str. 231 Sets the nickname of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OContact::setNotes( const QString &str ) 234/*! \fn void OContact::setNotes( const QString &str )
235 Sets the notes about the contact to \a str. 235 Sets the notes about the contact to \a str.
236*/ 236*/
237 237
238/*! \fn QString OContact::title() const 238/*! \fn QString OContact::title() const
239 Returns the title of the contact. 239 Returns the title of the contact.
240*/ 240*/
241 241
242/*! \fn QString OContact::firstName() const 242/*! \fn QString OContact::firstName() const
243 Returns the first name of the contact. 243 Returns the first name of the contact.
244*/ 244*/
245 245
246/*! \fn QString OContact::middleName() const 246/*! \fn QString OContact::middleName() const
247 Returns the middle name of the contact. 247 Returns the middle name of the contact.
248*/ 248*/
249 249
250/*! \fn QString OContact::lastName() const 250/*! \fn QString OContact::lastName() const
251 Returns the last name of the contact. 251 Returns the last name of the contact.
252*/ 252*/
253 253
254/*! \fn QString OContact::suffix() const 254/*! \fn QString OContact::suffix() const
255 Returns the suffix of the contact. 255 Returns the suffix of the contact.
256*/ 256*/
257 257
258/*! \fn QString OContact::fileAs() const 258/*! \fn QString OContact::fileAs() const
259 Returns the string the contact is filed as. 259 Returns the string the contact is filed as.
260*/ 260*/
261 261
262/*! \fn QString OContact::defaultEmail() const 262/*! \fn QString OContact::defaultEmail() const
263 Returns the default email address of the contact. 263 Returns the default email address of the contact.
264*/ 264*/
265 265
266/*! \fn QString OContact::emails() const 266/*! \fn QString OContact::emails() const
267 Returns the list of email address for a contact separated by ';'s in a single 267 Returns the list of email address for a contact separated by ';'s in a single
268 string. 268 string.
269*/ 269*/
270 270
271/*! \fn QString OContact::homeStreet() const 271/*! \fn QString OContact::homeStreet() const
272 Returns the home street address of the contact. 272 Returns the home street address of the contact.
273*/ 273*/
274 274
275/*! \fn QString OContact::homeCity() const 275/*! \fn QString OContact::homeCity() const
276 Returns the home city of the contact. 276 Returns the home city of the contact.
277*/ 277*/
278 278
279/*! \fn QString OContact::homeState() const 279/*! \fn QString OContact::homeState() const
280 Returns the home state of the contact. 280 Returns the home state of the contact.
281*/ 281*/
282 282
283/*! \fn QString OContact::homeZip() const 283/*! \fn QString OContact::homeZip() const
284 Returns the home zip of the contact. 284 Returns the home zip of the contact.
285*/ 285*/
286 286
287/*! \fn QString OContact::homeCountry() const 287/*! \fn QString OContact::homeCountry() const
288 Returns the home country of the contact. 288 Returns the home country of the contact.
289*/ 289*/
290 290
291/*! \fn QString OContact::homePhone() const 291/*! \fn QString OContact::homePhone() const
292 Returns the home phone number of the contact. 292 Returns the home phone number of the contact.
293*/ 293*/
294 294
295/*! \fn QString OContact::homeFax() const 295/*! \fn QString OContact::homeFax() const
296 Returns the home fax number of the contact. 296 Returns the home fax number of the contact.
297*/ 297*/
298 298
299/*! \fn QString OContact::homeMobile() const 299/*! \fn QString OContact::homeMobile() const
300 Returns the home mobile number of the contact. 300 Returns the home mobile number of the contact.
301*/ 301*/
302 302
303/*! \fn QString OContact::homeWebpage() const 303/*! \fn QString OContact::homeWebpage() const
304 Returns the home webpage of the contact. 304 Returns the home webpage of the contact.
305*/ 305*/
306 306
307/*! \fn QString OContact::company() const 307/*! \fn QString OContact::company() const
308 Returns the company for the contact. 308 Returns the company for the contact.
309*/ 309*/
310 310
311/*! \fn QString OContact::department() const 311/*! \fn QString OContact::department() const
312 Returns the department for the contact. 312 Returns the department for the contact.
313*/ 313*/
314 314
315/*! \fn QString OContact::office() const 315/*! \fn QString OContact::office() const
316 Returns the office for the contact. 316 Returns the office for the contact.
317*/ 317*/
318 318
319/*! \fn QString OContact::jobTitle() const 319/*! \fn QString OContact::jobTitle() const
320 Returns the job title of the contact. 320 Returns the job title of the contact.
321*/ 321*/
322 322
323/*! \fn QString OContact::profession() const 323/*! \fn QString OContact::profession() const
324 Returns the profession of the contact. 324 Returns the profession of the contact.
325*/ 325*/
326 326
327/*! \fn QString OContact::assistant() const 327/*! \fn QString OContact::assistant() const
328 Returns the assistant of the contact. 328 Returns the assistant of the contact.
329*/ 329*/
330 330
331/*! \fn QString OContact::manager() const 331/*! \fn QString OContact::manager() const
332 Returns the manager of the contact. 332 Returns the manager of the contact.
333*/ 333*/
334 334
335/*! \fn QString OContact::businessStreet() const 335/*! \fn QString OContact::businessStreet() const
336 Returns the business street address of the contact. 336 Returns the business street address of the contact.
337*/ 337*/
338 338
339/*! \fn QString OContact::businessCity() const 339/*! \fn QString OContact::businessCity() const
340 Returns the business city of the contact. 340 Returns the business city of the contact.
341*/ 341*/
342 342
343/*! \fn QString OContact::businessState() const 343/*! \fn QString OContact::businessState() const
344 Returns the business state of the contact. 344 Returns the business state of the contact.
345*/ 345*/
346 346
347/*! \fn QString OContact::businessZip() const 347/*! \fn QString OContact::businessZip() const
348 Returns the business zip of the contact. 348 Returns the business zip of the contact.
349*/ 349*/
350 350
351/*! \fn QString OContact::businessCountry() const 351/*! \fn QString OContact::businessCountry() const
352 Returns the business country of the contact. 352 Returns the business country of the contact.
353*/ 353*/
354 354
355/*! \fn QString OContact::businessPhone() const 355/*! \fn QString OContact::businessPhone() const
356 Returns the business phone number of the contact. 356 Returns the business phone number of the contact.
357*/ 357*/
358 358
359/*! \fn QString OContact::businessFax() const 359/*! \fn QString OContact::businessFax() const
360 Returns the business fax number of the contact. 360 Returns the business fax number of the contact.
361*/ 361*/
362 362
363/*! \fn QString OContact::businessMobile() const 363/*! \fn QString OContact::businessMobile() const
364 Returns the business mobile number of the contact. 364 Returns the business mobile number of the contact.
365*/ 365*/
366 366
367/*! \fn QString OContact::businessPager() const 367/*! \fn QString OContact::businessPager() const
368 Returns the business pager number of the contact. 368 Returns the business pager number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OContact::businessWebpage() const 371/*! \fn QString OContact::businessWebpage() const
372 Returns the business webpage of the contact. 372 Returns the business webpage of the contact.
373*/ 373*/
374 374
375/*! \fn QString OContact::spouse() const 375/*! \fn QString OContact::spouse() const
376 Returns the spouse of the contact. 376 Returns the spouse of the contact.
377*/ 377*/
378 378
379/*! \fn QString OContact::gender() const 379/*! \fn QString OContact::gender() const
380 Returns the gender of the contact. 380 Returns the gender of the contact.
381*/ 381*/
382 382
383/*! \fn QString OContact::nickname() const 383/*! \fn QString OContact::nickname() const
384 Returns the nickname of the contact. 384 Returns the nickname of the contact.
385*/ 385*/
386 386
387/*! \fn QString OContact::children() const 387/*! \fn QString OContact::children() const
388 Returns the children of the contact. 388 Returns the children of the contact.
389*/ 389*/
390 390
391/*! \fn QString OContact::notes() const 391/*! \fn QString OContact::notes() const
392 Returns the notes relating to the the contact. 392 Returns the notes relating to the the contact.
393*/ 393*/
394 394
395/*! \fn QString OContact::groups() const 395/*! \fn QString OContact::groups() const
396 \internal 396 \internal
397 Returns the groups for the contact. 397 Returns the groups for the contact.
398*/ 398*/
399 399
400/*! \fn QStringList OContact::groupList() const 400/*! \fn QStringList OContact::groupList() const
401 \internal 401 \internal
402*/ 402*/
403 403
404/*! \fn QString OContact::field(int) const 404/*! \fn QString OContact::field(int) const
405 \internal 405 \internal
406*/ 406*/
407 407
408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 408/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
409 \internal 409 \internal
410*/ 410*/
411 411
412/*! \fn void OContact::setUid( int id ) 412/*! \fn void OContact::setUid( int id )
413 \internal 413 \internal
414 Sets the uid for this record to \a id. 414 Sets the uid for this record to \a id.
415*/ 415*/
416 416
417/*! \enum OContact::journal_action 417/*! \enum OContact::journal_action
418 \internal 418 \internal
419*/ 419*/
420 420
421/*! 421/*!
422 \internal 422 \internal
423*/ 423*/
424QMap<int, QString> OContact::toMap() const 424QMap<int, QString> OContact::toMap() const
425{ 425{
426 QMap<int, QString> map = mMap; 426 QMap<int, QString> map = mMap;
427 QString cats = idsToString( categories() ); 427 QString cats = idsToString( categories() );
428 if ( !cats.isEmpty() ) 428 if ( !cats.isEmpty() )
429 map.insert( Qtopia::AddressCategory, cats ); 429 map.insert( Qtopia::AddressCategory, cats );
430 return map; 430 return map;
431} 431}
432 432
433/*! 433/*!
434 Returns a rich text formatted QString representing the contents the contact. 434 Returns a rich text formatted QString representing the contents the contact.
435*/ 435*/
436QString OContact::toRichText() const 436QString OContact::toRichText() const
437{ 437{
438 QString text; 438 QString text;
439 QString value, comp, state; 439 QString value, comp, state;
440 QString str; 440 QString str;
441 bool marker = false; 441 bool marker = false;
442 442
443 // name, jobtitle and company 443 // name, jobtitle and company
444 if ( !(value = fullName()).isEmpty() ) 444 if ( !(value = fullName()).isEmpty() )
445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; 445 text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>";
446 if ( !(value = jobTitle()).isEmpty() ) 446 if ( !(value = jobTitle()).isEmpty() )
447 text += Qtopia::escapeString(value) + "<br>"; 447 text += Qtopia::escapeString(value) + "<br>";
448 448
449 comp = company(); 449 comp = company();
450 if ( !(value = department()).isEmpty() ) { 450 if ( !(value = department()).isEmpty() ) {
451 text += Qtopia::escapeString(value); 451 text += Qtopia::escapeString(value);
452 if ( comp ) 452 if ( comp )
453 text += ", "; 453 text += ", ";
454 else 454 else
455 text += "<br>"; 455 text += "<br>";
456 } 456 }
457 if ( !comp.isEmpty() ) 457 if ( !comp.isEmpty() )
458 text += Qtopia::escapeString(comp) + "<br>"; 458 text += Qtopia::escapeString(comp) + "<br>";
459 459
460 QString defEmail = defaultEmail(); 460 QString defEmail = defaultEmail();
461 if ( !defEmail.isEmpty() ) 461 if ( !defEmail.isEmpty() )
462 text += "<b>" + QObject::tr("Default Email: ") + "</b>" 462 text += "<b>" + QObject::tr("Default Email: ") + "</b>"
463 + Qtopia::escapeString(defEmail) + "<br>"; 463 + Qtopia::escapeString(defEmail) + "<br>";
464 464
465 text += "<hr>"; 465 text += "<hr>";
466 466
467 // business address 467 // business address
468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 468 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 469 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
470 text += "<br>"; 470 text += "<br>";
471 text += QObject::tr( "<b>Work Address:</b>" ); 471 text += QObject::tr( "<b>Work Address:</b>" );
472 text += "<br>"; 472 text += "<br>";
473 marker = true; 473 marker = true;
474 } 474 }
475 475
476 if ( !(value = businessStreet()).isEmpty() ) 476 if ( !(value = businessStreet()).isEmpty() )
477 text += Qtopia::escapeString(value) + "<br>"; 477 text += Qtopia::escapeString(value) + "<br>";
478 state = businessState(); 478 state = businessState();
479 if ( !(value = businessZip()).isEmpty() ) 479 if ( !(value = businessZip()).isEmpty() )
480 text += Qtopia::escapeString(value) + " "; 480 text += Qtopia::escapeString(value) + " ";
481 if ( !(value = businessCity()).isEmpty() ) { 481 if ( !(value = businessCity()).isEmpty() ) {
482 text += Qtopia::escapeString(value); 482 text += Qtopia::escapeString(value);
483 if ( state ) 483 if ( state )
484 text += ", " + Qtopia::escapeString(state); 484 text += ", " + Qtopia::escapeString(state);
485 text += "<br>"; 485 text += "<br>";
486 } else if ( !state.isEmpty() ) 486 } else if ( !state.isEmpty() )
487 text += Qtopia::escapeString(state) + "<br>"; 487 text += Qtopia::escapeString(state) + "<br>";
488 488
489 if ( !(value = businessCountry()).isEmpty() ) 489 if ( !(value = businessCountry()).isEmpty() )
490 text += Qtopia::escapeString(value) + "<br>"; 490 text += Qtopia::escapeString(value) + "<br>";
491 491
492 // rest of Business data 492 // rest of Business data
493 str = office(); 493 str = office();
494 if ( !str.isEmpty() ){ 494 if ( !str.isEmpty() ){
495 text += "<b>" + QObject::tr("Office: ") + "</b>" 495 text += "<b>" + QObject::tr("Office: ") + "</b>"
496 + Qtopia::escapeString(str) + "<br>"; 496 + Qtopia::escapeString(str) + "<br>";
497 marker = true; 497 marker = true;
498 } 498 }
499 str = businessWebpage(); 499 str = businessWebpage();
500 if ( !str.isEmpty() ){ 500 if ( !str.isEmpty() ){
501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 501 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
502 + Qtopia::escapeString(str) + "<br>"; 502 + Qtopia::escapeString(str) + "<br>";
503 marker = true; 503 marker = true;
504 } 504 }
505 str = businessPhone(); 505 str = businessPhone();
506 if ( !str.isEmpty() ){ 506 if ( !str.isEmpty() ){
507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 507 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
508 + Qtopia::escapeString(str) + "<br>"; 508 + Qtopia::escapeString(str) + "<br>";
509 marker = true; 509 marker = true;
510 } 510 }
511 str = businessFax(); 511 str = businessFax();
512 if ( !str.isEmpty() ){ 512 if ( !str.isEmpty() ){
513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 513 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
514 + Qtopia::escapeString(str) + "<br>"; 514 + Qtopia::escapeString(str) + "<br>";
515 marker = true; 515 marker = true;
516 } 516 }
517 str = businessMobile(); 517 str = businessMobile();
518 if ( !str.isEmpty() ){ 518 if ( !str.isEmpty() ){
519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 519 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
520 + Qtopia::escapeString(str) + "<br>"; 520 + Qtopia::escapeString(str) + "<br>";
521 marker = true; 521 marker = true;
522 } 522 }
523 str = businessPager(); 523 str = businessPager();
524 if ( !str.isEmpty() ){ 524 if ( !str.isEmpty() ){
525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 525 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
526 + Qtopia::escapeString(str) + "<br>"; 526 + Qtopia::escapeString(str) + "<br>";
527 marker = true; 527 marker = true;
528 } 528 }
529 529
530 // home address 530 // home address
531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 531 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 532 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
533 text += "<br>"; 533 text += "<br>";
534 text += QObject::tr( "<b>Home Address:</b>" ); 534 text += QObject::tr( "<b>Home Address:</b>" );
535 text += "<br>"; 535 text += "<br>";
536 } 536 }
537 537
538 if ( !(value = homeStreet()).isEmpty() ) 538 if ( !(value = homeStreet()).isEmpty() )
539 text += Qtopia::escapeString(value) + "<br>"; 539 text += Qtopia::escapeString(value) + "<br>";
540 state = homeState(); 540 state = homeState();
541 if ( !(value = homeZip()).isEmpty() ) 541 if ( !(value = homeZip()).isEmpty() )
542 text += Qtopia::escapeString(value) + " "; 542 text += Qtopia::escapeString(value) + " ";
543 if ( !(value = homeCity()).isEmpty() ) { 543 if ( !(value = homeCity()).isEmpty() ) {
544 text += Qtopia::escapeString(value); 544 text += Qtopia::escapeString(value);
545 if ( !state.isEmpty() ) 545 if ( !state.isEmpty() )
546 text += ", " + Qtopia::escapeString(state); 546 text += ", " + Qtopia::escapeString(state);
547 text += "<br>"; 547 text += "<br>";
548 } else if (!state.isEmpty()) 548 } else if (!state.isEmpty())
549 text += Qtopia::escapeString(state) + "<br>"; 549 text += Qtopia::escapeString(state) + "<br>";
550 if ( !(value = homeCountry()).isEmpty() ) 550 if ( !(value = homeCountry()).isEmpty() )
551 text += Qtopia::escapeString(value) + "<br>"; 551 text += Qtopia::escapeString(value) + "<br>";
552 552
553 // rest of Home data 553 // rest of Home data
554 str = homeWebpage(); 554 str = homeWebpage();
555 if ( !str.isEmpty() ){ 555 if ( !str.isEmpty() ){
556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 556 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
557 + Qtopia::escapeString(str) + "<br>"; 557 + Qtopia::escapeString(str) + "<br>";
558 marker = true; 558 marker = true;
559 } 559 }
560 str = homePhone(); 560 str = homePhone();
561 if ( !str.isEmpty() ){ 561 if ( !str.isEmpty() ){
562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 562 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
563 + Qtopia::escapeString(str) + "<br>"; 563 + Qtopia::escapeString(str) + "<br>";
564 marker = true; 564 marker = true;
565 } 565 }
566 str = homeFax(); 566 str = homeFax();
567 if ( !str.isEmpty() ){ 567 if ( !str.isEmpty() ){
568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 568 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
569 + Qtopia::escapeString(str) + "<br>"; 569 + Qtopia::escapeString(str) + "<br>";
570 marker = true; 570 marker = true;
571 } 571 }
572 str = homeMobile(); 572 str = homeMobile();
573 if ( !str.isEmpty() ){ 573 if ( !str.isEmpty() ){
574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 574 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
575 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
576 marker = true; 576 marker = true;
577 } 577 }
578 578
579 if ( marker ) 579 if ( marker )
580 text += "<br><hr><br>"; 580 text += "<br><hr><br>";
581 // the others... 581 // the others...
582 str = emails(); 582 str = emails();
583 if ( !str.isEmpty() && ( str != defEmail ) ) 583 if ( !str.isEmpty() && ( str != defEmail ) )
584 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 584 text += "<b>" + QObject::tr("All Emails: ") + "</b>"
585 + Qtopia::escapeString(str) + "<br>"; 585 + Qtopia::escapeString(str) + "<br>";
586 str = profession(); 586 str = profession();
587 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
588 text += "<b>" + QObject::tr("Profession: ") + "</b>" 588 text += "<b>" + QObject::tr("Profession: ") + "</b>"
589 + Qtopia::escapeString(str) + "<br>"; 589 + Qtopia::escapeString(str) + "<br>";
590 str = assistant(); 590 str = assistant();
591 if ( !str.isEmpty() ) 591 if ( !str.isEmpty() )
592 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 592 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
593 + Qtopia::escapeString(str) + "<br>"; 593 + Qtopia::escapeString(str) + "<br>";
594 str = manager(); 594 str = manager();
595 if ( !str.isEmpty() ) 595 if ( !str.isEmpty() )
596 text += "<b>" + QObject::tr("Manager: ") + "</b>" 596 text += "<b>" + QObject::tr("Manager: ") + "</b>"
597 + Qtopia::escapeString(str) + "<br>"; 597 + Qtopia::escapeString(str) + "<br>";
598 str = gender(); 598 str = gender();
599 if ( !str.isEmpty() && str.toInt() != 0 ) { 599 if ( !str.isEmpty() && str.toInt() != 0 ) {
600 if ( str.toInt() == 1 ) 600 if ( str.toInt() == 1 )
601 str = QObject::tr( "Male" ); 601 str = QObject::tr( "Male" );
602 else if ( str.toInt() == 2 ) 602 else if ( str.toInt() == 2 )
603 str = QObject::tr( "Female" ); 603 str = QObject::tr( "Female" );
604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 604 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
605 } 605 }
606 str = spouse(); 606 str = spouse();
607 if ( !str.isEmpty() ) 607 if ( !str.isEmpty() )
608 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 608 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
609 + Qtopia::escapeString(str) + "<br>"; 609 + Qtopia::escapeString(str) + "<br>";
610 if ( birthday().isValid() ){ 610 if ( birthday().isValid() ){
611 str = TimeString::numberDateString( birthday() ); 611 str = TimeString::numberDateString( birthday() );
612 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 612 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
613 + Qtopia::escapeString(str) + "<br>"; 613 + Qtopia::escapeString(str) + "<br>";
614 } 614 }
615 if ( anniversary().isValid() ){ 615 if ( anniversary().isValid() ){
616 str = TimeString::numberDateString( anniversary() ); 616 str = TimeString::numberDateString( anniversary() );
617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 617 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
618 + Qtopia::escapeString(str) + "<br>"; 618 + Qtopia::escapeString(str) + "<br>";
619 } 619 }
620 str = children(); 620 str = children();
621 if ( !str.isEmpty() ) 621 if ( !str.isEmpty() )
622 text += "<b>" + QObject::tr("Children: ") + "</b>" 622 text += "<b>" + QObject::tr("Children: ") + "</b>"
623 + Qtopia::escapeString(str) + "<br>"; 623 + Qtopia::escapeString(str) + "<br>";
624 624
625 str = nickname(); 625 str = nickname();
626 if ( !str.isEmpty() ) 626 if ( !str.isEmpty() )
627 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 627 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
628 + Qtopia::escapeString(str) + "<br>"; 628 + Qtopia::escapeString(str) + "<br>";
629 629
630 if ( categoryNames().count() ){ 630 if ( categoryNames("Contacts").count() ){
631 text += "<b>" + QObject::tr( "Category:") + "</b> "; 631 text += "<b>" + QObject::tr( "Category:") + "</b> ";
632 text += categoryNames().join(", "); 632 text += categoryNames("Contacts").join(", ");
633 text += "<br>"; 633 text += "<br>";
634 } 634 }
635 635
636 // notes last 636 // notes last
637 if ( !(value = notes()).isEmpty() ) { 637 if ( !(value = notes()).isEmpty() ) {
638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 638 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
639 QRegExp reg("\n"); 639 QRegExp reg("\n");
640 640
641 //QString tmp = Qtopia::escapeString(value); 641 //QString tmp = Qtopia::escapeString(value);
642 QString tmp = QStyleSheet::convertFromPlainText(value); 642 QString tmp = QStyleSheet::convertFromPlainText(value);
643 //tmp.replace( reg, "<br>" ); 643 //tmp.replace( reg, "<br>" );
644 text += "<br>" + tmp + "<br>"; 644 text += "<br>" + tmp + "<br>";
645 } 645 }
646 return text; 646 return text;
647} 647}
648 648
649/*! 649/*!
650 \internal 650 \internal
651*/ 651*/
652void OContact::insert( int key, const QString &v ) 652void OContact::insert( int key, const QString &v )
653{ 653{
654 QString value = v.stripWhiteSpace(); 654 QString value = v.stripWhiteSpace();
655 if ( value.isEmpty() ) 655 if ( value.isEmpty() )
656 mMap.remove( key ); 656 mMap.remove( key );
657 else 657 else
658 mMap.insert( key, value ); 658 mMap.insert( key, value );
659} 659}
660 660
661/*! 661/*!
662 \internal 662 \internal
663*/ 663*/
664void OContact::replace( int key, const QString & v ) 664void OContact::replace( int key, const QString & v )
665{ 665{
666 QString value = v.stripWhiteSpace(); 666 QString value = v.stripWhiteSpace();
667 if ( value.isEmpty() ) 667 if ( value.isEmpty() )
668 mMap.remove( key ); 668 mMap.remove( key );
669 else 669 else
670 mMap.replace( key, value ); 670 mMap.replace( key, value );
671} 671}
672 672
673/*! 673/*!
674 \internal 674 \internal
675*/ 675*/
676QString OContact::find( int key ) const 676QString OContact::find( int key ) const
677{ 677{
678 return mMap[key]; 678 return mMap[key];
679} 679}
680 680
681/*! 681/*!
682 \internal 682 \internal
683*/ 683*/
684QString OContact::displayAddress( const QString &street, 684QString OContact::displayAddress( const QString &street,
685 const QString &city, 685 const QString &city,
686 const QString &state, 686 const QString &state,
687 const QString &zip, 687 const QString &zip,
688 const QString &country ) const 688 const QString &country ) const
689{ 689{
690 QString s = street; 690 QString s = street;
691 if ( !street.isEmpty() ) 691 if ( !street.isEmpty() )
692 s+= "\n"; 692 s+= "\n";
693 s += city; 693 s += city;
694 if ( !city.isEmpty() && !state.isEmpty() ) 694 if ( !city.isEmpty() && !state.isEmpty() )
695 s += ", "; 695 s += ", ";
696 s += state; 696 s += state;
697 if ( !state.isEmpty() && !zip.isEmpty() ) 697 if ( !state.isEmpty() && !zip.isEmpty() )
698 s += " "; 698 s += " ";
699 s += zip; 699 s += zip;
700 if ( !country.isEmpty() && !s.isEmpty() ) 700 if ( !country.isEmpty() && !s.isEmpty() )
701 s += "\n"; 701 s += "\n";
702 s += country; 702 s += country;
703 return s; 703 return s;
704} 704}
705 705
706/*! 706/*!
707 \internal 707 \internal
708*/ 708*/
709QString OContact::displayBusinessAddress() const 709QString OContact::displayBusinessAddress() const
710{ 710{
711 return displayAddress( businessStreet(), businessCity(), 711 return displayAddress( businessStreet(), businessCity(),
712 businessState(), businessZip(), 712 businessState(), businessZip(),
713 businessCountry() ); 713 businessCountry() );
714} 714}
715 715
716/*! 716/*!
717 \internal 717 \internal
718*/ 718*/
719QString OContact::displayHomeAddress() const 719QString OContact::displayHomeAddress() const
720{ 720{
721 return displayAddress( homeStreet(), homeCity(), 721 return displayAddress( homeStreet(), homeCity(),
722 homeState(), homeZip(), 722 homeState(), homeZip(),
723 homeCountry() ); 723 homeCountry() );
724} 724}
725 725
726/*! 726/*!
727 Returns the full name of the contact 727 Returns the full name of the contact
728*/ 728*/
729QString OContact::fullName() const 729QString OContact::fullName() const
730{ 730{
731 QString title = find( Qtopia::Title ); 731 QString title = find( Qtopia::Title );
732 QString firstName = find( Qtopia::FirstName ); 732 QString firstName = find( Qtopia::FirstName );
733 QString middleName = find( Qtopia::MiddleName ); 733 QString middleName = find( Qtopia::MiddleName );
734 QString lastName = find( Qtopia::LastName ); 734 QString lastName = find( Qtopia::LastName );
735 QString suffix = find( Qtopia::Suffix ); 735 QString suffix = find( Qtopia::Suffix );
736 736
737 QString name = title; 737 QString name = title;
738 if ( !firstName.isEmpty() ) { 738 if ( !firstName.isEmpty() ) {
739 if ( !name.isEmpty() ) 739 if ( !name.isEmpty() )
740 name += " "; 740 name += " ";
741 name += firstName; 741 name += firstName;
742 } 742 }
743 if ( !middleName.isEmpty() ) { 743 if ( !middleName.isEmpty() ) {
744 if ( !name.isEmpty() ) 744 if ( !name.isEmpty() )
745 name += " "; 745 name += " ";
746 name += middleName; 746 name += middleName;
747 } 747 }
748 if ( !lastName.isEmpty() ) { 748 if ( !lastName.isEmpty() ) {
749 if ( !name.isEmpty() ) 749 if ( !name.isEmpty() )
750 name += " "; 750 name += " ";
751 name += lastName; 751 name += lastName;
752 } 752 }
753 if ( !suffix.isEmpty() ) { 753 if ( !suffix.isEmpty() ) {
754 if ( !name.isEmpty() ) 754 if ( !name.isEmpty() )
755 name += " "; 755 name += " ";
756 name += suffix; 756 name += suffix;
757 } 757 }
758 return name.simplifyWhiteSpace(); 758 return name.simplifyWhiteSpace();
759} 759}
760 760
761/*! 761/*!
762 Returns a list of the names of the children of the contact. 762 Returns a list of the names of the children of the contact.
763*/ 763*/
764QStringList OContact::childrenList() const 764QStringList OContact::childrenList() const
765{ 765{
766 return QStringList::split( " ", find( Qtopia::Children ) ); 766 return QStringList::split( " ", find( Qtopia::Children ) );
767} 767}
768 768
769/*! \fn void OContact::insertEmail( const QString &email ) 769/*! \fn void OContact::insertEmail( const QString &email )
770 770
771 Insert \a email into the email list. Ensures \a email can only be added 771 Insert \a email into the email list. Ensures \a email can only be added
772 once. If there is no default email address set, it sets it to the \a email. 772 once. If there is no default email address set, it sets it to the \a email.
773*/ 773*/
774 774
775/*! \fn void OContact::removeEmail( const QString &email ) 775/*! \fn void OContact::removeEmail( const QString &email )
776 776
777 Removes the \a email from the email list. If the default email was \a email, 777 Removes the \a email from the email list. If the default email was \a email,
778 then the default email address is assigned to the first email in the 778 then the default email address is assigned to the first email in the
779 email list 779 email list
780*/ 780*/
781 781
782/*! \fn void OContact::clearEmails() 782/*! \fn void OContact::clearEmails()
783 783
784 Clears the email list. 784 Clears the email list.
785 */ 785 */
786 786
787/*! \fn void OContact::insertEmails( const QStringList &emailList ) 787/*! \fn void OContact::insertEmails( const QStringList &emailList )
788 788
789 Appends the \a emailList to the exiting email list 789 Appends the \a emailList to the exiting email list
790 */ 790 */
791 791
792/*! 792/*!
793 Returns a list of email addresses belonging to the contact, including 793 Returns a list of email addresses belonging to the contact, including
794 the default email address. 794 the default email address.
795*/ 795*/
796QStringList OContact::emailList() const 796QStringList OContact::emailList() const
797{ 797{
798 QString emailStr = emails(); 798 QString emailStr = emails();
799 799
800 QStringList r; 800 QStringList r;
801 if ( !emailStr.isEmpty() ) { 801 if ( !emailStr.isEmpty() ) {
802 qDebug(" emailstr "); 802 qDebug(" emailstr ");
803 QStringList l = QStringList::split( emailSeparator(), emailStr ); 803 QStringList l = QStringList::split( emailSeparator(), emailStr );
804 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 804 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
805 r += (*it).simplifyWhiteSpace(); 805 r += (*it).simplifyWhiteSpace();
806 } 806 }
807 807
808 return r; 808 return r;
809} 809}
810 810
811/*! 811/*!
812 \overload 812 \overload
813 813
814 Generates the string for the contact to be filed as from the first, 814 Generates the string for the contact to be filed as from the first,
815 middle and last name of the contact. 815 middle and last name of the contact.
816*/ 816*/
817void OContact::setFileAs() 817void OContact::setFileAs()
818{ 818{
819 QString lastName, firstName, middleName, fileas; 819 QString lastName, firstName, middleName, fileas;
820 820
821 lastName = find( Qtopia::LastName ); 821 lastName = find( Qtopia::LastName );
822 firstName = find( Qtopia::FirstName ); 822 firstName = find( Qtopia::FirstName );
823 middleName = find( Qtopia::MiddleName ); 823 middleName = find( Qtopia::MiddleName );
824 if ( !lastName.isEmpty() && !firstName.isEmpty() 824 if ( !lastName.isEmpty() && !firstName.isEmpty()
825 && !middleName.isEmpty() ) 825 && !middleName.isEmpty() )
826 fileas = lastName + ", " + firstName + " " + middleName; 826 fileas = lastName + ", " + firstName + " " + middleName;
827 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 827 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
828 fileas = lastName + ", " + firstName; 828 fileas = lastName + ", " + firstName;
829 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 829 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
830 !middleName.isEmpty() ) 830 !middleName.isEmpty() )
831 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 831 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
832 + middleName + ( middleName.isEmpty() ? "" : " " ) 832 + middleName + ( middleName.isEmpty() ? "" : " " )
833 + lastName; 833 + lastName;
834 834
835 replace( Qtopia::FileAs, fileas ); 835 replace( Qtopia::FileAs, fileas );
836} 836}
837 837
838/*! 838/*!
839 \internal 839 \internal
840 Appends the contact information to \a buf. 840 Appends the contact information to \a buf.
841*/ 841*/
842void OContact::save( QString &buf ) const 842void OContact::save( QString &buf ) const
843{ 843{
844 static const QStringList SLFIELDS = fields(); 844 static const QStringList SLFIELDS = fields();
845 // I'm expecting "<Contact " in front of this... 845 // I'm expecting "<Contact " in front of this...
846 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 846 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
847 it != mMap.end(); ++it ) { 847 it != mMap.end(); ++it ) {
848 const QString &value = it.data(); 848 const QString &value = it.data();
849 int key = it.key(); 849 int key = it.key();
850 if ( !value.isEmpty() ) { 850 if ( !value.isEmpty() ) {
851 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 851 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
852 continue; 852 continue;
853 853
854 key -= Qtopia::AddressCategory+1; 854 key -= Qtopia::AddressCategory+1;
855 buf += SLFIELDS[key]; 855 buf += SLFIELDS[key];
856 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 856 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
857 } 857 }
858 } 858 }
859 buf += customToXml(); 859 buf += customToXml();
860 if ( categories().count() > 0 ) 860 if ( categories().count() > 0 )
861 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 861 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
862 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 862 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
863 // You need to close this yourself 863 // You need to close this yourself
864} 864}
865 865
866 866
867/*! 867/*!
868 \internal 868 \internal
869 Returns the list of fields belonging to a contact 869 Returns the list of fields belonging to a contact
870 Never change order of this list ! It has to be regarding 870 Never change order of this list ! It has to be regarding
871 enum AddressBookFields !! 871 enum AddressBookFields !!
872*/ 872*/
873QStringList OContact::fields() 873QStringList OContact::fields()
874{ 874{
875 QStringList list; 875 QStringList list;
876 876
877 list.append( "Title" ); // Not Used! 877 list.append( "Title" ); // Not Used!
878 list.append( "FirstName" ); 878 list.append( "FirstName" );
879 list.append( "MiddleName" ); 879 list.append( "MiddleName" );
880 list.append( "LastName" ); 880 list.append( "LastName" );
881 list.append( "Suffix" ); 881 list.append( "Suffix" );
882 list.append( "FileAs" ); 882 list.append( "FileAs" );
883 883
884 list.append( "JobTitle" ); 884 list.append( "JobTitle" );
885 list.append( "Department" ); 885 list.append( "Department" );
886 list.append( "Company" ); 886 list.append( "Company" );
887 list.append( "BusinessPhone" ); 887 list.append( "BusinessPhone" );
888 list.append( "BusinessFax" ); 888 list.append( "BusinessFax" );
889 list.append( "BusinessMobile" ); 889 list.append( "BusinessMobile" );
890 890
891 list.append( "DefaultEmail" ); 891 list.append( "DefaultEmail" );
892 list.append( "Emails" ); 892 list.append( "Emails" );
893 893
894 list.append( "HomePhone" ); 894 list.append( "HomePhone" );
895 list.append( "HomeFax" ); 895 list.append( "HomeFax" );
896 list.append( "HomeMobile" ); 896 list.append( "HomeMobile" );
897 897
898 list.append( "BusinessStreet" ); 898 list.append( "BusinessStreet" );
899 list.append( "BusinessCity" ); 899 list.append( "BusinessCity" );
900 list.append( "BusinessState" ); 900 list.append( "BusinessState" );
901 list.append( "BusinessZip" ); 901 list.append( "BusinessZip" );
902 list.append( "BusinessCountry" ); 902 list.append( "BusinessCountry" );
903 list.append( "BusinessPager" ); 903 list.append( "BusinessPager" );
904 list.append( "BusinessWebPage" ); 904 list.append( "BusinessWebPage" );
905 905
906 list.append( "Office" ); 906 list.append( "Office" );
907 list.append( "Profession" ); 907 list.append( "Profession" );
908 list.append( "Assistant" ); 908 list.append( "Assistant" );
909 list.append( "Manager" ); 909 list.append( "Manager" );
910 910
911 list.append( "HomeStreet" ); 911 list.append( "HomeStreet" );
912 list.append( "HomeCity" ); 912 list.append( "HomeCity" );
913 list.append( "HomeState" ); 913 list.append( "HomeState" );
914 list.append( "HomeZip" ); 914 list.append( "HomeZip" );
915 list.append( "HomeCountry" ); 915 list.append( "HomeCountry" );
916 list.append( "HomeWebPage" ); 916 list.append( "HomeWebPage" );
917 917
918 list.append( "Spouse" ); 918 list.append( "Spouse" );
919 list.append( "Gender" ); 919 list.append( "Gender" );
920 list.append( "Birthday" ); 920 list.append( "Birthday" );
921 list.append( "Anniversary" ); 921 list.append( "Anniversary" );
922 list.append( "Nickname" ); 922 list.append( "Nickname" );
923 list.append( "Children" ); 923 list.append( "Children" );
924 924
925 list.append( "Notes" ); 925 list.append( "Notes" );
926 list.append( "Groups" ); 926 list.append( "Groups" );
927 927
928 return list; 928 return list;
929} 929}
930 930
931 931
932/*! 932/*!
933 Sets the list of email address for contact to those contained in \a str. 933 Sets the list of email address for contact to those contained in \a str.
934 Email address should be separated by ';'s. 934 Email address should be separated by ';'s.
935*/ 935*/
936void OContact::setEmails( const QString &str ) 936void OContact::setEmails( const QString &str )
937{ 937{
938 replace( Qtopia::Emails, str ); 938 replace( Qtopia::Emails, str );
939 if ( str.isEmpty() ) 939 if ( str.isEmpty() )
940 setDefaultEmail( QString::null ); 940 setDefaultEmail( QString::null );
941} 941}
942 942
943/*! 943/*!
944 Sets the list of children for the contact to those contained in \a str. 944 Sets the list of children for the contact to those contained in \a str.
945*/ 945*/
946void OContact::setChildren( const QString &str ) 946void OContact::setChildren( const QString &str )
947{ 947{
948 replace( Qtopia::Children, str ); 948 replace( Qtopia::Children, str );
949} 949}
950 950
951/*! 951/*!
952 Returns TRUE if the contact matches the regular expression \a regexp. 952 Returns TRUE if the contact matches the regular expression \a regexp.
953 Otherwise returns FALSE. 953 Otherwise returns FALSE.
954*/ 954*/
955bool OContact::match( const QString &regexp ) const 955bool OContact::match( const QString &regexp ) const
956{ 956{
957 return match(QRegExp(regexp)); 957 return match(QRegExp(regexp));
958} 958}
959 959
960/*! 960/*!
961 \overload 961 \overload
962 Returns TRUE if the contact matches the regular expression \a regexp. 962 Returns TRUE if the contact matches the regular expression \a regexp.
963 Otherwise returns FALSE. 963 Otherwise returns FALSE.
964*/ 964*/
965bool OContact::match( const QRegExp &r ) const 965bool OContact::match( const QRegExp &r ) const
966{ 966{
967 bool match; 967 bool match;
968 match = false; 968 match = false;
969 QMap<int, QString>::ConstIterator it; 969 QMap<int, QString>::ConstIterator it;
970 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 970 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
971 if ( (*it).find( r ) > -1 ) { 971 if ( (*it).find( r ) > -1 ) {
972 match = true; 972 match = true;
973 break; 973 break;
974 } 974 }
975 } 975 }
976 return match; 976 return match;
977} 977}
978 978
979 979
980QString OContact::toShortText() const 980QString OContact::toShortText() const
981{ 981{
982 return ( fullName() ); 982 return ( fullName() );
983} 983}
984QString OContact::type() const 984QString OContact::type() const
985{ 985{
986 return QString::fromLatin1( "OContact" ); 986 return QString::fromLatin1( "OContact" );
987} 987}
988 988
989// Definition is missing ! (se) 989// Definition is missing ! (se)
990QMap<QString,QString> OContact::toExtraMap() const 990QMap<QString,QString> OContact::toExtraMap() const
991{ 991{
992 qWarning ("Function not implemented: OContact::toExtraMap()"); 992 qWarning ("Function not implemented: OContact::toExtraMap()");
993 QMap <QString,QString> useless; 993 QMap <QString,QString> useless;
994 return useless; 994 return useless;
995} 995}
996 996
997class QString OContact::recordField( int pos ) const 997class QString OContact::recordField( int pos ) const
998{ 998{
999 QStringList SLFIELDS = fields(); // ?? why this ? (se) 999 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1000 return SLFIELDS[pos]; 1000 return SLFIELDS[pos];
1001} 1001}
1002 1002
1003// In future releases, we should store birthday and anniversary 1003// In future releases, we should store birthday and anniversary
1004// internally as QDate instead of QString ! 1004// internally as QDate instead of QString !
1005// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1005// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1006 1006
1007/*! \fn void OContact::setBirthday( const QDate& date ) 1007/*! \fn void OContact::setBirthday( const QDate& date )
1008 Sets the birthday for the contact to \a date. If date is null 1008 Sets the birthday for the contact to \a date. If date is null
1009 the current stored date will be removed. 1009 the current stored date will be removed.
1010*/ 1010*/
1011void OContact::setBirthday( const QDate &v ) 1011void OContact::setBirthday( const QDate &v )
1012{ 1012{
1013 if ( v.isNull() ){ 1013 if ( v.isNull() ){
1014 qWarning( "Remove Birthday"); 1014 qWarning( "Remove Birthday");
1015 replace( Qtopia::Birthday, QString::null ); 1015 replace( Qtopia::Birthday, QString::null );
1016 return; 1016 return;
1017 } 1017 }
1018 1018
1019 if ( v.isValid() ) 1019 if ( v.isValid() )
1020 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1020 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
1021 1021
1022} 1022}
1023 1023
1024 1024
1025/*! \fn void OContact::setAnniversary( const QDate &date ) 1025/*! \fn void OContact::setAnniversary( const QDate &date )
1026 Sets the anniversary of the contact to \a date. If date is 1026 Sets the anniversary of the contact to \a date. If date is
1027 null, the current stored date will be removed. 1027 null, the current stored date will be removed.
1028*/ 1028*/
1029void OContact::setAnniversary( const QDate &v ) 1029void OContact::setAnniversary( const QDate &v )
1030{ 1030{
1031 if ( v.isNull() ){ 1031 if ( v.isNull() ){
1032 qWarning( "Remove Anniversary"); 1032 qWarning( "Remove Anniversary");
1033 replace( Qtopia::Anniversary, QString::null ); 1033 replace( Qtopia::Anniversary, QString::null );
1034 return; 1034 return;
1035 } 1035 }
1036 1036
1037 if ( v.isValid() ) 1037 if ( v.isValid() )
1038 replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); 1038 replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
1039} 1039}
1040 1040
1041/*! \fn QDate OContact::birthday() const 1041/*! \fn QDate OContact::birthday() const
1042 Returns the birthday of the contact. 1042 Returns the birthday of the contact.
1043*/ 1043*/
1044QDate OContact::birthday() const 1044QDate OContact::birthday() const
1045{ 1045{
1046 QString str = find( Qtopia::Birthday ); 1046 QString str = find( Qtopia::Birthday );
1047 qWarning ("Birthday %s", str.latin1() ); 1047 qWarning ("Birthday %s", str.latin1() );
1048 if ( !str.isEmpty() ) 1048 if ( !str.isEmpty() )
1049 return TimeConversion::fromString ( str ); 1049 return TimeConversion::fromString ( str );
1050 else 1050 else
1051 return QDate(); 1051 return QDate();
1052} 1052}
1053 1053
1054 1054
1055/*! \fn QDate OContact::anniversary() const 1055/*! \fn QDate OContact::anniversary() const
1056 Returns the anniversary of the contact. 1056 Returns the anniversary of the contact.
1057*/ 1057*/
1058QDate OContact::anniversary() const 1058QDate OContact::anniversary() const
1059{ 1059{
1060 QDate empty; 1060 QDate empty;
1061 QString str = find( Qtopia::Anniversary ); 1061 QString str = find( Qtopia::Anniversary );
1062 qWarning ("Anniversary %s", str.latin1() ); 1062 qWarning ("Anniversary %s", str.latin1() );
1063 if ( !str.isEmpty() ) 1063 if ( !str.isEmpty() )
1064 return TimeConversion::fromString ( str ); 1064 return TimeConversion::fromString ( str );
1065 else 1065 else
1066 return empty; 1066 return empty;
1067} 1067}
1068 1068
1069 1069
1070void OContact::insertEmail( const QString &v ) 1070void OContact::insertEmail( const QString &v )
1071{ 1071{
1072 //qDebug("insertEmail %s", v.latin1()); 1072 //qDebug("insertEmail %s", v.latin1());
1073 QString e = v.simplifyWhiteSpace(); 1073 QString e = v.simplifyWhiteSpace();
1074 QString def = defaultEmail(); 1074 QString def = defaultEmail();
1075 1075
1076 // if no default, set it as the default email and don't insert 1076 // if no default, set it as the default email and don't insert
1077 if ( def.isEmpty() ) { 1077 if ( def.isEmpty() ) {
1078 setDefaultEmail( e ); // will insert into the list for us 1078 setDefaultEmail( e ); // will insert into the list for us
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 // otherwise, insert assuming doesn't already exist 1082 // otherwise, insert assuming doesn't already exist
1083 QString emailsStr = find( Qtopia::Emails ); 1083 QString emailsStr = find( Qtopia::Emails );
1084 if ( emailsStr.contains( e )) 1084 if ( emailsStr.contains( e ))
1085 return; 1085 return;
1086 if ( !emailsStr.isEmpty() ) 1086 if ( !emailsStr.isEmpty() )
1087 emailsStr += emailSeparator(); 1087 emailsStr += emailSeparator();
1088 emailsStr += e; 1088 emailsStr += e;
1089 replace( Qtopia::Emails, emailsStr ); 1089 replace( Qtopia::Emails, emailsStr );
1090} 1090}
1091 1091
1092void OContact::removeEmail( const QString &v ) 1092void OContact::removeEmail( const QString &v )
1093{ 1093{
1094 QString e = v.simplifyWhiteSpace(); 1094 QString e = v.simplifyWhiteSpace();
1095 QString def = defaultEmail(); 1095 QString def = defaultEmail();
1096 QString emailsStr = find( Qtopia::Emails ); 1096 QString emailsStr = find( Qtopia::Emails );
1097 QStringList emails = emailList(); 1097 QStringList emails = emailList();
1098 1098
1099 // otherwise, must first contain it 1099 // otherwise, must first contain it
1100 if ( !emailsStr.contains( e ) ) 1100 if ( !emailsStr.contains( e ) )
1101 return; 1101 return;
1102 1102
1103 // remove it 1103 // remove it
1104 //qDebug(" removing email from list %s", e.latin1()); 1104 //qDebug(" removing email from list %s", e.latin1());
1105 emails.remove( e ); 1105 emails.remove( e );
1106 // reset the string 1106 // reset the string
1107 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 1107 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1108 replace( Qtopia::Emails, emailsStr ); 1108 replace( Qtopia::Emails, emailsStr );
1109 1109
1110 // if default, then replace the default email with the first one 1110 // if default, then replace the default email with the first one
1111 if ( def == e ) { 1111 if ( def == e ) {
1112 //qDebug("removeEmail is default; setting new default"); 1112 //qDebug("removeEmail is default; setting new default");
1113 if ( !emails.count() ) 1113 if ( !emails.count() )
1114 clearEmails(); 1114 clearEmails();
1115 else // setDefaultEmail will remove e from the list 1115 else // setDefaultEmail will remove e from the list
1116 setDefaultEmail( emails.first() ); 1116 setDefaultEmail( emails.first() );
1117 } 1117 }
1118} 1118}
1119void OContact::clearEmails() 1119void OContact::clearEmails()
1120{ 1120{
1121 mMap.remove( Qtopia::DefaultEmail ); 1121 mMap.remove( Qtopia::DefaultEmail );
1122 mMap.remove( Qtopia::Emails ); 1122 mMap.remove( Qtopia::Emails );
1123} 1123}
1124void OContact::setDefaultEmail( const QString &v ) 1124void OContact::setDefaultEmail( const QString &v )
1125{ 1125{
1126 QString e = v.simplifyWhiteSpace(); 1126 QString e = v.simplifyWhiteSpace();
1127 1127
1128 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1128 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1129 replace( Qtopia::DefaultEmail, e ); 1129 replace( Qtopia::DefaultEmail, e );
1130 1130
1131 if ( !e.isEmpty() ) 1131 if ( !e.isEmpty() )
1132 insertEmail( e ); 1132 insertEmail( e );
1133 1133
1134} 1134}
1135 1135
1136void OContact::insertEmails( const QStringList &v ) 1136void OContact::insertEmails( const QStringList &v )
1137{ 1137{
1138 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1138 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1139 insertEmail( *it ); 1139 insertEmail( *it );
1140} 1140}
1141int OContact::rtti() { 1141int OContact::rtti() {
1142 return OPimResolver::AddressBook; 1142 return OPimResolver::AddressBook;
1143} 1143}
1144void OContact::setUid( int i ) 1144void OContact::setUid( int i )
1145{ 1145{
1146 OPimRecord::setUid(i); 1146 OPimRecord::setUid(i);
1147 replace( Qtopia::AddressUid , QString::number(i)); 1147 replace( Qtopia::AddressUid , QString::number(i));
1148} 1148}
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index cde2b3d..b4d4aa9 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -1,422 +1,422 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h" 18#include "opimnotifymanager.h"
19#include "opimresolver.h" 19#include "opimresolver.h"
20 20
21#include "otodo.h" 21#include "otodo.h"
22 22
23 23
24struct OTodo::OTodoData : public QShared { 24struct OTodo::OTodoData : public QShared {
25 OTodoData() : QShared() { 25 OTodoData() : QShared() {
26 }; 26 };
27 27
28 QDate date; 28 QDate date;
29 bool isCompleted:1; 29 bool isCompleted:1;
30 bool hasDate:1; 30 bool hasDate:1;
31 int priority; 31 int priority;
32 QString desc; 32 QString desc;
33 QString sum; 33 QString sum;
34 QMap<QString, QString> extra; 34 QMap<QString, QString> extra;
35 ushort prog; 35 ushort prog;
36 OPimState state; 36 OPimState state;
37 ORecur recur; 37 ORecur recur;
38 OPimMaintainer maintainer; 38 OPimMaintainer maintainer;
39 QDate start; 39 QDate start;
40 QDate completed; 40 QDate completed;
41 OPimNotifyManager notifiers; 41 OPimNotifyManager notifiers;
42}; 42};
43 43
44OTodo::OTodo(const OTodo &event ) 44OTodo::OTodo(const OTodo &event )
45 : OPimRecord( event ), data( event.data ) 45 : OPimRecord( event ), data( event.data )
46{ 46{
47 data->ref(); 47 data->ref();
48// qWarning("ref up"); 48// qWarning("ref up");
49} 49}
50OTodo::~OTodo() { 50OTodo::~OTodo() {
51 51
52// qWarning("~OTodo " ); 52// qWarning("~OTodo " );
53 if ( data->deref() ) { 53 if ( data->deref() ) {
54// qWarning("OTodo::dereffing"); 54// qWarning("OTodo::dereffing");
55 delete data; 55 delete data;
56 data = 0l; 56 data = 0l;
57 } 57 }
58} 58}
59OTodo::OTodo(bool completed, int priority, 59OTodo::OTodo(bool completed, int priority,
60 const QArray<int> &category, 60 const QArray<int> &category,
61 const QString& summary, 61 const QString& summary,
62 const QString &description, 62 const QString &description,
63 ushort progress, 63 ushort progress,
64 bool hasDate, QDate date, int uid ) 64 bool hasDate, QDate date, int uid )
65 : OPimRecord( uid ) 65 : OPimRecord( uid )
66{ 66{
67// qWarning("OTodoData " + summary); 67// qWarning("OTodoData " + summary);
68 setCategories( category ); 68 setCategories( category );
69 69
70 data = new OTodoData; 70 data = new OTodoData;
71 71
72 data->date = date; 72 data->date = date;
73 data->isCompleted = completed; 73 data->isCompleted = completed;
74 data->hasDate = hasDate; 74 data->hasDate = hasDate;
75 data->priority = priority; 75 data->priority = priority;
76 data->sum = summary; 76 data->sum = summary;
77 data->prog = progress; 77 data->prog = progress;
78 data->desc = Qtopia::simplifyMultiLineSpace(description ); 78 data->desc = Qtopia::simplifyMultiLineSpace(description );
79} 79}
80OTodo::OTodo(bool completed, int priority, 80OTodo::OTodo(bool completed, int priority,
81 const QStringList &category, 81 const QStringList &category,
82 const QString& summary, 82 const QString& summary,
83 const QString &description, 83 const QString &description,
84 ushort progress, 84 ushort progress,
85 bool hasDate, QDate date, int uid ) 85 bool hasDate, QDate date, int uid )
86 : OPimRecord( uid ) 86 : OPimRecord( uid )
87{ 87{
88// qWarning("OTodoData" + summary); 88// qWarning("OTodoData" + summary);
89 setCategories( idsFromString( category.join(";") ) ); 89 setCategories( idsFromString( category.join(";") ) );
90 90
91 data = new OTodoData; 91 data = new OTodoData;
92 92
93 data->date = date; 93 data->date = date;
94 data->isCompleted = completed; 94 data->isCompleted = completed;
95 data->hasDate = hasDate; 95 data->hasDate = hasDate;
96 data->priority = priority; 96 data->priority = priority;
97 data->sum = summary; 97 data->sum = summary;
98 data->prog = progress; 98 data->prog = progress;
99 data->desc = Qtopia::simplifyMultiLineSpace(description ); 99 data->desc = Qtopia::simplifyMultiLineSpace(description );
100} 100}
101bool OTodo::match( const QRegExp &regExp )const 101bool OTodo::match( const QRegExp &regExp )const
102{ 102{
103 if( QString::number( data->priority ).find( regExp ) != -1 ){ 103 if( QString::number( data->priority ).find( regExp ) != -1 ){
104 return true; 104 return true;
105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
106 return true; 106 return true;
107 }else if(data->desc.find( regExp ) != -1 ){ 107 }else if(data->desc.find( regExp ) != -1 ){
108 return true; 108 return true;
109 }else if(data->sum.find( regExp ) != -1 ) { 109 }else if(data->sum.find( regExp ) != -1 ) {
110 return true; 110 return true;
111 } 111 }
112 return false; 112 return false;
113} 113}
114bool OTodo::isCompleted() const 114bool OTodo::isCompleted() const
115{ 115{
116 return data->isCompleted; 116 return data->isCompleted;
117} 117}
118bool OTodo::hasDueDate() const 118bool OTodo::hasDueDate() const
119{ 119{
120 return data->hasDate; 120 return data->hasDate;
121} 121}
122bool OTodo::hasStartDate()const { 122bool OTodo::hasStartDate()const {
123 return data->start.isValid(); 123 return data->start.isValid();
124} 124}
125bool OTodo::hasCompletedDate()const { 125bool OTodo::hasCompletedDate()const {
126 return data->completed.isValid(); 126 return data->completed.isValid();
127} 127}
128int OTodo::priority()const 128int OTodo::priority()const
129{ 129{
130 return data->priority; 130 return data->priority;
131} 131}
132QString OTodo::summary() const 132QString OTodo::summary() const
133{ 133{
134 return data->sum; 134 return data->sum;
135} 135}
136ushort OTodo::progress() const 136ushort OTodo::progress() const
137{ 137{
138 return data->prog; 138 return data->prog;
139} 139}
140QDate OTodo::dueDate()const 140QDate OTodo::dueDate()const
141{ 141{
142 return data->date; 142 return data->date;
143} 143}
144QDate OTodo::startDate()const { 144QDate OTodo::startDate()const {
145 return data->start; 145 return data->start;
146} 146}
147QDate OTodo::completedDate()const { 147QDate OTodo::completedDate()const {
148 return data->completed; 148 return data->completed;
149} 149}
150QString OTodo::description()const 150QString OTodo::description()const
151{ 151{
152 return data->desc; 152 return data->desc;
153} 153}
154OPimState OTodo::state()const { 154OPimState OTodo::state()const {
155 return data->state; 155 return data->state;
156} 156}
157ORecur OTodo::recurrence()const { 157ORecur OTodo::recurrence()const {
158 return data->recur; 158 return data->recur;
159} 159}
160OPimMaintainer OTodo::maintainer()const { 160OPimMaintainer OTodo::maintainer()const {
161 return data->maintainer; 161 return data->maintainer;
162} 162}
163void OTodo::setCompleted( bool completed ) 163void OTodo::setCompleted( bool completed )
164{ 164{
165 changeOrModify(); 165 changeOrModify();
166 data->isCompleted = completed; 166 data->isCompleted = completed;
167} 167}
168void OTodo::setHasDueDate( bool hasDate ) 168void OTodo::setHasDueDate( bool hasDate )
169{ 169{
170 changeOrModify(); 170 changeOrModify();
171 data->hasDate = hasDate; 171 data->hasDate = hasDate;
172} 172}
173void OTodo::setDescription(const QString &desc ) 173void OTodo::setDescription(const QString &desc )
174{ 174{
175// qWarning( "desc " + desc ); 175// qWarning( "desc " + desc );
176 changeOrModify(); 176 changeOrModify();
177 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 177 data->desc = Qtopia::simplifyMultiLineSpace(desc );
178} 178}
179void OTodo::setSummary( const QString& sum ) 179void OTodo::setSummary( const QString& sum )
180{ 180{
181 changeOrModify(); 181 changeOrModify();
182 data->sum = sum; 182 data->sum = sum;
183} 183}
184void OTodo::setPriority(int prio ) 184void OTodo::setPriority(int prio )
185{ 185{
186 changeOrModify(); 186 changeOrModify();
187 data->priority = prio; 187 data->priority = prio;
188} 188}
189void OTodo::setDueDate( const QDate& date ) 189void OTodo::setDueDate( const QDate& date )
190{ 190{
191 changeOrModify(); 191 changeOrModify();
192 data->date = date; 192 data->date = date;
193} 193}
194void OTodo::setStartDate( const QDate& date ) { 194void OTodo::setStartDate( const QDate& date ) {
195 changeOrModify(); 195 changeOrModify();
196 data->start = date; 196 data->start = date;
197} 197}
198void OTodo::setCompletedDate( const QDate& date ) { 198void OTodo::setCompletedDate( const QDate& date ) {
199 changeOrModify(); 199 changeOrModify();
200 data->completed = date; 200 data->completed = date;
201} 201}
202void OTodo::setState( const OPimState& state ) { 202void OTodo::setState( const OPimState& state ) {
203 changeOrModify(); 203 changeOrModify();
204 data->state = state; 204 data->state = state;
205} 205}
206void OTodo::setRecurrence( const ORecur& rec) { 206void OTodo::setRecurrence( const ORecur& rec) {
207 changeOrModify(); 207 changeOrModify();
208 data->recur = rec; 208 data->recur = rec;
209} 209}
210void OTodo::setMaintainer( const OPimMaintainer& pim ) { 210void OTodo::setMaintainer( const OPimMaintainer& pim ) {
211 changeOrModify(); 211 changeOrModify();
212 data->maintainer = pim; 212 data->maintainer = pim;
213} 213}
214bool OTodo::isOverdue( ) 214bool OTodo::isOverdue( )
215{ 215{
216 if( data->hasDate && !data->isCompleted) 216 if( data->hasDate && !data->isCompleted)
217 return QDate::currentDate() > data->date; 217 return QDate::currentDate() > data->date;
218 return false; 218 return false;
219} 219}
220void OTodo::setProgress(ushort progress ) 220void OTodo::setProgress(ushort progress )
221{ 221{
222 changeOrModify(); 222 changeOrModify();
223 data->prog = progress; 223 data->prog = progress;
224} 224}
225QString OTodo::toShortText() const { 225QString OTodo::toShortText() const {
226 return summary(); 226 return summary();
227} 227}
228/*! 228/*!
229 Returns a richt text string 229 Returns a richt text string
230*/ 230*/
231QString OTodo::toRichText() const 231QString OTodo::toRichText() const
232{ 232{
233 QString text; 233 QString text;
234 QStringList catlist; 234 QStringList catlist;
235 235
236 // Description of the todo 236 // Description of the todo
237 if ( !summary().isEmpty() ) { 237 if ( !summary().isEmpty() ) {
238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
240 } 240 }
241 if( !description().isEmpty() ){ 241 if( !description().isEmpty() ){
242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
244 } 244 }
245 text += "<br><br><br>"; 245 text += "<br><br><br>";
246 246
247 text += "<b>" + QObject::tr( "Priority:") +" </b>" 247 text += "<b>" + QObject::tr( "Priority:") +" </b>"
248 + QString::number( priority() ) + " <br>"; 248 + QString::number( priority() ) + " <br>";
249 text += "<b>" + QObject::tr( "Progress:") + " </b>" 249 text += "<b>" + QObject::tr( "Progress:") + " </b>"
250 + QString::number( progress() ) + " %<br>"; 250 + QString::number( progress() ) + " %<br>";
251 if (hasDueDate() ){ 251 if (hasDueDate() ){
252 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 252 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
253 text += dueDate().toString(); 253 text += dueDate().toString();
254 text += "<br>"; 254 text += "<br>";
255 } 255 }
256 256
257 text += "<b>" + QObject::tr( "Category:") + "</b> "; 257 text += "<b>" + QObject::tr( "Category:") + "</b> ";
258 text += categoryNames().join(", "); 258 text += categoryNames( "Todo List" ).join(", ");
259 text += "<br>"; 259 text += "<br>";
260 260
261 return text; 261 return text;
262} 262}
263OPimNotifyManager& OTodo::notifiers() { 263OPimNotifyManager& OTodo::notifiers() {
264 return data->notifiers; 264 return data->notifiers;
265} 265}
266 266
267bool OTodo::operator<( const OTodo &toDoEvent )const{ 267bool OTodo::operator<( const OTodo &toDoEvent )const{
268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
270 if( hasDueDate() && toDoEvent.hasDueDate() ){ 270 if( hasDueDate() && toDoEvent.hasDueDate() ){
271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
272 return priority() < toDoEvent.priority(); 272 return priority() < toDoEvent.priority();
273 }else{ 273 }else{
274 return dueDate() < toDoEvent.dueDate(); 274 return dueDate() < toDoEvent.dueDate();
275 } 275 }
276 } 276 }
277 return false; 277 return false;
278} 278}
279bool OTodo::operator<=(const OTodo &toDoEvent )const 279bool OTodo::operator<=(const OTodo &toDoEvent )const
280{ 280{
281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
283 if( hasDueDate() && toDoEvent.hasDueDate() ){ 283 if( hasDueDate() && toDoEvent.hasDueDate() ){
284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
285 return priority() <= toDoEvent.priority(); 285 return priority() <= toDoEvent.priority();
286 }else{ 286 }else{
287 return dueDate() <= toDoEvent.dueDate(); 287 return dueDate() <= toDoEvent.dueDate();
288 } 288 }
289 } 289 }
290 return true; 290 return true;
291} 291}
292bool OTodo::operator>(const OTodo &toDoEvent )const 292bool OTodo::operator>(const OTodo &toDoEvent )const
293{ 293{
294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
296 if( hasDueDate() && toDoEvent.hasDueDate() ){ 296 if( hasDueDate() && toDoEvent.hasDueDate() ){
297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
298 return priority() > toDoEvent.priority(); 298 return priority() > toDoEvent.priority();
299 }else{ 299 }else{
300 return dueDate() > toDoEvent.dueDate(); 300 return dueDate() > toDoEvent.dueDate();
301 } 301 }
302 } 302 }
303 return false; 303 return false;
304} 304}
305bool OTodo::operator>=(const OTodo &toDoEvent )const 305bool OTodo::operator>=(const OTodo &toDoEvent )const
306{ 306{
307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
309 if( hasDueDate() && toDoEvent.hasDueDate() ){ 309 if( hasDueDate() && toDoEvent.hasDueDate() ){
310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
311 return priority() > toDoEvent.priority(); 311 return priority() > toDoEvent.priority();
312 }else{ 312 }else{
313 return dueDate() > toDoEvent.dueDate(); 313 return dueDate() > toDoEvent.dueDate();
314 } 314 }
315 } 315 }
316 return true; 316 return true;
317} 317}
318bool OTodo::operator==(const OTodo &toDoEvent )const 318bool OTodo::operator==(const OTodo &toDoEvent )const
319{ 319{
320 if ( data->priority != toDoEvent.data->priority ) return false; 320 if ( data->priority != toDoEvent.data->priority ) return false;
321 if ( data->priority != toDoEvent.data->prog ) return false; 321 if ( data->priority != toDoEvent.data->prog ) return false;
322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
323 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 323 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
324 if ( data->date != toDoEvent.data->date ) return false; 324 if ( data->date != toDoEvent.data->date ) return false;
325 if ( data->sum != toDoEvent.data->sum ) return false; 325 if ( data->sum != toDoEvent.data->sum ) return false;
326 if ( data->desc != toDoEvent.data->desc ) return false; 326 if ( data->desc != toDoEvent.data->desc ) return false;
327 if ( data->maintainer != toDoEvent.data->maintainer ) 327 if ( data->maintainer != toDoEvent.data->maintainer )
328 return false; 328 return false;
329 329
330 return OPimRecord::operator==( toDoEvent ); 330 return OPimRecord::operator==( toDoEvent );
331} 331}
332void OTodo::deref() { 332void OTodo::deref() {
333 333
334// qWarning("deref in ToDoEvent"); 334// qWarning("deref in ToDoEvent");
335 if ( data->deref() ) { 335 if ( data->deref() ) {
336// qWarning("deleting"); 336// qWarning("deleting");
337 delete data; 337 delete data;
338 data= 0; 338 data= 0;
339 } 339 }
340} 340}
341OTodo &OTodo::operator=(const OTodo &item ) 341OTodo &OTodo::operator=(const OTodo &item )
342{ 342{
343 OPimRecord::operator=( item ); 343 OPimRecord::operator=( item );
344 //qWarning("operator= ref "); 344 //qWarning("operator= ref ");
345 item.data->ref(); 345 item.data->ref();
346 deref(); 346 deref();
347 data = item.data; 347 data = item.data;
348 348
349 return *this; 349 return *this;
350} 350}
351 351
352QMap<int, QString> OTodo::toMap() const { 352QMap<int, QString> OTodo::toMap() const {
353 QMap<int, QString> map; 353 QMap<int, QString> map;
354 354
355 map.insert( Uid, QString::number( uid() ) ); 355 map.insert( Uid, QString::number( uid() ) );
356 map.insert( Category, idsToString( categories() ) ); 356 map.insert( Category, idsToString( categories() ) );
357 map.insert( HasDate, QString::number( data->hasDate ) ); 357 map.insert( HasDate, QString::number( data->hasDate ) );
358 map.insert( Completed, QString::number( data->isCompleted ) ); 358 map.insert( Completed, QString::number( data->isCompleted ) );
359 map.insert( Description, data->desc ); 359 map.insert( Description, data->desc );
360 map.insert( Summary, data->sum ); 360 map.insert( Summary, data->sum );
361 map.insert( Priority, QString::number( data->priority ) ); 361 map.insert( Priority, QString::number( data->priority ) );
362 map.insert( DateDay, QString::number( data->date.day() ) ); 362 map.insert( DateDay, QString::number( data->date.day() ) );
363 map.insert( DateMonth, QString::number( data->date.month() ) ); 363 map.insert( DateMonth, QString::number( data->date.month() ) );
364 map.insert( DateYear, QString::number( data->date.year() ) ); 364 map.insert( DateYear, QString::number( data->date.year() ) );
365 map.insert( Progress, QString::number( data->prog ) ); 365 map.insert( Progress, QString::number( data->prog ) );
366// map.insert( CrossReference, crossToString() ); 366// map.insert( CrossReference, crossToString() );
367 /* FIXME!!! map.insert( State, ); 367 /* FIXME!!! map.insert( State, );
368 map.insert( Recurrence, ); 368 map.insert( Recurrence, );
369 map.insert( Reminders, ); 369 map.insert( Reminders, );
370 map. 370 map.
371 */ 371 */
372 return map; 372 return map;
373} 373}
374 374
375QMap<QString, QString> OTodo::toExtraMap()const { 375QMap<QString, QString> OTodo::toExtraMap()const {
376 return data->extra; 376 return data->extra;
377} 377}
378/** 378/**
379 * change or modify looks at the ref count and either 379 * change or modify looks at the ref count and either
380 * creates a new QShared Object or it can modify it 380 * creates a new QShared Object or it can modify it
381 * right in place 381 * right in place
382 */ 382 */
383void OTodo::changeOrModify() { 383void OTodo::changeOrModify() {
384 if ( data->count != 1 ) { 384 if ( data->count != 1 ) {
385 qWarning("changeOrModify"); 385 qWarning("changeOrModify");
386 data->deref(); 386 data->deref();
387 OTodoData* d2 = new OTodoData(); 387 OTodoData* d2 = new OTodoData();
388 copy(data, d2 ); 388 copy(data, d2 );
389 data = d2; 389 data = d2;
390 } 390 }
391} 391}
392// WATCHOUT 392// WATCHOUT
393/* 393/*
394 * if you add something to the Data struct 394 * if you add something to the Data struct
395 * be sure to copy it here 395 * be sure to copy it here
396 */ 396 */
397void OTodo::copy( OTodoData* src, OTodoData* dest ) { 397void OTodo::copy( OTodoData* src, OTodoData* dest ) {
398 dest->date = src->date; 398 dest->date = src->date;
399 dest->isCompleted = src->isCompleted; 399 dest->isCompleted = src->isCompleted;
400 dest->hasDate = src->hasDate; 400 dest->hasDate = src->hasDate;
401 dest->priority = src->priority; 401 dest->priority = src->priority;
402 dest->desc = src->desc; 402 dest->desc = src->desc;
403 dest->sum = src->sum; 403 dest->sum = src->sum;
404 dest->extra = src->extra; 404 dest->extra = src->extra;
405 dest->prog = src->prog; 405 dest->prog = src->prog;
406 dest->state = src->state; 406 dest->state = src->state;
407 dest->recur = src->recur; 407 dest->recur = src->recur;
408 dest->maintainer = src->maintainer; 408 dest->maintainer = src->maintainer;
409 dest->start = src->start; 409 dest->start = src->start;
410 dest->completed = src->completed; 410 dest->completed = src->completed;
411 dest->notifiers = src->notifiers; 411 dest->notifiers = src->notifiers;
412} 412}
413QString OTodo::type() const { 413QString OTodo::type() const {
414 return QString::fromLatin1("OTodo"); 414 return QString::fromLatin1("OTodo");
415} 415}
416QString OTodo::recordField(int /*id*/ )const { 416QString OTodo::recordField(int /*id*/ )const {
417 return QString::null; 417 return QString::null;
418} 418}
419 419
420int OTodo::rtti(){ 420int OTodo::rtti(){
421 return OPimResolver::TodoList; 421 return OPimResolver::TodoList;
422} 422}