summaryrefslogtreecommitdiff
path: root/library/backend/contact.h
authorzecke <zecke>2002-09-10 12:09:49 (UTC)
committer zecke <zecke>2002-09-10 12:09:49 (UTC)
commit6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff)
tree6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/backend/contact.h
parentd10cddb3c9ce75bc90b14add14bc133737fe35aa (diff)
downloadopie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2
Qtopia1-6 merge
still to test bic changes to be resolved more changes to be made?
Diffstat (limited to 'library/backend/contact.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/contact.h102
1 files changed, 93 insertions, 9 deletions
diff --git a/library/backend/contact.h b/library/backend/contact.h
index a74cbbe..4999430 100644
--- a/library/backend/contact.h
+++ b/library/backend/contact.h
@@ -1,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -21,14 +21,14 @@
21#ifndef __CONTACT_H__ 21#ifndef __CONTACT_H__
22#define __CONTACT_H__ 22#define __CONTACT_H__
23 23
24#include <qpe/palmtoprecord.h> 24#include <qtopia/private/palmtoprecord.h>
25#include <qpe/recordfields.h> 25#include <qtopia/private/recordfields.h>
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
@@ -56,9 +56,12 @@ public:
56 void setFileAs(); 56 void setFileAs();
57 57
58 // default email address 58 // default email address
59 void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } 59 void setDefaultEmail( const QString &v );
60 // the emails should be seperated by a semicolon 60 // inserts email to list and ensure's doesn't already exist
61 void setEmails( const QString &v ); 61 void insertEmail( const QString &v );
62 void removeEmail( const QString &v );
63 void clearEmails();
64 void insertEmails( const QStringList &v );
62 65
63 // home 66 // home
64 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
@@ -123,7 +126,6 @@ public:
123 126
124 // email 127 // email
125 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
126 QString emails() const { return find( Qtopia::Emails ); }
127 QStringList emailList() const; 129 QStringList emailList() const;
128 130
129 // home 131 // home
@@ -202,7 +204,16 @@ public:
202{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
203 205
204private: 206private:
207 friend class AbEditor;
205 friend class AbTable; 208 friend class AbTable;
209 friend class AddressBookAccessPrivate;
210 friend class XMLIO;
211
212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma
214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); }
216
206 void insert( int key, const QString &value ); 217 void insert( int key, const QString &value );
207 void replace( int key, const QString &value ); 218 void replace( int key, const QString &value );
208 QString find( int key ) const; 219 QString find( int key ) const;
@@ -219,4 +230,77 @@ private:
219 ContactPrivate *d; 230 ContactPrivate *d;
220}; 231};
221 232
233// these methods are inlined to keep binary compatability with Qtopia 1.5
234inline void Contact::insertEmail( const QString &v )
235{
236 //qDebug("insertEmail %s", v.latin1());
237 QString e = v.simplifyWhiteSpace();
238 QString def = defaultEmail();
239
240 // if no default, set it as the default email and don't insert
241 if ( def.isEmpty() ) {
242 setDefaultEmail( e ); // will insert into the list for us
243 return;
244 }
245
246 // otherwise, insert assuming doesn't already exist
247 QString emailsStr = find( Qtopia::Emails );
248 if ( emailsStr.contains( e ))
249 return;
250 if ( !emailsStr.isEmpty() )
251 emailsStr += emailSeparator();
252 emailsStr += e;
253 replace( Qtopia::Emails, emailsStr );
254}
255
256inline void Contact::removeEmail( const QString &v )
257{
258 QString e = v.simplifyWhiteSpace();
259 QString def = defaultEmail();
260 QString emailsStr = find( Qtopia::Emails );
261 QStringList emails = emailList();
262
263 // otherwise, must first contain it
264 if ( !emailsStr.contains( e ) )
265 return;
266
267 // remove it
268 //qDebug(" removing email from list %s", e.latin1());
269 emails.remove( e );
270 // reset the string
271 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
272 replace( Qtopia::Emails, emailsStr );
273
274 // if default, then replace the default email with the first one
275 if ( def == e ) {
276 //qDebug("removeEmail is default; setting new default");
277 if ( !emails.count() )
278 clearEmails();
279 else // setDefaultEmail will remove e from the list
280 setDefaultEmail( emails.first() );
281 }
282}
283inline void Contact::clearEmails()
284{
285 mMap.remove( Qtopia::DefaultEmail );
286 mMap.remove( Qtopia::Emails );
287}
288inline void Contact::setDefaultEmail( const QString &v )
289{
290 QString e = v.simplifyWhiteSpace();
291
292 //qDebug("Contact::setDefaultEmail %s", e.latin1());
293 replace( Qtopia::DefaultEmail, e );
294
295 if ( !e.isEmpty() )
296 insertEmail( e );
297
298}
299
300inline void Contact::insertEmails( const QStringList &v )
301{
302 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
303 insertEmail( *it );
304}
305
222#endif 306#endif