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