summaryrefslogtreecommitdiffabout
path: root/kabc/field.cpp
authorzautrix <zautrix>2005-04-07 07:42:53 (UTC)
committer zautrix <zautrix>2005-04-07 07:42:53 (UTC)
commitc82f9b40f6023dc7b39ac555cba8c4c313f15ca8 (patch) (unidiff)
treee9e4f0c0ed3243ec060a475983b271bd27b40d15 /kabc/field.cpp
parent76e220bf1236ae6afa9d91f18f0cd9ced730cff0 (diff)
downloadkdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.zip
kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.gz
kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.bz2
added fields to kapi
Diffstat (limited to 'kabc/field.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp
index 89d0b77..5c561c3 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -25,458 +25,476 @@ Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 Category, 60 Category,
61 HomeAddressStreet, 61 HomeAddressStreet,
62 HomeAddressLocality, 62 HomeAddressLocality,
63 HomeAddressRegion, 63 HomeAddressRegion,
64 HomeAddressPostalCode, 64 HomeAddressPostalCode,
65 HomeAddressCountry, 65 HomeAddressCountry,
66 HomeAddressLabel, 66 HomeAddressLabel,
67 BusinessAddressStreet, 67 BusinessAddressStreet,
68 BusinessAddressLocality, 68 BusinessAddressLocality,
69 BusinessAddressRegion, 69 BusinessAddressRegion,
70 BusinessAddressPostalCode, 70 BusinessAddressPostalCode,
71 BusinessAddressCountry, 71 BusinessAddressCountry,
72 BusinessAddressLabel, 72 BusinessAddressLabel,
73 HomePhone, 73 HomePhone,
74 BusinessPhone, 74 BusinessPhone,
75 MobilePhone, 75 MobilePhone,
76 HomeFax, 76 HomeFax,
77 BusinessFax, 77 BusinessFax,
78 CarPhone, 78 CarPhone,
79 Isdn, 79 Isdn,
80 Pager, 80 Pager,
81 Email, 81 Email,
82 Mailer, 82 Mailer,
83 Title, 83 Title,
84 Role, 84 Role,
85 Organization, 85 Organization,
86 Note, 86 Note,
87 Url, 87 Url,
88 Resource, 88 Resource,
89 Sip 89 Sip,
90 DefaultFormattedName,
91 MobileWorkPhone,
92 MobileHomePhone
90 }; 93 };
91 94
92 int fieldId() { return mFieldId; } 95 int fieldId() { return mFieldId; }
93 int category() { return mCategory; } 96 int category() { return mCategory; }
94 97
95 QString label() { return mLabel; } 98 QString label() { return mLabel; }
96 QString key() { return mKey; } 99 QString key() { return mKey; }
97 QString app() { return mApp; } 100 QString app() { return mApp; }
98 101
99 private: 102 private:
100 int mFieldId; 103 int mFieldId;
101 int mCategory; 104 int mCategory;
102 105
103 QString mLabel; 106 QString mLabel;
104 QString mKey; 107 QString mKey;
105 QString mApp; 108 QString mApp;
106}; 109};
107 110
108 111
109Field::List Field::mAllFields; 112Field::List Field::mAllFields;
110Field::List Field::mDefaultFields; 113Field::List Field::mDefaultFields;
111Field::List Field::mCustomFields; 114Field::List Field::mCustomFields;
112 115
113 116
114Field::Field( FieldImpl *impl ) 117Field::Field( FieldImpl *impl )
115{ 118{
116 mImpl = impl; 119 mImpl = impl;
117} 120}
118 121
119Field::~Field() 122Field::~Field()
120{ 123{
121 delete mImpl; 124 delete mImpl;
122} 125}
123 126
124QString Field::label() 127QString Field::label()
125{ 128{
126 switch ( mImpl->fieldId() ) { 129 switch ( mImpl->fieldId() ) {
127 case FieldImpl::FormattedName: 130 case FieldImpl::FormattedName:
128 return Addressee::formattedNameLabel(); 131 return Addressee::formattedNameLabel();
132 case FieldImpl::DefaultFormattedName:
133 return Addressee::defaultFormattedNameLabel();
129 case FieldImpl::FamilyName: 134 case FieldImpl::FamilyName:
130 return Addressee::familyNameLabel(); 135 return Addressee::familyNameLabel();
131 case FieldImpl::GivenName: 136 case FieldImpl::GivenName:
132 return Addressee::givenNameLabel(); 137 return Addressee::givenNameLabel();
133 case FieldImpl::AdditionalName: 138 case FieldImpl::AdditionalName:
134 return Addressee::additionalNameLabel(); 139 return Addressee::additionalNameLabel();
135 case FieldImpl::Prefix: 140 case FieldImpl::Prefix:
136 return Addressee::prefixLabel(); 141 return Addressee::prefixLabel();
137 case FieldImpl::Suffix: 142 case FieldImpl::Suffix:
138 return Addressee::suffixLabel(); 143 return Addressee::suffixLabel();
139 case FieldImpl::NickName: 144 case FieldImpl::NickName:
140 return Addressee::nickNameLabel(); 145 return Addressee::nickNameLabel();
141 case FieldImpl::Birthday: 146 case FieldImpl::Birthday:
142 return Addressee::birthdayLabel(); 147 return Addressee::birthdayLabel();
143 case FieldImpl::HomeAddressStreet: 148 case FieldImpl::HomeAddressStreet:
144 return Addressee::homeAddressStreetLabel(); 149 return Addressee::homeAddressStreetLabel();
145 case FieldImpl::HomeAddressLocality: 150 case FieldImpl::HomeAddressLocality:
146 return Addressee::homeAddressLocalityLabel(); 151 return Addressee::homeAddressLocalityLabel();
147 case FieldImpl::HomeAddressRegion: 152 case FieldImpl::HomeAddressRegion:
148 return Addressee::homeAddressRegionLabel(); 153 return Addressee::homeAddressRegionLabel();
149 case FieldImpl::HomeAddressPostalCode: 154 case FieldImpl::HomeAddressPostalCode:
150 return Addressee::homeAddressPostalCodeLabel(); 155 return Addressee::homeAddressPostalCodeLabel();
151 case FieldImpl::HomeAddressCountry: 156 case FieldImpl::HomeAddressCountry:
152 return Addressee::homeAddressCountryLabel(); 157 return Addressee::homeAddressCountryLabel();
153 case FieldImpl::HomeAddressLabel: 158 case FieldImpl::HomeAddressLabel:
154 return Addressee::homeAddressLabelLabel(); 159 return Addressee::homeAddressLabelLabel();
155 case FieldImpl::BusinessAddressStreet: 160 case FieldImpl::BusinessAddressStreet:
156 return Addressee::businessAddressStreetLabel(); 161 return Addressee::businessAddressStreetLabel();
157 case FieldImpl::BusinessAddressLocality: 162 case FieldImpl::BusinessAddressLocality:
158 return Addressee::businessAddressLocalityLabel(); 163 return Addressee::businessAddressLocalityLabel();
159 case FieldImpl::BusinessAddressRegion: 164 case FieldImpl::BusinessAddressRegion:
160 return Addressee::businessAddressRegionLabel(); 165 return Addressee::businessAddressRegionLabel();
161 case FieldImpl::BusinessAddressPostalCode: 166 case FieldImpl::BusinessAddressPostalCode:
162 return Addressee::businessAddressPostalCodeLabel(); 167 return Addressee::businessAddressPostalCodeLabel();
163 case FieldImpl::BusinessAddressCountry: 168 case FieldImpl::BusinessAddressCountry:
164 return Addressee::businessAddressCountryLabel(); 169 return Addressee::businessAddressCountryLabel();
165 case FieldImpl::BusinessAddressLabel: 170 case FieldImpl::BusinessAddressLabel:
166 return Addressee::businessAddressLabelLabel(); 171 return Addressee::businessAddressLabelLabel();
167 case FieldImpl::HomePhone: 172 case FieldImpl::HomePhone:
168 return Addressee::homePhoneLabel(); 173 return Addressee::homePhoneLabel();
169 case FieldImpl::BusinessPhone: 174 case FieldImpl::BusinessPhone:
170 return Addressee::businessPhoneLabel(); 175 return Addressee::businessPhoneLabel();
171 case FieldImpl::MobilePhone: 176 case FieldImpl::MobilePhone:
172 return Addressee::mobilePhoneLabel(); 177 return Addressee::mobilePhoneLabel();
178 case FieldImpl::MobileHomePhone:
179 return Addressee::mobileHomePhoneLabel();
180 case FieldImpl::MobileWorkPhone:
181 return Addressee::mobileWorkPhoneLabel();
173 case FieldImpl::HomeFax: 182 case FieldImpl::HomeFax:
174 return Addressee::homeFaxLabel(); 183 return Addressee::homeFaxLabel();
175 case FieldImpl::BusinessFax: 184 case FieldImpl::BusinessFax:
176 return Addressee::businessFaxLabel(); 185 return Addressee::businessFaxLabel();
177 case FieldImpl::CarPhone: 186 case FieldImpl::CarPhone:
178 return Addressee::carPhoneLabel(); 187 return Addressee::carPhoneLabel();
179 case FieldImpl::Isdn: 188 case FieldImpl::Isdn:
180 return Addressee::isdnLabel(); 189 return Addressee::isdnLabel();
181 case FieldImpl::Pager: 190 case FieldImpl::Pager:
182 return Addressee::pagerLabel(); 191 return Addressee::pagerLabel();
183 case FieldImpl::Email: 192 case FieldImpl::Email:
184 return Addressee::emailLabel(); 193 return Addressee::emailLabel();
185 case FieldImpl::Mailer: 194 case FieldImpl::Mailer:
186 return Addressee::mailerLabel(); 195 return Addressee::mailerLabel();
187 case FieldImpl::Title: 196 case FieldImpl::Title:
188 return Addressee::titleLabel(); 197 return Addressee::titleLabel();
189 case FieldImpl::Role: 198 case FieldImpl::Role:
190 return Addressee::roleLabel(); 199 return Addressee::roleLabel();
191 case FieldImpl::Organization: 200 case FieldImpl::Organization:
192 return Addressee::organizationLabel(); 201 return Addressee::organizationLabel();
193 case FieldImpl::Note: 202 case FieldImpl::Note:
194 return Addressee::noteLabel(); 203 return Addressee::noteLabel();
195 case FieldImpl::Url: 204 case FieldImpl::Url:
196 return Addressee::urlLabel(); 205 return Addressee::urlLabel();
197 case FieldImpl::Resource: 206 case FieldImpl::Resource:
198 return Addressee::resourceLabel(); 207 return Addressee::resourceLabel();
199 case FieldImpl::Category: 208 case FieldImpl::Category:
200 return Addressee::categoryLabel(); 209 return Addressee::categoryLabel();
201 case FieldImpl::Sip: 210 case FieldImpl::Sip:
202 return Addressee::sipLabel(); 211 return Addressee::sipLabel();
203 case FieldImpl::CustomField: 212 case FieldImpl::CustomField:
204 return mImpl->label(); 213 return mImpl->label();
205 default: 214 default:
206 return i18n("Unknown Field"); 215 return i18n("Unknown Field");
207 } 216 }
208} 217}
209 218
210int Field::category() 219int Field::category()
211{ 220{
212 return mImpl->category(); 221 return mImpl->category();
213} 222}
214 223
215QString Field::categoryLabel( int category ) 224QString Field::categoryLabel( int category )
216{ 225{
217 switch ( category ) { 226 switch ( category ) {
218 case All: 227 case All:
219 return i18n("All"); 228 return i18n("All");
220 case Frequent: 229 case Frequent:
221 return i18n("Frequent"); 230 return i18n("Frequent");
222 case Address: 231 case Address:
223 return i18n("Address"); 232 return i18n("Address");
224 case Email: 233 case Email:
225 return i18n("Email"); 234 return i18n("Email");
226 case Personal: 235 case Personal:
227 return i18n("Personal"); 236 return i18n("Personal");
228 case Organization: 237 case Organization:
229 return i18n("Organization"); 238 return i18n("Organization");
230 case CustomCategory: 239 case CustomCategory:
231 return i18n("Custom"); 240 return i18n("Custom");
232 default: 241 default:
233 return i18n("Undefined"); 242 return i18n("Undefined");
234 } 243 }
235} 244}
236 245
237QString Field::value( const KABC::Addressee &a ) 246QString Field::value( const KABC::Addressee &a )
238{ 247{
239 switch ( mImpl->fieldId() ) { 248 switch ( mImpl->fieldId() ) {
240 case FieldImpl::FormattedName: 249 case FieldImpl::FormattedName:
241 return a.formattedName(); 250 return a.formattedName();
251 case FieldImpl::DefaultFormattedName:
252 return a.defaultFormattedName();
242 case FieldImpl::FamilyName: 253 case FieldImpl::FamilyName:
243 return a.familyName(); 254 return a.familyName();
244 case FieldImpl::GivenName: 255 case FieldImpl::GivenName:
245 return a.givenName(); 256 return a.givenName();
246 case FieldImpl::AdditionalName: 257 case FieldImpl::AdditionalName:
247 return a.additionalName(); 258 return a.additionalName();
248 case FieldImpl::Prefix: 259 case FieldImpl::Prefix:
249 return a.prefix(); 260 return a.prefix();
250 case FieldImpl::Suffix: 261 case FieldImpl::Suffix:
251 return a.suffix(); 262 return a.suffix();
252 case FieldImpl::NickName: 263 case FieldImpl::NickName:
253 return a.nickName(); 264 return a.nickName();
254 case FieldImpl::Mailer: 265 case FieldImpl::Mailer:
255 return a.mailer(); 266 return a.mailer();
256 case FieldImpl::Title: 267 case FieldImpl::Title:
257 return a.title(); 268 return a.title();
258 case FieldImpl::Role: 269 case FieldImpl::Role:
259 return a.role(); 270 return a.role();
260 case FieldImpl::Organization: 271 case FieldImpl::Organization:
261 return a.organization(); 272 return a.organization();
262 case FieldImpl::Note: 273 case FieldImpl::Note:
263 return a.note(); 274 return a.note();
264 case FieldImpl::Email: 275 case FieldImpl::Email:
265 return a.preferredEmail(); 276 return a.preferredEmail();
266 case FieldImpl::Birthday: 277 case FieldImpl::Birthday:
267 if ( a.birthday().isValid() ) { 278 if ( a.birthday().isValid() ) {
268//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 279//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
269// But Qt::IsoDate was not specified. 280// But Qt::IsoDate was not specified.
270// QString _oldFormat = KGlobal::locale()->dateFormat(); 281// QString _oldFormat = KGlobal::locale()->dateFormat();
271// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 282// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
272 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 283 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
273// KGlobal::locale()->setDateFormat(_oldFormat); 284// KGlobal::locale()->setDateFormat(_oldFormat);
274 return dt; 285 return dt;
275 } 286 }
276 else 287 else
277 return QString::null; 288 return QString::null;
278 case FieldImpl::Url: 289 case FieldImpl::Url:
279 return a.url().prettyURL(); 290 return a.url().prettyURL();
280//US 291//US
281 case FieldImpl::Resource: 292 case FieldImpl::Resource:
282 return a.resource()->resourceName(); 293 return a.resource()->resourceName();
283 case FieldImpl::Category: 294 case FieldImpl::Category:
284 return a.categories().join(","); 295 return a.categories().join(",");
285 case FieldImpl::HomePhone: 296 case FieldImpl::HomePhone:
286 return a.phoneNumber( PhoneNumber::Home ).number(); 297 return a.phoneNumber( PhoneNumber::Home ).number();
287 case FieldImpl::BusinessPhone: 298 case FieldImpl::BusinessPhone:
288 return a.phoneNumber( PhoneNumber::Work ).number(); 299 return a.phoneNumber( PhoneNumber::Work ).number();
289 case FieldImpl::MobilePhone: 300 case FieldImpl::MobilePhone:
290 return a.phoneNumber( PhoneNumber::Cell ).number(); 301 return a.phoneNumber( PhoneNumber::Cell ).number();
302 case FieldImpl::MobileWorkPhone:
303 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number();
304 case FieldImpl::MobileHomePhone:
305 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number();
291 case FieldImpl::HomeFax: 306 case FieldImpl::HomeFax:
292 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 307 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
293 case FieldImpl::BusinessFax: 308 case FieldImpl::BusinessFax:
294 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 309 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
295 case FieldImpl::CarPhone: 310 case FieldImpl::CarPhone:
296 return a.phoneNumber( PhoneNumber::Car ).number(); 311 return a.phoneNumber( PhoneNumber::Car ).number();
297 case FieldImpl::Isdn: 312 case FieldImpl::Isdn:
298 return a.phoneNumber( PhoneNumber::Isdn ).number(); 313 return a.phoneNumber( PhoneNumber::Isdn ).number();
299 case FieldImpl::Pager: 314 case FieldImpl::Pager:
300 return a.phoneNumber( PhoneNumber::Pager ).number(); 315 return a.phoneNumber( PhoneNumber::Pager ).number();
301 case FieldImpl::Sip: 316 case FieldImpl::Sip:
302 return a.phoneNumber( PhoneNumber::Sip ).number(); 317 return a.phoneNumber( PhoneNumber::Sip ).number();
303 case FieldImpl::HomeAddressStreet: 318 case FieldImpl::HomeAddressStreet:
304 return a.address( Address::Home ).street(); 319 return a.address( Address::Home ).street();
305 case FieldImpl::HomeAddressLocality: 320 case FieldImpl::HomeAddressLocality:
306 return a.address( Address::Home ).locality(); 321 return a.address( Address::Home ).locality();
307 case FieldImpl::HomeAddressRegion: 322 case FieldImpl::HomeAddressRegion:
308 return a.address( Address::Home ).region(); 323 return a.address( Address::Home ).region();
309 case FieldImpl::HomeAddressPostalCode: 324 case FieldImpl::HomeAddressPostalCode:
310 return a.address( Address::Home ).postalCode(); 325 return a.address( Address::Home ).postalCode();
311 case FieldImpl::HomeAddressCountry: 326 case FieldImpl::HomeAddressCountry:
312 return a.address( Address::Home ).country(); 327 return a.address( Address::Home ).country();
313 case FieldImpl::BusinessAddressStreet: 328 case FieldImpl::BusinessAddressStreet:
314 return a.address( Address::Work ).street(); 329 return a.address( Address::Work ).street();
315 case FieldImpl::BusinessAddressLocality: 330 case FieldImpl::BusinessAddressLocality:
316 return a.address( Address::Work ).locality(); 331 return a.address( Address::Work ).locality();
317 case FieldImpl::BusinessAddressRegion: 332 case FieldImpl::BusinessAddressRegion:
318 return a.address( Address::Work ).region(); 333 return a.address( Address::Work ).region();
319 case FieldImpl::BusinessAddressPostalCode: 334 case FieldImpl::BusinessAddressPostalCode:
320 return a.address( Address::Work ).postalCode(); 335 return a.address( Address::Work ).postalCode();
321 case FieldImpl::BusinessAddressCountry: 336 case FieldImpl::BusinessAddressCountry:
322 return a.address( Address::Work ).country(); 337 return a.address( Address::Work ).country();
323 case FieldImpl::CustomField: 338 case FieldImpl::CustomField:
324 return a.custom( mImpl->app(), mImpl->key() ); 339 return a.custom( mImpl->app(), mImpl->key() );
325 default: 340 default:
326 return QString::null; 341 return QString::null;
327 } 342 }
328} 343}
329 344
330bool Field::setValue( KABC::Addressee &a, const QString &value ) 345bool Field::setValue( KABC::Addressee &a, const QString &value )
331{ 346{
332 switch ( mImpl->fieldId() ) { 347 switch ( mImpl->fieldId() ) {
333 case FieldImpl::FormattedName: 348 case FieldImpl::FormattedName:
334 a.setFormattedName( value ); 349 a.setFormattedName( value );
335 return true; 350 return true;
336 case FieldImpl::FamilyName: 351 case FieldImpl::FamilyName:
337 a.setFamilyName( value ); 352 a.setFamilyName( value );
338 return true; 353 return true;
339 case FieldImpl::GivenName: 354 case FieldImpl::GivenName:
340 a.setGivenName( value ); 355 a.setGivenName( value );
341 return true; 356 return true;
342 case FieldImpl::AdditionalName: 357 case FieldImpl::AdditionalName:
343 a.setAdditionalName( value ); 358 a.setAdditionalName( value );
344 return true; 359 return true;
345 case FieldImpl::Prefix: 360 case FieldImpl::Prefix:
346 a.setPrefix( value ); 361 a.setPrefix( value );
347 return true; 362 return true;
348 case FieldImpl::Suffix: 363 case FieldImpl::Suffix:
349 a.setSuffix( value ); 364 a.setSuffix( value );
350 return true; 365 return true;
351 case FieldImpl::NickName: 366 case FieldImpl::NickName:
352 a.setNickName( value ); 367 a.setNickName( value );
353 return true; 368 return true;
354 case FieldImpl::Mailer: 369 case FieldImpl::Mailer:
355 a.setMailer( value ); 370 a.setMailer( value );
356 return true; 371 return true;
357 case FieldImpl::Title: 372 case FieldImpl::Title:
358 a.setTitle( value ); 373 a.setTitle( value );
359 return true; 374 return true;
360 case FieldImpl::Role: 375 case FieldImpl::Role:
361 a.setRole( value ); 376 a.setRole( value );
362 return true; 377 return true;
363 case FieldImpl::Organization: 378 case FieldImpl::Organization:
364 a.setOrganization( value ); 379 a.setOrganization( value );
365 return true; 380 return true;
366 case FieldImpl::Note: 381 case FieldImpl::Note:
367 a.setNote( value ); 382 a.setNote( value );
368 return true; 383 return true;
369 case FieldImpl::Birthday: 384 case FieldImpl::Birthday:
370//US 385//US
371//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 386//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
372// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 387// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
373 { 388 {
374 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 389 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
375 a.setBirthday(dt); 390 a.setBirthday(dt);
376 } 391 }
377 return true; 392 return true;
378 case FieldImpl::CustomField: 393 case FieldImpl::CustomField:
379 a.insertCustom( mImpl->app(), mImpl->key(), value ); 394 a.insertCustom( mImpl->app(), mImpl->key(), value );
380//US never copy the resourcename back to the adressee. 395//US never copy the resourcename back to the adressee.
381 case FieldImpl::Resource: 396 case FieldImpl::Resource:
382 default: 397 default:
383 return false; 398 return false;
384 } 399 }
385} 400}
386 401
387bool Field::isCustom() 402bool Field::isCustom()
388{ 403{
389 return mImpl->fieldId() == FieldImpl::CustomField; 404 return mImpl->fieldId() == FieldImpl::CustomField;
390} 405}
391 406
392Field::List Field::allFields() 407Field::List Field::allFields()
393{ 408{
394 if ( mAllFields.isEmpty() ) { 409 if ( mAllFields.isEmpty() ) {
395 createField( FieldImpl::FormattedName, Frequent ); 410 createField( FieldImpl::FormattedName, Frequent );
411 createField( FieldImpl::DefaultFormattedName, Frequent );
396 createField( FieldImpl::FamilyName, Frequent ); 412 createField( FieldImpl::FamilyName, Frequent );
397 createField( FieldImpl::GivenName, Frequent ); 413 createField( FieldImpl::GivenName, Frequent );
398 createField( FieldImpl::AdditionalName ); 414 createField( FieldImpl::AdditionalName );
399 createField( FieldImpl::Prefix ); 415 createField( FieldImpl::Prefix );
400 createField( FieldImpl::Suffix ); 416 createField( FieldImpl::Suffix );
401 createField( FieldImpl::NickName, Personal ); 417 createField( FieldImpl::NickName, Personal );
402 createField( FieldImpl::Birthday, Personal ); 418 createField( FieldImpl::Birthday, Personal );
403 createField( FieldImpl::Category ); 419 createField( FieldImpl::Category );
404 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 420 createField( FieldImpl::HomeAddressStreet, Address|Personal );
405 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 421 createField( FieldImpl::HomeAddressLocality, Address|Personal );
406 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 422 createField( FieldImpl::HomeAddressRegion, Address|Personal );
407 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 423 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
408 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 424 createField( FieldImpl::HomeAddressCountry, Address|Personal );
409 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 425 createField( FieldImpl::HomeAddressLabel, Address|Personal );
410 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 426 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
411 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 427 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
412 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 428 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
413 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 429 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
414 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 430 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
415 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 431 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
416 createField( FieldImpl::HomePhone, Personal|Frequent ); 432 createField( FieldImpl::HomePhone, Personal|Frequent );
417 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 433 createField( FieldImpl::BusinessPhone, Organization|Frequent );
418 createField( FieldImpl::MobilePhone, Frequent ); 434 createField( FieldImpl::MobilePhone, Frequent );
435 createField( FieldImpl::MobileHomePhone, Frequent );
436 createField( FieldImpl::MobileWorkPhone, Frequent );
419 createField( FieldImpl::HomeFax ); 437 createField( FieldImpl::HomeFax );
420 createField( FieldImpl::BusinessFax ); 438 createField( FieldImpl::BusinessFax );
421 createField( FieldImpl::CarPhone ); 439 createField( FieldImpl::CarPhone );
422 createField( FieldImpl::Isdn ); 440 createField( FieldImpl::Isdn );
423 createField( FieldImpl::Pager ); 441 createField( FieldImpl::Pager );
424 createField( FieldImpl::Email, Email|Frequent ); 442 createField( FieldImpl::Email, Email|Frequent );
425 createField( FieldImpl::Mailer, Email ); 443 createField( FieldImpl::Mailer, Email );
426 createField( FieldImpl::Title, Organization ); 444 createField( FieldImpl::Title, Organization );
427 createField( FieldImpl::Role, Organization ); 445 createField( FieldImpl::Role, Organization );
428 createField( FieldImpl::Organization, Organization ); 446 createField( FieldImpl::Organization, Organization );
429 createField( FieldImpl::Note ); 447 createField( FieldImpl::Note );
430 createField( FieldImpl::Url ); 448 createField( FieldImpl::Url );
431 createField( FieldImpl::Resource ); 449 createField( FieldImpl::Resource );
432 createField( FieldImpl::Sip ); 450 createField( FieldImpl::Sip );
433 } 451 }
434 452
435 return mAllFields; 453 return mAllFields;
436} 454}
437 455
438Field::List Field::defaultFields() 456Field::List Field::defaultFields()
439{ 457{
440 if ( mDefaultFields.isEmpty() ) { 458 if ( mDefaultFields.isEmpty() ) {
441 createDefaultField( FieldImpl::GivenName ); 459 createDefaultField( FieldImpl::GivenName );
442 createDefaultField( FieldImpl::FamilyName ); 460 createDefaultField( FieldImpl::FamilyName );
443 createDefaultField( FieldImpl::Email ); 461 createDefaultField( FieldImpl::Email );
444 } 462 }
445 463
446 return mDefaultFields; 464 return mDefaultFields;
447} 465}
448 466
449void Field::createField( int id, int category ) 467void Field::createField( int id, int category )
450{ 468{
451 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 469 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
452} 470}
453 471
454void Field::createDefaultField( int id, int category ) 472void Field::createDefaultField( int id, int category )
455{ 473{
456 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 474 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
457} 475}
458 476
459void Field::deleteFields() 477void Field::deleteFields()
460{ 478{
461 Field::List::ConstIterator it; 479 Field::List::ConstIterator it;
462 480
463 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 481 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
464 delete (*it); 482 delete (*it);
465 } 483 }
466 mAllFields.clear(); 484 mAllFields.clear();
467 485
468 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 486 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
469 delete (*it); 487 delete (*it);
470 } 488 }
471 mDefaultFields.clear(); 489 mDefaultFields.clear();
472 490
473 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 491 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
474 delete (*it); 492 delete (*it);
475 } 493 }
476 mCustomFields.clear(); 494 mCustomFields.clear();
477} 495}
478 496
479void Field::saveFields( const QString &identifier, 497void Field::saveFields( const QString &identifier,
480 const Field::List &fields ) 498 const Field::List &fields )
481{ 499{
482 KConfig *cfg = KGlobal::config(); 500 KConfig *cfg = KGlobal::config();