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