summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ocontact.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/ocontact.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ocontact.h82
1 files changed, 6 insertions, 76 deletions
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index f916cf2..9e83150 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,38 +1,40 @@
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**
6** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#ifndef __OCONTACT_H__ 22#ifndef __OCONTACT_H__
22#define __OCONTACT_H__ 23#define __OCONTACT_H__
23 24
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)
30// MOC_SKIP_BEGIN 32// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 33QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 34// MOC_SKIP_END
33#endif 35#endif
34 36
35class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) 37class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
36class QPC_EXPORT OContact : public OPimRecord 38class QPC_EXPORT OContact : public OPimRecord
37{ 39{
38 friend class DataSet; 40 friend class DataSet;
@@ -87,26 +89,26 @@ public:
87 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 89 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
88 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 90 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
89 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 91 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
90 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 92 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
91 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 93 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
92 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 94 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
93 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 95 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
94 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 96 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
95 97
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
104 // other 106 // other
105 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 107 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
106 108
107 bool match( const QString &regexp ) const; 109 bool match( const QString &regexp ) const;
108 110
109// DON'T ATTEMPT TO USE THIS 111// DON'T ATTEMPT TO USE THIS
110#ifdef QTOPIA_INTERNAL_CONTACT_MRE 112#ifdef QTOPIA_INTERNAL_CONTACT_MRE
111 bool match( const QRegExp &regexp ) const; 113 bool match( const QRegExp &regexp ) const;
112#endif 114#endif
@@ -164,26 +166,26 @@ public:
164 QString assistant() const { return find( Qtopia::Assistant ); } 166 QString assistant() const { return find( Qtopia::Assistant ); }
165 QString manager() const { return find( Qtopia::Manager ); } 167 QString manager() const { return find( Qtopia::Manager ); }
166 /** Multi line string containing all non-empty address info in the form 168 /** Multi line string containing all non-empty address info in the form
167 * Street 169 * Street
168 * City, State Zip 170 * City, State Zip
169 * Country 171 * Country
170 */ 172 */
171 QString displayBusinessAddress() const; 173 QString displayBusinessAddress() const;
172 174
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;
181 183
182 // other 184 // other
183 QString notes() const { return find( Qtopia::Notes ); } 185 QString notes() const { return find( Qtopia::Notes ); }
184 QString groups() const { return find( Qtopia::Groups ); } 186 QString groups() const { return find( Qtopia::Groups ); }
185 QStringList groupList() const; 187 QStringList groupList() const;
186 188
187// // custom 189// // custom
188// const QString &customField( const QString &key ) 190// const QString &customField( const QString &key )
189// { return find( Custom- + key ); } 191// { return find( Custom- + key ); }
@@ -230,86 +232,14 @@ private:
230 QString displayAddress( const QString &street, 232 QString displayAddress( const QString &street,
231 const QString &city, 233 const QString &city,
232 const QString &state, 234 const QString &state,
233 const QString &zip, 235 const QString &zip,
234 const QString &country ) const; 236 const QString &country ) const;
235 237
236 Qtopia::UidGen &uidGen() { return sUidGen; } 238 Qtopia::UidGen &uidGen() { return sUidGen; }
237 static Qtopia::UidGen sUidGen; 239 static Qtopia::UidGen sUidGen;
238 QMap<int, QString> mMap; 240 QMap<int, QString> mMap;
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