summaryrefslogtreecommitdiff
path: root/library/backend/contact.h
Unidiff
Diffstat (limited to 'library/backend/contact.h') (more/less context) (show whitespace changes)
-rw-r--r--library/backend/contact.h217
1 files changed, 217 insertions, 0 deletions
diff --git a/library/backend/contact.h b/library/backend/contact.h
new file mode 100644
index 0000000..6abdab6
--- a/dev/null
+++ b/library/backend/contact.h
@@ -0,0 +1,217 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** 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**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef __CONTACT_H__
22#define __CONTACT_H__
23
24#include <qpe/palmtoprecord.h>
25#include <qpe/recordfields.h>
26
27#include <qstringlist.h>
28
29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN
31template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END
33#endif
34
35class ContactPrivate;
36class QPC_EXPORT Contact : public Qtopia::Record
37{
38 friend class DataSet;
39public:
40 Contact();
41 Contact( const QMap<int, QString> &fromMap );
42 virtual ~Contact();
43
44 static void writeVCard( const QString &filename, const QValueList<Contact> &contacts);
45 static void writeVCard( const QString &filename, const Contact &c );
46 static QValueList<Contact> readVCard( const QString &filename );
47
48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
49
50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
56 void setFileAs();
57
58 // default email address
59 void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); }
60 // the emails should be seperated by a semicolon
61 void setEmails( const QString &v );
62
63 // home
64 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
65 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
66 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
67 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
68 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
69 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
70 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
71 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
72 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
73
74 // business
75 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
76 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
77 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
78 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
79 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
80 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
81 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
82 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
83 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
84 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
85 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
86 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
87 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
88 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
89 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
90 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
91 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
92
93 // personal
94 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
95 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
96 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
97 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
98 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
99 void setChildren( const QString &v );
100
101 // other
102 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
103
104 bool match( const QRegExp &r ) const;
105
106// // custom
107// void setCustomField( const QString &key, const QString &v )
108// { replace(Custom- + key, v ); }
109
110 // name
111 QString fullName() const;
112 QString title() const { return find( Qtopia::Title ); }
113 QString firstName() const { return find( Qtopia::FirstName ); }
114 QString middleName() const { return find( Qtopia::MiddleName ); }
115 QString lastName() const { return find( Qtopia::LastName ); }
116 QString suffix() const { return find( Qtopia::Suffix ); }
117 QString fileAs() const { return find( Qtopia::FileAs ); }
118
119 // email
120 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
121 QString emails() const { return find( Qtopia::Emails ); }
122 QStringList emailList() const;
123
124 // home
125 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
126 QString homeCity() const { return find( Qtopia::HomeCity ); }
127 QString homeState() const { return find( Qtopia::HomeState ); }
128 QString homeZip() const { return find( Qtopia::HomeZip ); }
129 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
130 QString homePhone() const { return find( Qtopia::HomePhone ); }
131 QString homeFax() const { return find( Qtopia::HomeFax ); }
132 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
133 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
134 /** Multi line string containing all non-empty address info in the form
135 * Street
136 * City, State Zip
137 * Country
138 */
139 QString displayHomeAddress() const;
140
141 // business
142 QString company() const { return find( Qtopia::Company ); }
143 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
144 QString businessCity() const { return find( Qtopia::BusinessCity ); }
145 QString businessState() const { return find( Qtopia::BusinessState ); }
146 QString businessZip() const { return find( Qtopia::BusinessZip ); }
147 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
148 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
149 QString jobTitle() const { return find( Qtopia::JobTitle ); }
150 QString department() const { return find( Qtopia::Department ); }
151 QString office() const { return find( Qtopia::Office ); }
152 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
153 QString businessFax() const { return find( Qtopia::BusinessFax ); }
154 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
155 QString businessPager() const { return find( Qtopia::BusinessPager ); }
156 QString profession() const { return find( Qtopia::Profession ); }
157 QString assistant() const { return find( Qtopia::Assistant ); }
158 QString manager() const { return find( Qtopia::Manager ); }
159 /** Multi line string containing all non-empty address info in the form
160 * Street
161 * City, State Zip
162 * Country
163 */
164 QString displayBusinessAddress() const;
165
166 //personal
167 QString spouse() const { return find( Qtopia::Spouse ); }
168 QString gender() const { return find( Qtopia::Gender ); }
169 QString birthday() const { return find( Qtopia::Birthday ); }
170 QString anniversary() const { return find( Qtopia::Anniversary ); }
171 QString nickname() const { return find( Qtopia::Nickname ); }
172 QString children() const { return find( Qtopia::Children ); }
173 QStringList childrenList() const;
174
175 // other
176 QString notes() const { return find( Qtopia::Notes ); }
177 QString groups() const { return find( Qtopia::Groups ); }
178 QStringList groupList() const;
179
180// // custom
181// const QString &customField( const QString &key )
182// { return find( Custom- + key ); }
183
184 static QStringList fields();
185 static QStringList trfields();
186
187 QString toRichText() const;
188 QMap<int, QString> toMap() const;
189 QString field( int key ) const { return find( key ); }
190
191
192 // journaling...
193 void saveJournal( journal_action action, const QString &key = QString::null );
194 void save( QString &buf ) const;
195
196 void setUid( int i )
197{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
198
199private:
200 friend class AbTable;
201 void insert( int key, const QString &value );
202 void replace( int key, const QString &value );
203 QString find( int key ) const;
204
205 QString displayAddress( const QString &street,
206 const QString &city,
207 const QString &state,
208 const QString &zip,
209 const QString &country ) const;
210
211 Qtopia::UidGen &uidGen() { return sUidGen; }
212 static Qtopia::UidGen sUidGen;
213 QMap<int, QString> mMap;
214 ContactPrivate *d;
215};
216
217#endif