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