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