author | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
commit | eea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (unidiff) | |
tree | 874549d9c1c6239304fe1540d1b56269652954c0 /kabc/plugins | |
parent | 953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff) | |
download | kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index ac513b6..7d00a3f 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp | |||
@@ -1,362 +1,369 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //US | 28 | //US |
29 | #include "kglobal.h" | 29 | #include "kglobal.h" |
30 | 30 | ||
31 | 31 | ||
32 | #include "qtopiaconverter.h" | 32 | #include "qtopiaconverter.h" |
33 | 33 | ||
34 | #include <qpe/categories.h> | 34 | #include <qpe/categories.h> |
35 | //US #include <qpe/categoryselect.h> | 35 | //US #include <qpe/categoryselect.h> |
36 | 36 | ||
37 | 37 | ||
38 | using namespace KABC; | 38 | using namespace KABC; |
39 | 39 | ||
40 | QtopiaConverter::QtopiaConverter() : catDB(0) | 40 | QtopiaConverter::QtopiaConverter() : catDB(0) |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | QtopiaConverter::~QtopiaConverter() | 44 | QtopiaConverter::~QtopiaConverter() |
45 | { | 45 | { |
46 | deinit(); | 46 | deinit(); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool QtopiaConverter::init() | 49 | bool QtopiaConverter::init() |
50 | { | 50 | { |
51 | catDB = new Categories(); | 51 | catDB = new Categories(); |
52 | 52 | ||
53 | if (!catDB) | 53 | if (!catDB) |
54 | return false; | 54 | return false; |
55 | 55 | ||
56 | catDB->load( categoryFileName() ); | 56 | catDB->load( categoryFileName() ); |
57 | return true; | 57 | return true; |
58 | } | 58 | } |
59 | 59 | ||
60 | void QtopiaConverter::deinit() | 60 | void QtopiaConverter::deinit() |
61 | { | 61 | { |
62 | if (catDB) | 62 | if (catDB) |
63 | { | 63 | { |
64 | delete catDB; | 64 | delete catDB; |
65 | catDB = 0; | 65 | catDB = 0; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
70 | { | 70 | { |
71 | // name | 71 | // name |
72 | addr.setFormattedName(contact.fileAs()); | 72 | addr.setFormattedName(contact.fileAs()); |
73 | addr.setFamilyName( contact.lastName() ); | 73 | addr.setFamilyName( contact.lastName() ); |
74 | addr.setGivenName( contact.firstName() ); | 74 | addr.setGivenName( contact.firstName() ); |
75 | addr.setAdditionalName( contact.middleName() ); | 75 | addr.setAdditionalName( contact.middleName() ); |
76 | addr.setPrefix( contact.nameTitle() ); | 76 | addr.setPrefix( contact.nameTitle() ); |
77 | addr.setSuffix( contact.suffix() ); | 77 | addr.setSuffix( contact.suffix() ); |
78 | 78 | QString exuid = contact.uid().toString(); | |
79 | int ente = exuid.find( "-0000"); | ||
80 | if ( exuid.left(1) == "{" ) | ||
81 | exuid = exuid.mid(1); | ||
82 | if ( ente > -1 ) | ||
83 | exuid = exuid.left( ente-1 ); | ||
84 | addr.setExternalUID( exuid ); | ||
85 | //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); | ||
79 | 86 | ||
80 | 87 | ||
81 | QStringList emails = contact.emailList(); | 88 | QStringList emails = contact.emailList(); |
82 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 89 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
83 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 90 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
84 | } | 91 | } |
85 | 92 | ||
86 | if (!contact.defaultEmail().isEmpty()) | 93 | if (!contact.defaultEmail().isEmpty()) |
87 | addr.insertEmail(contact.defaultEmail(), true); | 94 | addr.insertEmail(contact.defaultEmail(), true); |
88 | 95 | ||
89 | // home | 96 | // home |
90 | if ((!contact.homeStreet().isEmpty()) || | 97 | if ((!contact.homeStreet().isEmpty()) || |
91 | (!contact.homeCity().isEmpty()) || | 98 | (!contact.homeCity().isEmpty()) || |
92 | (!contact.homeState().isEmpty()) || | 99 | (!contact.homeState().isEmpty()) || |
93 | (!contact.homeZip().isEmpty()) || | 100 | (!contact.homeZip().isEmpty()) || |
94 | (!contact.homeCountry().isEmpty())) | 101 | (!contact.homeCountry().isEmpty())) |
95 | { | 102 | { |
96 | Address homeaddress; | 103 | Address homeaddress; |
97 | homeaddress.setType(Address::Home); | 104 | homeaddress.setType(Address::Home); |
98 | //US homeaddress.setPostOfficeBox( "" ); | 105 | //US homeaddress.setPostOfficeBox( "" ); |
99 | //US homeaddress.setExtended( "" ); | 106 | //US homeaddress.setExtended( "" ); |
100 | homeaddress.setStreet( contact.homeStreet() ); | 107 | homeaddress.setStreet( contact.homeStreet() ); |
101 | homeaddress.setLocality( contact.homeCity() ); | 108 | homeaddress.setLocality( contact.homeCity() ); |
102 | homeaddress.setRegion( contact.homeState() ); | 109 | homeaddress.setRegion( contact.homeState() ); |
103 | homeaddress.setPostalCode( contact.homeZip() ); | 110 | homeaddress.setPostalCode( contact.homeZip() ); |
104 | homeaddress.setCountry( contact.homeCountry() ); | 111 | homeaddress.setCountry( contact.homeCountry() ); |
105 | 112 | ||
106 | addr.insertAddress( homeaddress ); | 113 | addr.insertAddress( homeaddress ); |
107 | } | 114 | } |
108 | 115 | ||
109 | if (!contact.homePhone().isEmpty()) | 116 | if (!contact.homePhone().isEmpty()) |
110 | { | 117 | { |
111 | PhoneNumber homephone; | 118 | PhoneNumber homephone; |
112 | homephone.setType( PhoneNumber::Home ); | 119 | homephone.setType( PhoneNumber::Home ); |
113 | homephone.setNumber( contact.homePhone() ); | 120 | homephone.setNumber( contact.homePhone() ); |
114 | addr.insertPhoneNumber( homephone ); | 121 | addr.insertPhoneNumber( homephone ); |
115 | } | 122 | } |
116 | 123 | ||
117 | if (!contact.homeFax().isEmpty()) | 124 | if (!contact.homeFax().isEmpty()) |
118 | { | 125 | { |
119 | PhoneNumber homefax; | 126 | PhoneNumber homefax; |
120 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | 127 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); |
121 | homefax.setNumber( contact.homeFax() ); | 128 | homefax.setNumber( contact.homeFax() ); |
122 | addr.insertPhoneNumber( homefax ); | 129 | addr.insertPhoneNumber( homefax ); |
123 | } | 130 | } |
124 | 131 | ||
125 | if (!contact.homeMobile().isEmpty()) | 132 | if (!contact.homeMobile().isEmpty()) |
126 | { | 133 | { |
127 | PhoneNumber homemobile; | 134 | PhoneNumber homemobile; |
128 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | 135 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); |
129 | homemobile.setNumber( contact.homeMobile() ); | 136 | homemobile.setNumber( contact.homeMobile() ); |
130 | addr.insertPhoneNumber( homemobile ); | 137 | addr.insertPhoneNumber( homemobile ); |
131 | } | 138 | } |
132 | 139 | ||
133 | addr.setUrl( contact.homeWebpage() ); | 140 | addr.setUrl( contact.homeWebpage() ); |
134 | 141 | ||
135 | 142 | ||
136 | // business | 143 | // business |
137 | if ((!contact.businessStreet().isEmpty()) || | 144 | if ((!contact.businessStreet().isEmpty()) || |
138 | (!contact.businessCity().isEmpty()) || | 145 | (!contact.businessCity().isEmpty()) || |
139 | (!contact.businessState().isEmpty()) || | 146 | (!contact.businessState().isEmpty()) || |
140 | (!contact.businessZip().isEmpty()) || | 147 | (!contact.businessZip().isEmpty()) || |
141 | (!contact.businessCountry().isEmpty())) | 148 | (!contact.businessCountry().isEmpty())) |
142 | { | 149 | { |
143 | Address businessaddress; | 150 | Address businessaddress; |
144 | businessaddress.setType(Address::Work); | 151 | businessaddress.setType(Address::Work); |
145 | //US businessaddress.setPostOfficeBox( "" ); | 152 | //US businessaddress.setPostOfficeBox( "" ); |
146 | //US businessaddress.setExtended( "" ); | 153 | //US businessaddress.setExtended( "" ); |
147 | businessaddress.setStreet( contact.businessStreet() ); | 154 | businessaddress.setStreet( contact.businessStreet() ); |
148 | businessaddress.setLocality( contact.businessCity() ); | 155 | businessaddress.setLocality( contact.businessCity() ); |
149 | businessaddress.setRegion( contact.businessState() ); | 156 | businessaddress.setRegion( contact.businessState() ); |
150 | businessaddress.setPostalCode( contact.businessZip() ); | 157 | businessaddress.setPostalCode( contact.businessZip() ); |
151 | businessaddress.setCountry( contact.businessCountry() ); | 158 | businessaddress.setCountry( contact.businessCountry() ); |
152 | 159 | ||
153 | addr.insertAddress( businessaddress ); | 160 | addr.insertAddress( businessaddress ); |
154 | } | 161 | } |
155 | 162 | ||
156 | 163 | ||
157 | if (!contact.businessPhone().isEmpty()) | 164 | if (!contact.businessPhone().isEmpty()) |
158 | { | 165 | { |
159 | PhoneNumber businessphone; | 166 | PhoneNumber businessphone; |
160 | businessphone.setType( PhoneNumber::Work ); | 167 | businessphone.setType( PhoneNumber::Work ); |
161 | businessphone.setNumber( contact.businessPhone() ); | 168 | businessphone.setNumber( contact.businessPhone() ); |
162 | addr.insertPhoneNumber( businessphone ); | 169 | addr.insertPhoneNumber( businessphone ); |
163 | } | 170 | } |
164 | 171 | ||
165 | if (!contact.businessFax().isEmpty()) | 172 | if (!contact.businessFax().isEmpty()) |
166 | { | 173 | { |
167 | PhoneNumber businessfax; | 174 | PhoneNumber businessfax; |
168 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 175 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
169 | businessfax.setNumber( contact.businessFax() ); | 176 | businessfax.setNumber( contact.businessFax() ); |
170 | addr.insertPhoneNumber( businessfax ); | 177 | addr.insertPhoneNumber( businessfax ); |
171 | } | 178 | } |
172 | 179 | ||
173 | if (!contact.businessMobile().isEmpty()) | 180 | if (!contact.businessMobile().isEmpty()) |
174 | { | 181 | { |
175 | PhoneNumber businessmobile; | 182 | PhoneNumber businessmobile; |
176 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 183 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
177 | businessmobile.setNumber( contact.businessMobile() ); | 184 | businessmobile.setNumber( contact.businessMobile() ); |
178 | addr.insertPhoneNumber( businessmobile ); | 185 | addr.insertPhoneNumber( businessmobile ); |
179 | } | 186 | } |
180 | 187 | ||
181 | if (!contact.businessPager().isEmpty()) | 188 | if (!contact.businessPager().isEmpty()) |
182 | { | 189 | { |
183 | PhoneNumber businesspager; | 190 | PhoneNumber businesspager; |
184 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 191 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
185 | businesspager.setNumber( contact.businessPager() ); | 192 | businesspager.setNumber( contact.businessPager() ); |
186 | addr.insertPhoneNumber( businesspager ); | 193 | addr.insertPhoneNumber( businesspager ); |
187 | } | 194 | } |
188 | 195 | ||
189 | addr.setRole( contact.jobTitle() ); //? | 196 | addr.setRole( contact.jobTitle() ); //? |
190 | addr.setOrganization( contact.company() ); | 197 | addr.setOrganization( contact.company() ); |
191 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); | 198 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); |
192 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); | 199 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); |
193 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); | 200 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); |
194 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); | 201 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); |
195 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); | 202 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); |
196 | 203 | ||
197 | //personal | 204 | //personal |
198 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); | 205 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); |
199 | // qtopia uses this categorization: | 206 | // qtopia uses this categorization: |
200 | // enum GenderType { UnspecifiedGender=0, Male, Female }; | 207 | // enum GenderType { UnspecifiedGender=0, Male, Female }; |
201 | if (contact.gender() == PimContact::Male) | 208 | if (contact.gender() == PimContact::Male) |
202 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 209 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
203 | else if (contact.gender() == PimContact::Female) | 210 | else if (contact.gender() == PimContact::Female) |
204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 211 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
205 | 212 | ||
206 | if (contact.anniversary().isValid()) { | 213 | if (contact.anniversary().isValid()) { |
207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); | 214 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); |
208 | //US | 215 | //US |
209 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); | 216 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); |
210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
211 | } | 218 | } |
212 | 219 | ||
213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); | 220 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); |
214 | if (contact.birthday().isValid()) | 221 | if (contact.birthday().isValid()) |
215 | addr.setBirthday( contact.birthday() ); | 222 | addr.setBirthday( contact.birthday() ); |
216 | 223 | ||
217 | addr.setNickName( contact.nickname() ); | 224 | addr.setNickName( contact.nickname() ); |
218 | 225 | ||
219 | // others | 226 | // others |
220 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 227 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
221 | QString notes = contact.notes(); | 228 | QString notes = contact.notes(); |
222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; | 229 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; |
223 | 230 | ||
224 | addr.setNote( contact.notes() ); | 231 | addr.setNote( contact.notes() ); |
225 | 232 | ||
226 | 233 | ||
227 | 234 | ||
228 | //US QString groups() const { return find( Qtopia::Groups ); } | 235 | //US QString groups() const { return find( Qtopia::Groups ); } |
229 | //US QStringList groupList() const; | 236 | //US QStringList groupList() const; |
230 | 237 | ||
231 | QArray<int> catArray = contact.categories(); | 238 | QArray<int> catArray = contact.categories(); |
232 | QString cat; | 239 | QString cat; |
233 | 240 | ||
234 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 241 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
235 | cat = catDB->label("contact", catArray[i]); | 242 | cat = catDB->label("contact", catArray[i]); |
236 | if ( cat.isEmpty() ) | 243 | if ( cat.isEmpty() ) |
237 | addr.insertCategory(QString::number(catArray[i])); | 244 | addr.insertCategory(QString::number(catArray[i])); |
238 | else | 245 | else |
239 | addr.insertCategory( cat ); | 246 | addr.insertCategory( cat ); |
240 | } | 247 | } |
241 | 248 | ||
242 | return true; | 249 | return true; |
243 | } | 250 | } |
244 | 251 | ||
245 | bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) | 252 | bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) |
246 | { | 253 | { |
247 | // name | 254 | // name |
248 | contact.setLastName(addr.familyName()); | 255 | contact.setLastName(addr.familyName()); |
249 | contact.setFirstName(addr.givenName()); | 256 | contact.setFirstName(addr.givenName()); |
250 | contact.setMiddleName(addr.additionalName()); | 257 | contact.setMiddleName(addr.additionalName()); |
251 | contact.setNameTitle(addr.prefix()); | 258 | contact.setNameTitle(addr.prefix()); |
252 | contact.setSuffix(addr.suffix()); | 259 | contact.setSuffix(addr.suffix()); |
253 | contact.setFileAs(); | 260 | contact.setFileAs(); |
254 | 261 | ||
255 | 262 | ||
256 | 263 | ||
257 | QStringList emails = addr.emails(); | 264 | QStringList emails = addr.emails(); |
258 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 265 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
259 | contact.insertEmail(*it); | 266 | contact.insertEmail(*it); |
260 | } | 267 | } |
261 | contact.setDefaultEmail( addr.preferredEmail() ); | 268 | contact.setDefaultEmail( addr.preferredEmail() ); |
262 | 269 | ||
263 | 270 | ||
264 | // home | 271 | // home |
265 | const Address homeaddress = addr.address(Address::Home); | 272 | const Address homeaddress = addr.address(Address::Home); |
266 | if (!homeaddress.isEmpty()) { | 273 | if (!homeaddress.isEmpty()) { |
267 | contact.setHomeStreet(homeaddress.street()); | 274 | contact.setHomeStreet(homeaddress.street()); |
268 | contact.setHomeCity(homeaddress.locality()); | 275 | contact.setHomeCity(homeaddress.locality()); |
269 | contact.setHomeState(homeaddress.region()); | 276 | contact.setHomeState(homeaddress.region()); |
270 | contact.setHomeZip(homeaddress.postalCode()); | 277 | contact.setHomeZip(homeaddress.postalCode()); |
271 | contact.setHomeCountry(homeaddress.country()); | 278 | contact.setHomeCountry(homeaddress.country()); |
272 | } | 279 | } |
273 | 280 | ||
274 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 281 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
275 | if (!homephone.number().isEmpty()) | 282 | if (!homephone.number().isEmpty()) |
276 | contact.setHomePhone(homephone.number()); | 283 | contact.setHomePhone(homephone.number()); |
277 | 284 | ||
278 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 285 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
279 | if (!homefax.number().isEmpty()) | 286 | if (!homefax.number().isEmpty()) |
280 | contact.setHomeFax(homefax.number()); | 287 | contact.setHomeFax(homefax.number()); |
281 | 288 | ||
282 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 289 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
283 | if (!homemobile.number().isEmpty()) | 290 | if (!homemobile.number().isEmpty()) |
284 | contact.setHomeMobile(homemobile.number()); | 291 | contact.setHomeMobile(homemobile.number()); |
285 | 292 | ||
286 | contact.setHomeWebpage(addr.url().url()); | 293 | contact.setHomeWebpage(addr.url().url()); |
287 | 294 | ||
288 | 295 | ||
289 | // business | 296 | // business |
290 | const Address businessaddress = addr.address(Address::Work); | 297 | const Address businessaddress = addr.address(Address::Work); |
291 | if (!businessaddress.isEmpty()) { | 298 | if (!businessaddress.isEmpty()) { |
292 | contact.setBusinessStreet(businessaddress.street()); | 299 | contact.setBusinessStreet(businessaddress.street()); |
293 | contact.setBusinessCity(businessaddress.locality()); | 300 | contact.setBusinessCity(businessaddress.locality()); |
294 | contact.setBusinessState(businessaddress.region()); | 301 | contact.setBusinessState(businessaddress.region()); |
295 | contact.setBusinessZip(businessaddress.postalCode()); | 302 | contact.setBusinessZip(businessaddress.postalCode()); |
296 | contact.setBusinessCountry(businessaddress.country()); | 303 | contact.setBusinessCountry(businessaddress.country()); |
297 | } | 304 | } |
298 | 305 | ||
299 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 306 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
300 | if (!businessphone.number().isEmpty()) | 307 | if (!businessphone.number().isEmpty()) |
301 | contact.setBusinessPhone(businessphone.number()); | 308 | contact.setBusinessPhone(businessphone.number()); |
302 | 309 | ||
303 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 310 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
304 | if (!businessfax.number().isEmpty()) | 311 | if (!businessfax.number().isEmpty()) |
305 | contact.setBusinessFax(businessfax.number()); | 312 | contact.setBusinessFax(businessfax.number()); |
306 | 313 | ||
307 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 314 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
308 | if (!businessmobile.number().isEmpty()) | 315 | if (!businessmobile.number().isEmpty()) |
309 | contact.setBusinessMobile(businessmobile.number()); | 316 | contact.setBusinessMobile(businessmobile.number()); |
310 | 317 | ||
311 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 318 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
312 | if (!businesspager.number().isEmpty()) | 319 | if (!businesspager.number().isEmpty()) |
313 | contact.setBusinessPager(businesspager.number()); | 320 | contact.setBusinessPager(businesspager.number()); |
314 | 321 | ||
315 | contact.setJobTitle(addr.role()); | 322 | contact.setJobTitle(addr.role()); |
316 | contact.setCompany(addr.organization()); | 323 | contact.setCompany(addr.organization()); |
317 | 324 | ||
318 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); | 325 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); |
319 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 326 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
320 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); | 327 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); |
321 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 328 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
322 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); | 329 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); |
323 | 330 | ||
324 | //personal | 331 | //personal |
325 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 332 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
326 | // qtopia uses this categorization: | 333 | // qtopia uses this categorization: |
327 | // enum GenderType { UnspecifiedGender=0, Male, Female }; | 334 | // enum GenderType { UnspecifiedGender=0, Male, Female }; |
328 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 335 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
329 | if (gt = "male") | 336 | if (gt = "male") |
330 | contact.setGender(PimContact::Male); | 337 | contact.setGender(PimContact::Male); |
331 | else if (gt = "female") | 338 | else if (gt = "female") |
332 | contact.setGender(PimContact::Female); | 339 | contact.setGender(PimContact::Female); |
333 | else | 340 | else |
334 | contact.setGender(PimContact::UnspecifiedGender); | 341 | contact.setGender(PimContact::UnspecifiedGender); |
335 | 342 | ||
336 | 343 | ||
337 | QDate dt = KGlobal::locale()->readDate( | 344 | QDate dt = KGlobal::locale()->readDate( |
338 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 345 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
339 | contact.setAnniversary( dt ); | 346 | contact.setAnniversary( dt ); |
340 | 347 | ||
341 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); | 348 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); |
342 | 349 | ||
343 | contact.setBirthday(addr.birthday().date()); | 350 | contact.setBirthday(addr.birthday().date()); |
344 | contact.setNickname(addr.nickName()); | 351 | contact.setNickname(addr.nickName()); |
345 | 352 | ||
346 | // other | 353 | // other |
347 | contact.setNotes(addr.note()); | 354 | contact.setNotes(addr.note()); |
348 | 355 | ||
349 | //US QString groups() const { return find( Qtopia::Groups ); } | 356 | //US QString groups() const { return find( Qtopia::Groups ); } |
350 | //US QStringList groupList() const; | 357 | //US QStringList groupList() const; |
351 | 358 | ||
352 | 359 | ||
353 | QStringList cats = addr.categories(); | 360 | QStringList cats = addr.categories(); |
354 | 361 | ||
355 | QArray<int> iar; | 362 | QArray<int> iar; |
356 | if ( !cats.isEmpty() ) { | 363 | if ( !cats.isEmpty() ) { |
357 | QArray<int> iar = catDB->ids("contact", cats); | 364 | QArray<int> iar = catDB->ids("contact", cats); |
358 | contact.setCategories(iar); | 365 | contact.setCategories(iar); |
359 | } | 366 | } |
360 | 367 | ||
361 | return true; | 368 | return true; |
362 | } | 369 | } |