-rw-r--r-- | libopie/pim/ocontact.h | 82 |
1 files changed, 6 insertions, 76 deletions
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index f916cf2..9e83150 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -2,2 +2,3 @@ | |||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | ||
3 | ** | 4 | ** |
@@ -26,2 +27,3 @@ | |||
26 | 27 | ||
28 | #include <qdatetime.h> | ||
27 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
@@ -98,4 +100,4 @@ public: | |||
98 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
99 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } | 101 | void setBirthday( const QDate &v ); |
100 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } | 102 | void setAnniversary( const QDate &v ); |
101 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
@@ -175,4 +177,4 @@ public: | |||
175 | QString gender() const { return find( Qtopia::Gender ); } | 177 | QString gender() const { return find( Qtopia::Gender ); } |
176 | QString birthday() const { return find( Qtopia::Birthday ); } | 178 | QDate birthday() const; |
177 | QString anniversary() const { return find( Qtopia::Anniversary ); } | 179 | QDate anniversary() const; |
178 | QString nickname() const { return find( Qtopia::Nickname ); } | 180 | QString nickname() const { return find( Qtopia::Nickname ); } |
@@ -241,74 +243,2 @@ private: | |||
241 | 243 | ||
242 | // these methods are inlined to keep binary compatability with Qtopia 1.5 | ||
243 | inline void OContact::insertEmail( const QString &v ) | ||
244 | { | ||
245 | //qDebug("insertEmail %s", v.latin1()); | ||
246 | QString e = v.simplifyWhiteSpace(); | ||
247 | QString def = defaultEmail(); | ||
248 | |||
249 | // if no default, set it as the default email and don't insert | ||
250 | if ( def.isEmpty() ) { | ||
251 | setDefaultEmail( e ); // will insert into the list for us | ||
252 | return; | ||
253 | } | ||
254 | |||
255 | // otherwise, insert assuming doesn't already exist | ||
256 | QString emailsStr = find( Qtopia::Emails ); | ||
257 | if ( emailsStr.contains( e )) | ||
258 | return; | ||
259 | if ( !emailsStr.isEmpty() ) | ||
260 | emailsStr += emailSeparator(); | ||
261 | emailsStr += e; | ||
262 | replace( Qtopia::Emails, emailsStr ); | ||
263 | } | ||
264 | |||
265 | inline void OContact::removeEmail( const QString &v ) | ||
266 | { | ||
267 | QString e = v.simplifyWhiteSpace(); | ||
268 | QString def = defaultEmail(); | ||
269 | QString emailsStr = find( Qtopia::Emails ); | ||
270 | QStringList emails = emailList(); | ||
271 | |||
272 | // otherwise, must first contain it | ||
273 | if ( !emailsStr.contains( e ) ) | ||
274 | return; | ||
275 | |||
276 | // remove it | ||
277 | //qDebug(" removing email from list %s", e.latin1()); | ||
278 | emails.remove( e ); | ||
279 | // reset the string | ||
280 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | ||
281 | replace( Qtopia::Emails, emailsStr ); | ||
282 | |||
283 | // if default, then replace the default email with the first one | ||
284 | if ( def == e ) { | ||
285 | //qDebug("removeEmail is default; setting new default"); | ||
286 | if ( !emails.count() ) | ||
287 | clearEmails(); | ||
288 | else // setDefaultEmail will remove e from the list | ||
289 | setDefaultEmail( emails.first() ); | ||
290 | } | ||
291 | } | ||
292 | inline void OContact::clearEmails() | ||
293 | { | ||
294 | mMap.remove( Qtopia::DefaultEmail ); | ||
295 | mMap.remove( Qtopia::Emails ); | ||
296 | } | ||
297 | inline void OContact::setDefaultEmail( const QString &v ) | ||
298 | { | ||
299 | QString e = v.simplifyWhiteSpace(); | ||
300 | |||
301 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | ||
302 | replace( Qtopia::DefaultEmail, e ); | ||
303 | |||
304 | if ( !e.isEmpty() ) | ||
305 | insertEmail( e ); | ||
306 | |||
307 | } | ||
308 | |||
309 | inline void OContact::insertEmails( const QStringList &v ) | ||
310 | { | ||
311 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | ||
312 | insertEmail( *it ); | ||
313 | } | ||
314 | 244 | ||