summaryrefslogtreecommitdiff
path: root/libopie/pim/ocontact.h
Unidiff
Diffstat (limited to 'libopie/pim/ocontact.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/ocontact.h82
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
@@ -1,5 +1,6 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
3** 4**
4** This file is part of the Qtopia Environment. 5** This file is part of the Qtopia Environment.
5** 6**
@@ -24,6 +25,7 @@
24#include <opie/opimrecord.h> 25#include <opie/opimrecord.h>
25#include <qpe/recordfields.h> 26#include <qpe/recordfields.h>
26 27
28#include <qdatetime.h>
27#include <qstringlist.h> 29#include <qstringlist.h>
28 30
29#if defined(QPC_TEMPLATEDLL) 31#if defined(QPC_TEMPLATEDLL)
@@ -96,8 +98,8 @@ public:
96 // personal 98 // personal
97 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 99 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 100 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } 101 void setBirthday( const QDate &v );
100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } 102 void setAnniversary( const QDate &v );
101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 103 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
102 void setChildren( const QString &v ); 104 void setChildren( const QString &v );
103 105
@@ -173,8 +175,8 @@ public:
173 //personal 175 //personal
174 QString spouse() const { return find( Qtopia::Spouse ); } 176 QString spouse() const { return find( Qtopia::Spouse ); }
175 QString gender() const { return find( Qtopia::Gender ); } 177 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 178 QDate birthday() const;
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 179 QDate anniversary() const;
178 QString nickname() const { return find( Qtopia::Nickname ); } 180 QString nickname() const { return find( Qtopia::Nickname ); }
179 QString children() const { return find( Qtopia::Children ); } 181 QString children() const { return find( Qtopia::Children ); }
180 QStringList childrenList() const; 182 QStringList childrenList() const;
@@ -239,77 +241,5 @@ private:
239 ContactPrivate *d; 241 ContactPrivate *d;
240}; 242};
241 243
242// these methods are inlined to keep binary compatability with Qtopia 1.5
243inline 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
265inline 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}
292inline void OContact::clearEmails()
293{
294 mMap.remove( Qtopia::DefaultEmail );
295 mMap.remove( Qtopia::Emails );
296}
297inline 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
309inline void OContact::insertEmails( const QStringList &v )
310{
311 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
312 insertEmail( *it );
313}
314 244
315#endif 245#endif