-rw-r--r-- | kabc/field.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp index e27970e..d95cd19 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -55,65 +55,66 @@ class Field::FieldImpl | |||
55 | AdditionalName, | 55 | AdditionalName, |
56 | Prefix, | 56 | Prefix, |
57 | Suffix, | 57 | Suffix, |
58 | NickName, | 58 | NickName, |
59 | Birthday, | 59 | Birthday, |
60 | HomeAddressStreet, | 60 | HomeAddressStreet, |
61 | HomeAddressLocality, | 61 | HomeAddressLocality, |
62 | HomeAddressRegion, | 62 | HomeAddressRegion, |
63 | HomeAddressPostalCode, | 63 | HomeAddressPostalCode, |
64 | HomeAddressCountry, | 64 | HomeAddressCountry, |
65 | HomeAddressLabel, | 65 | HomeAddressLabel, |
66 | BusinessAddressStreet, | 66 | BusinessAddressStreet, |
67 | BusinessAddressLocality, | 67 | BusinessAddressLocality, |
68 | BusinessAddressRegion, | 68 | BusinessAddressRegion, |
69 | BusinessAddressPostalCode, | 69 | BusinessAddressPostalCode, |
70 | BusinessAddressCountry, | 70 | BusinessAddressCountry, |
71 | BusinessAddressLabel, | 71 | BusinessAddressLabel, |
72 | HomePhone, | 72 | HomePhone, |
73 | BusinessPhone, | 73 | BusinessPhone, |
74 | MobilePhone, | 74 | MobilePhone, |
75 | HomeFax, | 75 | HomeFax, |
76 | BusinessFax, | 76 | BusinessFax, |
77 | CarPhone, | 77 | CarPhone, |
78 | Isdn, | 78 | Isdn, |
79 | Pager, | 79 | Pager, |
80 | Email, | 80 | Email, |
81 | Mailer, | 81 | Mailer, |
82 | Title, | 82 | Title, |
83 | Role, | 83 | Role, |
84 | Organization, | 84 | Organization, |
85 | Note, | 85 | Note, |
86 | Url, | 86 | Url, |
87 | Resource | 87 | Resource, |
88 | Sip | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | int fieldId() { return mFieldId; } | 91 | int fieldId() { return mFieldId; } |
91 | int category() { return mCategory; } | 92 | int category() { return mCategory; } |
92 | 93 | ||
93 | QString label() { return mLabel; } | 94 | QString label() { return mLabel; } |
94 | QString key() { return mKey; } | 95 | QString key() { return mKey; } |
95 | QString app() { return mApp; } | 96 | QString app() { return mApp; } |
96 | 97 | ||
97 | private: | 98 | private: |
98 | int mFieldId; | 99 | int mFieldId; |
99 | int mCategory; | 100 | int mCategory; |
100 | 101 | ||
101 | QString mLabel; | 102 | QString mLabel; |
102 | QString mKey; | 103 | QString mKey; |
103 | QString mApp; | 104 | QString mApp; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | 107 | ||
107 | Field::List Field::mAllFields; | 108 | Field::List Field::mAllFields; |
108 | Field::List Field::mDefaultFields; | 109 | Field::List Field::mDefaultFields; |
109 | Field::List Field::mCustomFields; | 110 | Field::List Field::mCustomFields; |
110 | 111 | ||
111 | 112 | ||
112 | Field::Field( FieldImpl *impl ) | 113 | Field::Field( FieldImpl *impl ) |
113 | { | 114 | { |
114 | mImpl = impl; | 115 | mImpl = impl; |
115 | } | 116 | } |
116 | 117 | ||
117 | Field::~Field() | 118 | Field::~Field() |
118 | { | 119 | { |
119 | delete mImpl; | 120 | delete mImpl; |
@@ -165,64 +166,66 @@ QString Field::label() | |||
165 | case FieldImpl::HomePhone: | 166 | case FieldImpl::HomePhone: |
166 | return Addressee::homePhoneLabel(); | 167 | return Addressee::homePhoneLabel(); |
167 | case FieldImpl::BusinessPhone: | 168 | case FieldImpl::BusinessPhone: |
168 | return Addressee::businessPhoneLabel(); | 169 | return Addressee::businessPhoneLabel(); |
169 | case FieldImpl::MobilePhone: | 170 | case FieldImpl::MobilePhone: |
170 | return Addressee::mobilePhoneLabel(); | 171 | return Addressee::mobilePhoneLabel(); |
171 | case FieldImpl::HomeFax: | 172 | case FieldImpl::HomeFax: |
172 | return Addressee::homeFaxLabel(); | 173 | return Addressee::homeFaxLabel(); |
173 | case FieldImpl::BusinessFax: | 174 | case FieldImpl::BusinessFax: |
174 | return Addressee::businessFaxLabel(); | 175 | return Addressee::businessFaxLabel(); |
175 | case FieldImpl::CarPhone: | 176 | case FieldImpl::CarPhone: |
176 | return Addressee::carPhoneLabel(); | 177 | return Addressee::carPhoneLabel(); |
177 | case FieldImpl::Isdn: | 178 | case FieldImpl::Isdn: |
178 | return Addressee::isdnLabel(); | 179 | return Addressee::isdnLabel(); |
179 | case FieldImpl::Pager: | 180 | case FieldImpl::Pager: |
180 | return Addressee::pagerLabel(); | 181 | return Addressee::pagerLabel(); |
181 | case FieldImpl::Email: | 182 | case FieldImpl::Email: |
182 | return Addressee::emailLabel(); | 183 | return Addressee::emailLabel(); |
183 | case FieldImpl::Mailer: | 184 | case FieldImpl::Mailer: |
184 | return Addressee::mailerLabel(); | 185 | return Addressee::mailerLabel(); |
185 | case FieldImpl::Title: | 186 | case FieldImpl::Title: |
186 | return Addressee::titleLabel(); | 187 | return Addressee::titleLabel(); |
187 | case FieldImpl::Role: | 188 | case FieldImpl::Role: |
188 | return Addressee::roleLabel(); | 189 | return Addressee::roleLabel(); |
189 | case FieldImpl::Organization: | 190 | case FieldImpl::Organization: |
190 | return Addressee::organizationLabel(); | 191 | return Addressee::organizationLabel(); |
191 | case FieldImpl::Note: | 192 | case FieldImpl::Note: |
192 | return Addressee::noteLabel(); | 193 | return Addressee::noteLabel(); |
193 | case FieldImpl::Url: | 194 | case FieldImpl::Url: |
194 | return Addressee::urlLabel(); | 195 | return Addressee::urlLabel(); |
195 | case FieldImpl::Resource: | 196 | case FieldImpl::Resource: |
196 | return Addressee::resourceLabel(); | 197 | return Addressee::resourceLabel(); |
198 | case FieldImpl::Sip: | ||
199 | return Addressee::sipLabel(); | ||
197 | case FieldImpl::CustomField: | 200 | case FieldImpl::CustomField: |
198 | return mImpl->label(); | 201 | return mImpl->label(); |
199 | default: | 202 | default: |
200 | return i18n("Unknown Field"); | 203 | return i18n("Unknown Field"); |
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
204 | int Field::category() | 207 | int Field::category() |
205 | { | 208 | { |
206 | return mImpl->category(); | 209 | return mImpl->category(); |
207 | } | 210 | } |
208 | 211 | ||
209 | QString Field::categoryLabel( int category ) | 212 | QString Field::categoryLabel( int category ) |
210 | { | 213 | { |
211 | switch ( category ) { | 214 | switch ( category ) { |
212 | case All: | 215 | case All: |
213 | return i18n("All"); | 216 | return i18n("All"); |
214 | case Frequent: | 217 | case Frequent: |
215 | return i18n("Frequent"); | 218 | return i18n("Frequent"); |
216 | case Address: | 219 | case Address: |
217 | return i18n("Address"); | 220 | return i18n("Address"); |
218 | case Email: | 221 | case Email: |
219 | return i18n("Email"); | 222 | return i18n("Email"); |
220 | case Personal: | 223 | case Personal: |
221 | return i18n("Personal"); | 224 | return i18n("Personal"); |
222 | case Organization: | 225 | case Organization: |
223 | return i18n("Organization"); | 226 | return i18n("Organization"); |
224 | case CustomCategory: | 227 | case CustomCategory: |
225 | return i18n("Custom"); | 228 | return i18n("Custom"); |
226 | default: | 229 | default: |
227 | return i18n("Undefined"); | 230 | return i18n("Undefined"); |
228 | } | 231 | } |
@@ -261,64 +264,66 @@ QString Field::value( const KABC::Addressee &a ) | |||
261 | if ( a.birthday().isValid() ) { | 264 | if ( a.birthday().isValid() ) { |
262 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); | 265 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); |
263 | // But Qt::IsoDate was not specified. | 266 | // But Qt::IsoDate was not specified. |
264 | // QString _oldFormat = KGlobal::locale()->dateFormat(); | 267 | // QString _oldFormat = KGlobal::locale()->dateFormat(); |
265 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate | 268 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate |
266 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); | 269 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); |
267 | // KGlobal::locale()->setDateFormat(_oldFormat); | 270 | // KGlobal::locale()->setDateFormat(_oldFormat); |
268 | return dt; | 271 | return dt; |
269 | } | 272 | } |
270 | else | 273 | else |
271 | return QString::null; | 274 | return QString::null; |
272 | case FieldImpl::Url: | 275 | case FieldImpl::Url: |
273 | return a.url().prettyURL(); | 276 | return a.url().prettyURL(); |
274 | //US | 277 | //US |
275 | case FieldImpl::Resource: | 278 | case FieldImpl::Resource: |
276 | return a.resource()->resourceName(); | 279 | return a.resource()->resourceName(); |
277 | case FieldImpl::HomePhone: | 280 | case FieldImpl::HomePhone: |
278 | return a.phoneNumber( PhoneNumber::Home ).number(); | 281 | return a.phoneNumber( PhoneNumber::Home ).number(); |
279 | case FieldImpl::BusinessPhone: | 282 | case FieldImpl::BusinessPhone: |
280 | return a.phoneNumber( PhoneNumber::Work ).number(); | 283 | return a.phoneNumber( PhoneNumber::Work ).number(); |
281 | case FieldImpl::MobilePhone: | 284 | case FieldImpl::MobilePhone: |
282 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 285 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
283 | case FieldImpl::HomeFax: | 286 | case FieldImpl::HomeFax: |
284 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 287 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
285 | case FieldImpl::BusinessFax: | 288 | case FieldImpl::BusinessFax: |
286 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); | 289 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); |
287 | case FieldImpl::CarPhone: | 290 | case FieldImpl::CarPhone: |
288 | return a.phoneNumber( PhoneNumber::Car ).number(); | 291 | return a.phoneNumber( PhoneNumber::Car ).number(); |
289 | case FieldImpl::Isdn: | 292 | case FieldImpl::Isdn: |
290 | return a.phoneNumber( PhoneNumber::Isdn ).number(); | 293 | return a.phoneNumber( PhoneNumber::Isdn ).number(); |
291 | case FieldImpl::Pager: | 294 | case FieldImpl::Pager: |
292 | return a.phoneNumber( PhoneNumber::Pager ).number(); | 295 | return a.phoneNumber( PhoneNumber::Pager ).number(); |
296 | case FieldImpl::Sip: | ||
297 | return a.phoneNumber( PhoneNumber::Sip ).number(); | ||
293 | case FieldImpl::HomeAddressStreet: | 298 | case FieldImpl::HomeAddressStreet: |
294 | return a.address( Address::Home ).street(); | 299 | return a.address( Address::Home ).street(); |
295 | case FieldImpl::HomeAddressLocality: | 300 | case FieldImpl::HomeAddressLocality: |
296 | return a.address( Address::Home ).locality(); | 301 | return a.address( Address::Home ).locality(); |
297 | case FieldImpl::HomeAddressRegion: | 302 | case FieldImpl::HomeAddressRegion: |
298 | return a.address( Address::Home ).region(); | 303 | return a.address( Address::Home ).region(); |
299 | case FieldImpl::HomeAddressPostalCode: | 304 | case FieldImpl::HomeAddressPostalCode: |
300 | return a.address( Address::Home ).postalCode(); | 305 | return a.address( Address::Home ).postalCode(); |
301 | case FieldImpl::HomeAddressCountry: | 306 | case FieldImpl::HomeAddressCountry: |
302 | return a.address( Address::Home ).country(); | 307 | return a.address( Address::Home ).country(); |
303 | case FieldImpl::BusinessAddressStreet: | 308 | case FieldImpl::BusinessAddressStreet: |
304 | return a.address( Address::Work ).street(); | 309 | return a.address( Address::Work ).street(); |
305 | case FieldImpl::BusinessAddressLocality: | 310 | case FieldImpl::BusinessAddressLocality: |
306 | return a.address( Address::Work ).locality(); | 311 | return a.address( Address::Work ).locality(); |
307 | case FieldImpl::BusinessAddressRegion: | 312 | case FieldImpl::BusinessAddressRegion: |
308 | return a.address( Address::Work ).region(); | 313 | return a.address( Address::Work ).region(); |
309 | case FieldImpl::BusinessAddressPostalCode: | 314 | case FieldImpl::BusinessAddressPostalCode: |
310 | return a.address( Address::Work ).postalCode(); | 315 | return a.address( Address::Work ).postalCode(); |
311 | case FieldImpl::BusinessAddressCountry: | 316 | case FieldImpl::BusinessAddressCountry: |
312 | return a.address( Address::Work ).country(); | 317 | return a.address( Address::Work ).country(); |
313 | case FieldImpl::CustomField: | 318 | case FieldImpl::CustomField: |
314 | return a.custom( mImpl->app(), mImpl->key() ); | 319 | return a.custom( mImpl->app(), mImpl->key() ); |
315 | default: | 320 | default: |
316 | return QString::null; | 321 | return QString::null; |
317 | } | 322 | } |
318 | } | 323 | } |
319 | 324 | ||
320 | bool Field::setValue( KABC::Addressee &a, const QString &value ) | 325 | bool Field::setValue( KABC::Addressee &a, const QString &value ) |
321 | { | 326 | { |
322 | switch ( mImpl->fieldId() ) { | 327 | switch ( mImpl->fieldId() ) { |
323 | case FieldImpl::FormattedName: | 328 | case FieldImpl::FormattedName: |
324 | a.setFormattedName( value ); | 329 | a.setFormattedName( value ); |
@@ -389,64 +394,65 @@ Field::List Field::allFields() | |||
389 | createField( FieldImpl::Prefix ); | 394 | createField( FieldImpl::Prefix ); |
390 | createField( FieldImpl::Suffix ); | 395 | createField( FieldImpl::Suffix ); |
391 | createField( FieldImpl::NickName, Personal ); | 396 | createField( FieldImpl::NickName, Personal ); |
392 | createField( FieldImpl::Birthday, Personal ); | 397 | createField( FieldImpl::Birthday, Personal ); |
393 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 398 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
394 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 399 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
395 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 400 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
396 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 401 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
397 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 402 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
398 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 403 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
399 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 404 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
400 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 405 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); |
401 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); | 406 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); |
402 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); | 407 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); |
403 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); | 408 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); |
404 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); | 409 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); |
405 | createField( FieldImpl::HomePhone, Personal|Frequent ); | 410 | createField( FieldImpl::HomePhone, Personal|Frequent ); |
406 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); | 411 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); |
407 | createField( FieldImpl::MobilePhone, Frequent ); | 412 | createField( FieldImpl::MobilePhone, Frequent ); |
408 | createField( FieldImpl::HomeFax ); | 413 | createField( FieldImpl::HomeFax ); |
409 | createField( FieldImpl::BusinessFax ); | 414 | createField( FieldImpl::BusinessFax ); |
410 | createField( FieldImpl::CarPhone ); | 415 | createField( FieldImpl::CarPhone ); |
411 | createField( FieldImpl::Isdn ); | 416 | createField( FieldImpl::Isdn ); |
412 | createField( FieldImpl::Pager ); | 417 | createField( FieldImpl::Pager ); |
413 | createField( FieldImpl::Email, Email|Frequent ); | 418 | createField( FieldImpl::Email, Email|Frequent ); |
414 | createField( FieldImpl::Mailer, Email ); | 419 | createField( FieldImpl::Mailer, Email ); |
415 | createField( FieldImpl::Title, Organization ); | 420 | createField( FieldImpl::Title, Organization ); |
416 | createField( FieldImpl::Role, Organization ); | 421 | createField( FieldImpl::Role, Organization ); |
417 | createField( FieldImpl::Organization, Organization ); | 422 | createField( FieldImpl::Organization, Organization ); |
418 | createField( FieldImpl::Note ); | 423 | createField( FieldImpl::Note ); |
419 | createField( FieldImpl::Url ); | 424 | createField( FieldImpl::Url ); |
420 | createField( FieldImpl::Resource ); | 425 | createField( FieldImpl::Resource ); |
426 | createField( FieldImpl::Sip ); | ||
421 | } | 427 | } |
422 | 428 | ||
423 | return mAllFields; | 429 | return mAllFields; |
424 | } | 430 | } |
425 | 431 | ||
426 | Field::List Field::defaultFields() | 432 | Field::List Field::defaultFields() |
427 | { | 433 | { |
428 | if ( mDefaultFields.isEmpty() ) { | 434 | if ( mDefaultFields.isEmpty() ) { |
429 | createDefaultField( FieldImpl::GivenName ); | 435 | createDefaultField( FieldImpl::GivenName ); |
430 | createDefaultField( FieldImpl::FamilyName ); | 436 | createDefaultField( FieldImpl::FamilyName ); |
431 | createDefaultField( FieldImpl::Email ); | 437 | createDefaultField( FieldImpl::Email ); |
432 | } | 438 | } |
433 | 439 | ||
434 | return mDefaultFields; | 440 | return mDefaultFields; |
435 | } | 441 | } |
436 | 442 | ||
437 | void Field::createField( int id, int category ) | 443 | void Field::createField( int id, int category ) |
438 | { | 444 | { |
439 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); | 445 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); |
440 | } | 446 | } |
441 | 447 | ||
442 | void Field::createDefaultField( int id, int category ) | 448 | void Field::createDefaultField( int id, int category ) |
443 | { | 449 | { |
444 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); | 450 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); |
445 | } | 451 | } |
446 | 452 | ||
447 | void Field::deleteFields() | 453 | void Field::deleteFields() |
448 | { | 454 | { |
449 | Field::List::ConstIterator it; | 455 | Field::List::ConstIterator it; |
450 | 456 | ||
451 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { | 457 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { |
452 | delete (*it); | 458 | delete (*it); |