author | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
commit | 6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff) | |
tree | 6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/backend/contact.cpp | |
parent | d10cddb3c9ce75bc90b14add14bc133737fe35aa (diff) | |
download | opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2 |
Qtopia1-6 merge
still to test
bic changes to be resolved
more changes to be made?
-rw-r--r-- | library/backend/contact.cpp | 526 |
1 files changed, 505 insertions, 21 deletions
diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index b10b19a..3f4934a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -34,13 +34,32 @@ | |||
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | /*! | ||
38 | \class Contact contact.h | ||
39 | \brief The Contact class holds the data of an address book entry. | ||
40 | |||
41 | This data includes information the name of the person, contact | ||
42 | information, and business information such as deparment and job title. | ||
43 | |||
44 | \ingroup qtopiaemb | ||
45 | \ingroup qtopiadesktop | ||
46 | */ | ||
47 | |||
37 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); | 48 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); |
38 | 49 | ||
50 | /*! | ||
51 | Creates a new, empty contact. | ||
52 | */ | ||
39 | Contact::Contact() | 53 | Contact::Contact() |
40 | : Record(), mMap(), d( 0 ) | 54 | : Record(), mMap(), d( 0 ) |
41 | { | 55 | { |
42 | } | 56 | } |
43 | 57 | ||
58 | /*! | ||
59 | \internal | ||
60 | Creates a new contact. The properties of the contact are | ||
61 | set from \a fromMap. | ||
62 | */ | ||
44 | Contact::Contact( const QMap<int, QString> &fromMap ) : | 63 | Contact::Contact( const QMap<int, QString> &fromMap ) : |
45 | Record(), mMap( fromMap ), d( 0 ) | 64 | Record(), mMap( fromMap ), d( 0 ) |
46 | { | 65 | { |
@@ -48,25 +67,384 @@ Contact::Contact( const QMap<int, QString> &fromMap ) : | |||
48 | if ( !cats.isEmpty() ) | 67 | if ( !cats.isEmpty() ) |
49 | setCategories( idsFromString( cats ) ); | 68 | setCategories( idsFromString( cats ) ); |
50 | QString uidStr = find( Qtopia::AddressUid ); | 69 | QString uidStr = find( Qtopia::AddressUid ); |
70 | |||
51 | if ( uidStr.isEmpty() ) | 71 | if ( uidStr.isEmpty() ) |
52 | setUid( uidGen().generate() ); | 72 | setUid( uidGen().generate() ); |
53 | else | 73 | else |
54 | setUid( uidStr.toInt() ); | 74 | setUid( uidStr.toInt() ); |
75 | |||
76 | if ( !uidStr.isEmpty() ) | ||
77 | setUid( uidStr.toInt() ); | ||
55 | } | 78 | } |
56 | 79 | ||
80 | /*! | ||
81 | Destroys a contact. | ||
82 | */ | ||
57 | Contact::~Contact() | 83 | Contact::~Contact() |
58 | { | 84 | { |
59 | } | 85 | } |
60 | 86 | ||
87 | /*! \fn void Contact::setTitle( const QString &str ) | ||
88 | Sets the title of the contact to \a str. | ||
89 | */ | ||
90 | |||
91 | /*! \fn void Contact::setFirstName( const QString &str ) | ||
92 | Sets the first name of the contact to \a str. | ||
93 | */ | ||
94 | |||
95 | /*! \fn void Contact::setMiddleName( const QString &str ) | ||
96 | Sets the middle name of the contact to \a str. | ||
97 | */ | ||
98 | |||
99 | /*! \fn void Contact::setLastName( const QString &str ) | ||
100 | Sets the last name of the contact to \a str. | ||
101 | */ | ||
102 | |||
103 | /*! \fn void Contact::setSuffix( const QString &str ) | ||
104 | Sets the suffix of the contact to \a str. | ||
105 | */ | ||
106 | |||
107 | /*! \fn void Contact::setFileAs( const QString &str ) | ||
108 | Sets the contact to filed as \a str. | ||
109 | */ | ||
110 | |||
111 | /*! \fn void Contact::setDefaultEmail( const QString &str ) | ||
112 | Sets the default email of the contact to \a str. | ||
113 | */ | ||
114 | |||
115 | /*! \fn void Contact::setHomeStreet( const QString &str ) | ||
116 | Sets the home street address of the contact to \a str. | ||
117 | */ | ||
118 | |||
119 | /*! \fn void Contact::setHomeCity( const QString &str ) | ||
120 | Sets the home city of the contact to \a str. | ||
121 | */ | ||
122 | |||
123 | /*! \fn void Contact::setHomeState( const QString &str ) | ||
124 | Sets the home state of the contact to \a str. | ||
125 | */ | ||
126 | |||
127 | /*! \fn void Contact::setHomeZip( const QString &str ) | ||
128 | Sets the home zip code of the contact to \a str. | ||
129 | */ | ||
130 | |||
131 | /*! \fn void Contact::setHomeCountry( const QString &str ) | ||
132 | Sets the home country of the contact to \a str. | ||
133 | */ | ||
134 | |||
135 | /*! \fn void Contact::setHomePhone( const QString &str ) | ||
136 | Sets the home phone number of the contact to \a str. | ||
137 | */ | ||
138 | |||
139 | /*! \fn void Contact::setHomeFax( const QString &str ) | ||
140 | Sets the home fax number of the contact to \a str. | ||
141 | */ | ||
142 | |||
143 | /*! \fn void Contact::setHomeMobile( const QString &str ) | ||
144 | Sets the home mobile phone number of the contact to \a str. | ||
145 | */ | ||
146 | |||
147 | /*! \fn void Contact::setHomeWebpage( const QString &str ) | ||
148 | Sets the home webpage of the contact to \a str. | ||
149 | */ | ||
150 | |||
151 | /*! \fn void Contact::setCompany( const QString &str ) | ||
152 | Sets the company for contact to \a str. | ||
153 | */ | ||
154 | |||
155 | /*! \fn void Contact::setJobTitle( const QString &str ) | ||
156 | Sets the job title of the contact to \a str. | ||
157 | */ | ||
158 | |||
159 | /*! \fn void Contact::setDepartment( const QString &str ) | ||
160 | Sets the department for contact to \a str. | ||
161 | */ | ||
162 | |||
163 | /*! \fn void Contact::setOffice( const QString &str ) | ||
164 | Sets the office for contact to \a str. | ||
165 | */ | ||
166 | |||
167 | /*! \fn void Contact::setBusinessStreet( const QString &str ) | ||
168 | Sets the business street address of the contact to \a str. | ||
169 | */ | ||
170 | |||
171 | /*! \fn void Contact::setBusinessCity( const QString &str ) | ||
172 | Sets the business city of the contact to \a str. | ||
173 | */ | ||
174 | |||
175 | /*! \fn void Contact::setBusinessState( const QString &str ) | ||
176 | Sets the business state of the contact to \a str. | ||
177 | */ | ||
178 | |||
179 | /*! \fn void Contact::setBusinessZip( const QString &str ) | ||
180 | Sets the business zip code of the contact to \a str. | ||
181 | */ | ||
182 | |||
183 | /*! \fn void Contact::setBusinessCountry( const QString &str ) | ||
184 | Sets the business country of the contact to \a str. | ||
185 | */ | ||
186 | |||
187 | /*! \fn void Contact::setBusinessPhone( const QString &str ) | ||
188 | Sets the business phone number of the contact to \a str. | ||
189 | */ | ||
190 | |||
191 | /*! \fn void Contact::setBusinessFax( const QString &str ) | ||
192 | Sets the business fax number of the contact to \a str. | ||
193 | */ | ||
194 | |||
195 | /*! \fn void Contact::setBusinessMobile( const QString &str ) | ||
196 | Sets the business mobile phone number of the contact to \a str. | ||
197 | */ | ||
198 | |||
199 | /*! \fn void Contact::setBusinessPager( const QString &str ) | ||
200 | Sets the business pager number of the contact to \a str. | ||
201 | */ | ||
202 | |||
203 | /*! \fn void Contact::setBusinessWebpage( const QString &str ) | ||
204 | Sets the business webpage of the contact to \a str. | ||
205 | */ | ||
206 | |||
207 | /*! \fn void Contact::setProfession( const QString &str ) | ||
208 | Sets the profession of the contact to \a str. | ||
209 | */ | ||
210 | |||
211 | /*! \fn void Contact::setAssistant( const QString &str ) | ||
212 | Sets the assistant of the contact to \a str. | ||
213 | */ | ||
214 | |||
215 | /*! \fn void Contact::setManager( const QString &str ) | ||
216 | Sets the manager of the contact to \a str. | ||
217 | */ | ||
218 | |||
219 | /*! \fn void Contact::setSpouse( const QString &str ) | ||
220 | Sets the spouse of the contact to \a str. | ||
221 | */ | ||
222 | |||
223 | /*! \fn void Contact::setGender( const QString &str ) | ||
224 | Sets the gender of the contact to \a str. | ||
225 | */ | ||
226 | |||
227 | /*! \fn void Contact::setBirthday( const QString &str ) | ||
228 | Sets the birthday for the contact to \a str. | ||
229 | */ | ||
230 | |||
231 | /*! \fn void Contact::setAnniversary( const QString &str ) | ||
232 | Sets the anniversary of the contact to \a str. | ||
233 | */ | ||
234 | |||
235 | /*! \fn void Contact::setNickname( const QString &str ) | ||
236 | Sets the nickname of the contact to \a str. | ||
237 | */ | ||
238 | |||
239 | /*! \fn void Contact::setNotes( const QString &str ) | ||
240 | Sets the notes about the contact to \a str. | ||
241 | */ | ||
242 | |||
243 | /*! \fn QString Contact::title() const | ||
244 | Returns the title of the contact. | ||
245 | */ | ||
246 | |||
247 | /*! \fn QString Contact::firstName() const | ||
248 | Returns the first name of the contact. | ||
249 | */ | ||
250 | |||
251 | /*! \fn QString Contact::middleName() const | ||
252 | Returns the middle name of the contact. | ||
253 | */ | ||
254 | |||
255 | /*! \fn QString Contact::lastName() const | ||
256 | Returns the last name of the contact. | ||
257 | */ | ||
258 | |||
259 | /*! \fn QString Contact::suffix() const | ||
260 | Returns the suffix of the contact. | ||
261 | */ | ||
262 | |||
263 | /*! \fn QString Contact::fileAs() const | ||
264 | Returns the string the contact is filed as. | ||
265 | */ | ||
266 | |||
267 | /*! \fn QString Contact::defaultEmail() const | ||
268 | Returns the default email address of the contact. | ||
269 | */ | ||
270 | |||
271 | /*! \fn QString Contact::emails() const | ||
272 | Returns the list of email address for a contact separated by ';'s in a single | ||
273 | string. | ||
274 | */ | ||
275 | |||
276 | /*! \fn QString Contact::homeStreet() const | ||
277 | Returns the home street address of the contact. | ||
278 | */ | ||
279 | |||
280 | /*! \fn QString Contact::homeCity() const | ||
281 | Returns the home city of the contact. | ||
282 | */ | ||
283 | |||
284 | /*! \fn QString Contact::homeState() const | ||
285 | Returns the home state of the contact. | ||
286 | */ | ||
287 | |||
288 | /*! \fn QString Contact::homeZip() const | ||
289 | Returns the home zip of the contact. | ||
290 | */ | ||
291 | |||
292 | /*! \fn QString Contact::homeCountry() const | ||
293 | Returns the home country of the contact. | ||
294 | */ | ||
295 | |||
296 | /*! \fn QString Contact::homePhone() const | ||
297 | Returns the home phone number of the contact. | ||
298 | */ | ||
299 | |||
300 | /*! \fn QString Contact::homeFax() const | ||
301 | Returns the home fax number of the contact. | ||
302 | */ | ||
303 | |||
304 | /*! \fn QString Contact::homeMobile() const | ||
305 | Returns the home mobile number of the contact. | ||
306 | */ | ||
307 | |||
308 | /*! \fn QString Contact::homeWebpage() const | ||
309 | Returns the home webpage of the contact. | ||
310 | */ | ||
311 | |||
312 | /*! \fn QString Contact::company() const | ||
313 | Returns the company for the contact. | ||
314 | */ | ||
315 | |||
316 | /*! \fn QString Contact::department() const | ||
317 | Returns the department for the contact. | ||
318 | */ | ||
319 | |||
320 | /*! \fn QString Contact::office() const | ||
321 | Returns the office for the contact. | ||
322 | */ | ||
323 | |||
324 | /*! \fn QString Contact::jobTitle() const | ||
325 | Returns the job title of the contact. | ||
326 | */ | ||
327 | |||
328 | /*! \fn QString Contact::profession() const | ||
329 | Returns the profession of the contact. | ||
330 | */ | ||
331 | |||
332 | /*! \fn QString Contact::assistant() const | ||
333 | Returns the assistant of the contact. | ||
334 | */ | ||
335 | |||
336 | /*! \fn QString Contact::manager() const | ||
337 | Returns the manager of the contact. | ||
338 | */ | ||
339 | |||
340 | /*! \fn QString Contact::businessStreet() const | ||
341 | Returns the business street address of the contact. | ||
342 | */ | ||
343 | |||
344 | /*! \fn QString Contact::businessCity() const | ||
345 | Returns the business city of the contact. | ||
346 | */ | ||
347 | |||
348 | /*! \fn QString Contact::businessState() const | ||
349 | Returns the business state of the contact. | ||
350 | */ | ||
351 | |||
352 | /*! \fn QString Contact::businessZip() const | ||
353 | Returns the business zip of the contact. | ||
354 | */ | ||
355 | |||
356 | /*! \fn QString Contact::businessCountry() const | ||
357 | Returns the business country of the contact. | ||
358 | */ | ||
359 | |||
360 | /*! \fn QString Contact::businessPhone() const | ||
361 | Returns the business phone number of the contact. | ||
362 | */ | ||
363 | |||
364 | /*! \fn QString Contact::businessFax() const | ||
365 | Returns the business fax number of the contact. | ||
366 | */ | ||
367 | |||
368 | /*! \fn QString Contact::businessMobile() const | ||
369 | Returns the business mobile number of the contact. | ||
370 | */ | ||
371 | |||
372 | /*! \fn QString Contact::businessPager() const | ||
373 | Returns the business pager number of the contact. | ||
374 | */ | ||
375 | |||
376 | /*! \fn QString Contact::businessWebpage() const | ||
377 | Returns the business webpage of the contact. | ||
378 | */ | ||
379 | |||
380 | /*! \fn QString Contact::spouse() const | ||
381 | Returns the spouse of the contact. | ||
382 | */ | ||
383 | |||
384 | /*! \fn QString Contact::gender() const | ||
385 | Returns the gender of the contact. | ||
386 | */ | ||
387 | |||
388 | /*! \fn QString Contact::birthday() const | ||
389 | Returns the birthday of the contact. | ||
390 | */ | ||
391 | |||
392 | /*! \fn QString Contact::anniversary() const | ||
393 | Returns the anniversary of the contact. | ||
394 | */ | ||
395 | |||
396 | /*! \fn QString Contact::nickname() const | ||
397 | Returns the nickname of the contact. | ||
398 | */ | ||
399 | |||
400 | /*! \fn QString Contact::children() const | ||
401 | Returns the children of the contact. | ||
402 | */ | ||
403 | |||
404 | /*! \fn QString Contact::notes() const | ||
405 | Returns the notes relating to the the contact. | ||
406 | */ | ||
407 | |||
408 | /*! \fn QString Contact::groups() const | ||
409 | \internal | ||
410 | Returns the groups for the contact. | ||
411 | */ | ||
412 | |||
413 | /*! \fn QStringList Contact::groupList() const | ||
414 | \internal | ||
415 | */ | ||
416 | |||
417 | /*! \fn QString Contact::field(int) const | ||
418 | \internal | ||
419 | */ | ||
420 | |||
421 | /*! \fn void Contact::saveJournal( journal_action, const QString & = QString::null ) | ||
422 | \internal | ||
423 | */ | ||
424 | |||
425 | /*! \fn void Contact::setUid( int id ) | ||
426 | \internal | ||
427 | Sets the uid for this record to \a id. | ||
428 | */ | ||
429 | |||
430 | /*! \enum Contact::journal_action | ||
431 | \internal | ||
432 | */ | ||
433 | |||
434 | /*! | ||
435 | \internal | ||
436 | */ | ||
61 | QMap<int, QString> Contact::toMap() const | 437 | QMap<int, QString> Contact::toMap() const |
62 | { | 438 | { |
63 | QMap<int, QString> map = mMap; | 439 | QMap<int, QString> map = mMap; |
64 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); | 440 | QString cats = idsToString( categories() ); |
441 | if ( !cats.isEmpty() ) | ||
442 | map.insert( Qtopia::AddressCategory, cats ); | ||
65 | return map; | 443 | return map; |
66 | } | 444 | } |
67 | 445 | ||
68 | /*! | 446 | /*! |
69 | Returns a rich text formatted QString of the Contact. | 447 | Returns a rich text formatted QString representing the contents the contact. |
70 | */ | 448 | */ |
71 | QString Contact::toRichText() const | 449 | QString Contact::toRichText() const |
72 | { | 450 | { |
@@ -231,6 +609,9 @@ QString Contact::toRichText() const | |||
231 | return text; | 609 | return text; |
232 | } | 610 | } |
233 | 611 | ||
612 | /*! | ||
613 | \internal | ||
614 | */ | ||
234 | void Contact::insert( int key, const QString &v ) | 615 | void Contact::insert( int key, const QString &v ) |
235 | { | 616 | { |
236 | QString value = v.stripWhiteSpace(); | 617 | QString value = v.stripWhiteSpace(); |
@@ -240,6 +621,9 @@ void Contact::insert( int key, const QString &v ) | |||
240 | mMap.insert( key, value ); | 621 | mMap.insert( key, value ); |
241 | } | 622 | } |
242 | 623 | ||
624 | /*! | ||
625 | \internal | ||
626 | */ | ||
243 | void Contact::replace( int key, const QString & v ) | 627 | void Contact::replace( int key, const QString & v ) |
244 | { | 628 | { |
245 | QString value = v.stripWhiteSpace(); | 629 | QString value = v.stripWhiteSpace(); |
@@ -249,11 +633,17 @@ void Contact::replace( int key, const QString & v ) | |||
249 | mMap.replace( key, value ); | 633 | mMap.replace( key, value ); |
250 | } | 634 | } |
251 | 635 | ||
636 | /*! | ||
637 | \internal | ||
638 | */ | ||
252 | QString Contact::find( int key ) const | 639 | QString Contact::find( int key ) const |
253 | { | 640 | { |
254 | return mMap[key]; | 641 | return mMap[key]; |
255 | } | 642 | } |
256 | 643 | ||
644 | /*! | ||
645 | \internal | ||
646 | */ | ||
257 | QString Contact::displayAddress( const QString &street, | 647 | QString Contact::displayAddress( const QString &street, |
258 | const QString &city, | 648 | const QString &city, |
259 | const QString &state, | 649 | const QString &state, |
@@ -276,6 +666,9 @@ QString Contact::displayAddress( const QString &street, | |||
276 | return s; | 666 | return s; |
277 | } | 667 | } |
278 | 668 | ||
669 | /*! | ||
670 | \internal | ||
671 | */ | ||
279 | QString Contact::displayBusinessAddress() const | 672 | QString Contact::displayBusinessAddress() const |
280 | { | 673 | { |
281 | return displayAddress( businessStreet(), businessCity(), | 674 | return displayAddress( businessStreet(), businessCity(), |
@@ -283,6 +676,9 @@ QString Contact::displayBusinessAddress() const | |||
283 | businessCountry() ); | 676 | businessCountry() ); |
284 | } | 677 | } |
285 | 678 | ||
679 | /*! | ||
680 | \internal | ||
681 | */ | ||
286 | QString Contact::displayHomeAddress() const | 682 | QString Contact::displayHomeAddress() const |
287 | { | 683 | { |
288 | return displayAddress( homeStreet(), homeCity(), | 684 | return displayAddress( homeStreet(), homeCity(), |
@@ -290,6 +686,9 @@ QString Contact::displayHomeAddress() const | |||
290 | homeCountry() ); | 686 | homeCountry() ); |
291 | } | 687 | } |
292 | 688 | ||
689 | /*! | ||
690 | Returns the full name of the contact | ||
691 | */ | ||
293 | QString Contact::fullName() const | 692 | QString Contact::fullName() const |
294 | { | 693 | { |
295 | QString title = find( Qtopia::Title ); | 694 | QString title = find( Qtopia::Title ); |
@@ -322,16 +721,62 @@ QString Contact::fullName() const | |||
322 | return name.simplifyWhiteSpace(); | 721 | return name.simplifyWhiteSpace(); |
323 | } | 722 | } |
324 | 723 | ||
724 | /*! | ||
725 | Returns a list of the names of the children of the contact. | ||
726 | */ | ||
325 | QStringList Contact::childrenList() const | 727 | QStringList Contact::childrenList() const |
326 | { | 728 | { |
327 | return QStringList::split( " ", find( Qtopia::Children ) ); | 729 | return QStringList::split( " ", find( Qtopia::Children ) ); |
328 | } | 730 | } |
329 | 731 | ||
732 | /*! \fn void Contact::insertEmail( const QString &email ) | ||
733 | |||
734 | Insert \a email into the email list. Ensures \a email can only be added | ||
735 | once. If there is no default email address set, it sets it to the \a email. | ||
736 | */ | ||
737 | |||
738 | /*! \fn void Contact::removeEmail( const QString &email ) | ||
739 | |||
740 | Removes the \a email from the email list. If the default email was \a email, | ||
741 | then the default email address is assigned to the first email in the | ||
742 | email list | ||
743 | */ | ||
744 | |||
745 | /*! \fn void Contact::clearEmails() | ||
746 | |||
747 | Clears the email list. | ||
748 | */ | ||
749 | |||
750 | /*! \fn void Contact::insertEmails( const QStringList &emailList ) | ||
751 | |||
752 | Appends the \a emailList to the exiting email list | ||
753 | */ | ||
754 | |||
755 | /*! | ||
756 | Returns a list of email addresses belonging to the contact, including | ||
757 | the default email address. | ||
758 | */ | ||
330 | QStringList Contact::emailList() const | 759 | QStringList Contact::emailList() const |
331 | { | 760 | { |
332 | return QStringList::split( ";", find( Qtopia::Emails ) ); | 761 | QString emailStr = emails(); |
762 | |||
763 | QStringList r; | ||
764 | if ( !emailStr.isEmpty() ) { | ||
765 | qDebug(" emailstr "); | ||
766 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | ||
767 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | ||
768 | r += (*it).simplifyWhiteSpace(); | ||
769 | } | ||
770 | |||
771 | return r; | ||
333 | } | 772 | } |
334 | 773 | ||
774 | /*! | ||
775 | \overload | ||
776 | |||
777 | Generates the string for the contact to be filed as from the first, | ||
778 | middle and last name of the contact. | ||
779 | */ | ||
335 | void Contact::setFileAs() | 780 | void Contact::setFileAs() |
336 | { | 781 | { |
337 | QString lastName, firstName, middleName, fileas; | 782 | QString lastName, firstName, middleName, fileas; |
@@ -353,6 +798,10 @@ void Contact::setFileAs() | |||
353 | replace( Qtopia::FileAs, fileas ); | 798 | replace( Qtopia::FileAs, fileas ); |
354 | } | 799 | } |
355 | 800 | ||
801 | /*! | ||
802 | \internal | ||
803 | Appends the contact information to \a buf. | ||
804 | */ | ||
356 | void Contact::save( QString &buf ) const | 805 | void Contact::save( QString &buf ) const |
357 | { | 806 | { |
358 | static const QStringList SLFIELDS = fields(); | 807 | static const QStringList SLFIELDS = fields(); |
@@ -377,6 +826,10 @@ void Contact::save( QString &buf ) const | |||
377 | // You need to close this yourself | 826 | // You need to close this yourself |
378 | } | 827 | } |
379 | 828 | ||
829 | /*! | ||
830 | \internal | ||
831 | Returns the list of fields belonging to a contact | ||
832 | */ | ||
380 | QStringList Contact::fields() | 833 | QStringList Contact::fields() |
381 | { | 834 | { |
382 | QStringList list; | 835 | QStringList list; |
@@ -435,6 +888,10 @@ QStringList Contact::fields() | |||
435 | return list; | 888 | return list; |
436 | } | 889 | } |
437 | 890 | ||
891 | /*! | ||
892 | \internal | ||
893 | Returns a translated list of field names for a contact. | ||
894 | */ | ||
438 | QStringList Contact::trfields() | 895 | QStringList Contact::trfields() |
439 | { | 896 | { |
440 | QStringList list; | 897 | QStringList list; |
@@ -493,19 +950,29 @@ QStringList Contact::trfields() | |||
493 | return list; | 950 | return list; |
494 | } | 951 | } |
495 | 952 | ||
496 | void Contact::setEmails( const QString &v ) | 953 | /*! |
954 | Sets the list of email address for contact to those contained in \a str. | ||
955 | Email address should be separated by ';'s. | ||
956 | */ | ||
957 | void Contact::setEmails( const QString &str ) | ||
497 | { | 958 | { |
498 | replace( Qtopia::Emails, v ); | 959 | replace( Qtopia::Emails, str ); |
499 | if ( v.isEmpty() ) | 960 | if ( str.isEmpty() ) |
500 | setDefaultEmail( QString::null ); | 961 | setDefaultEmail( QString::null ); |
501 | } | 962 | } |
502 | 963 | ||
503 | void Contact::setChildren( const QString &v ) | 964 | /*! |
965 | Sets the list of children for the contact to those contained in \a str. | ||
966 | */ | ||
967 | void Contact::setChildren( const QString &str ) | ||
504 | { | 968 | { |
505 | replace( Qtopia::Children, v ); | 969 | replace( Qtopia::Children, str ); |
506 | } | 970 | } |
507 | 971 | ||
508 | // vcard conversion code | 972 | // vcard conversion code |
973 | /*! | ||
974 | \internal | ||
975 | */ | ||
509 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 976 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
510 | { | 977 | { |
511 | VObject *ret = 0; | 978 | VObject *ret = 0; |
@@ -514,6 +981,9 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt | |||
514 | return ret; | 981 | return ret; |
515 | } | 982 | } |
516 | 983 | ||
984 | /*! | ||
985 | \internal | ||
986 | */ | ||
517 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 987 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
518 | { | 988 | { |
519 | VObject *ret = 0; | 989 | VObject *ret = 0; |
@@ -522,6 +992,9 @@ static inline VObject *safeAddProp( VObject *o, const char *prop) | |||
522 | return ret; | 992 | return ret; |
523 | } | 993 | } |
524 | 994 | ||
995 | /*! | ||
996 | \internal | ||
997 | */ | ||
525 | static VObject *createVObject( const Contact &c ) | 998 | static VObject *createVObject( const Contact &c ) |
526 | { | 999 | { |
527 | VObject *vcard = newVObject( VCCardProp ); | 1000 | VObject *vcard = newVObject( VCCardProp ); |
@@ -622,12 +1095,13 @@ static VObject *createVObject( const Contact &c ) | |||
622 | } | 1095 | } |
623 | 1096 | ||
624 | 1097 | ||
1098 | /*! | ||
1099 | \internal | ||
1100 | */ | ||
625 | static Contact parseVObject( VObject *obj ) | 1101 | static Contact parseVObject( VObject *obj ) |
626 | { | 1102 | { |
627 | Contact c; | 1103 | Contact c; |
628 | 1104 | ||
629 | bool haveDefaultEmail = FALSE; | ||
630 | |||
631 | VObjectIterator it; | 1105 | VObjectIterator it; |
632 | initPropIterator( &it, obj ); | 1106 | initPropIterator( &it, obj ); |
633 | while( moreIteration( &it ) ) { | 1107 | while( moreIteration( &it ) ) { |
@@ -767,14 +1241,7 @@ static Contact parseVObject( VObject *obj ) | |||
767 | valid = FALSE; | 1241 | valid = FALSE; |
768 | } | 1242 | } |
769 | if ( valid ) { | 1243 | if ( valid ) { |
770 | if ( haveDefaultEmail ) { | 1244 | c.insertEmail( email ); |
771 | QString str = c.emails(); | ||
772 | if ( !str.isEmpty() ) | ||
773 | str += ","+email; | ||
774 | c.setEmails( str ); | ||
775 | } else { | ||
776 | c.setDefaultEmail( email ); | ||
777 | } | ||
778 | } | 1245 | } |
779 | } | 1246 | } |
780 | else if ( name == VCURLProp ) { | 1247 | else if ( name == VCURLProp ) { |
@@ -851,6 +1318,9 @@ static Contact parseVObject( VObject *obj ) | |||
851 | return c; | 1318 | return c; |
852 | } | 1319 | } |
853 | 1320 | ||
1321 | /*! | ||
1322 | Writes the list of \a contacts as a set of VCards to the file \a filename. | ||
1323 | */ | ||
854 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) | 1324 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) |
855 | { | 1325 | { |
856 | QFileDirect f( filename.utf8().data() ); | 1326 | QFileDirect f( filename.utf8().data() ); |
@@ -868,6 +1338,9 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co | |||
868 | cleanStrTbl(); | 1338 | cleanStrTbl(); |
869 | } | 1339 | } |
870 | 1340 | ||
1341 | /*! | ||
1342 | writes \a contact as a VCard to the file \a filename. | ||
1343 | */ | ||
871 | void Contact::writeVCard( const QString &filename, const Contact &contact) | 1344 | void Contact::writeVCard( const QString &filename, const Contact &contact) |
872 | { | 1345 | { |
873 | QFileDirect f( filename.utf8().data() ); | 1346 | QFileDirect f( filename.utf8().data() ); |
@@ -883,7 +1356,9 @@ void Contact::writeVCard( const QString &filename, const Contact &contact) | |||
883 | cleanStrTbl(); | 1356 | cleanStrTbl(); |
884 | } | 1357 | } |
885 | 1358 | ||
886 | 1359 | /*! | |
1360 | Returns the set of contacts read as VCards from the file \a filename. | ||
1361 | */ | ||
887 | QValueList<Contact> Contact::readVCard( const QString &filename ) | 1362 | QValueList<Contact> Contact::readVCard( const QString &filename ) |
888 | { | 1363 | { |
889 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1364 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
@@ -904,11 +1379,20 @@ QValueList<Contact> Contact::readVCard( const QString &filename ) | |||
904 | return contacts; | 1379 | return contacts; |
905 | } | 1380 | } |
906 | 1381 | ||
1382 | /*! | ||
1383 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
1384 | Otherwise returns FALSE. | ||
1385 | */ | ||
907 | bool Contact::match( const QString ®exp ) const | 1386 | bool Contact::match( const QString ®exp ) const |
908 | { | 1387 | { |
909 | return match(QRegExp(regexp)); | 1388 | return match(QRegExp(regexp)); |
910 | } | 1389 | } |
911 | 1390 | ||
1391 | /*! | ||
1392 | \overload | ||
1393 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
1394 | Otherwise returns FALSE. | ||
1395 | */ | ||
912 | bool Contact::match( const QRegExp &r ) const | 1396 | bool Contact::match( const QRegExp &r ) const |
913 | { | 1397 | { |
914 | bool match; | 1398 | bool match; |