-rw-r--r-- | kabc/field.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp index 41bbfde..bc2e176 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -31,8 +31,9 @@ $Id$ | |||
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 | 36 | ||
36 | using namespace KABC; | 37 | using namespace KABC; |
37 | 38 | ||
38 | class Field::FieldImpl | 39 | class Field::FieldImpl |
@@ -81,9 +82,10 @@ class Field::FieldImpl | |||
81 | Title, | 82 | Title, |
82 | Role, | 83 | Role, |
83 | Organization, | 84 | Organization, |
84 | Note, | 85 | Note, |
85 | Url | 86 | Url, |
87 | Resource | ||
86 | }; | 88 | }; |
87 | 89 | ||
88 | int fieldId() { return mFieldId; } | 90 | int fieldId() { return mFieldId; } |
89 | int category() { return mCategory; } | 91 | int category() { return mCategory; } |
@@ -189,8 +191,10 @@ QString Field::label() | |||
189 | case FieldImpl::Note: | 191 | case FieldImpl::Note: |
190 | return Addressee::noteLabel(); | 192 | return Addressee::noteLabel(); |
191 | case FieldImpl::Url: | 193 | case FieldImpl::Url: |
192 | return Addressee::urlLabel(); | 194 | return Addressee::urlLabel(); |
195 | case FieldImpl::Resource: | ||
196 | return Addressee::resourceLabel(); | ||
193 | case FieldImpl::CustomField: | 197 | case FieldImpl::CustomField: |
194 | return mImpl->label(); | 198 | return mImpl->label(); |
195 | default: | 199 | default: |
196 | return i18n("Unknown Field"); | 200 | return i18n("Unknown Field"); |
@@ -266,8 +270,11 @@ QString Field::value( const KABC::Addressee &a ) | |||
266 | else | 270 | else |
267 | return QString::null; | 271 | return QString::null; |
268 | case FieldImpl::Url: | 272 | case FieldImpl::Url: |
269 | return a.url().prettyURL(); | 273 | return a.url().prettyURL(); |
274 | //US | ||
275 | case FieldImpl::Resource: | ||
276 | return a.resource()->resourceName(); | ||
270 | case FieldImpl::HomePhone: | 277 | case FieldImpl::HomePhone: |
271 | return a.phoneNumber( PhoneNumber::Home ).number(); | 278 | return a.phoneNumber( PhoneNumber::Home ).number(); |
272 | case FieldImpl::BusinessPhone: | 279 | case FieldImpl::BusinessPhone: |
273 | return a.phoneNumber( PhoneNumber::Work ).number(); | 280 | return a.phoneNumber( PhoneNumber::Work ).number(); |
@@ -359,8 +366,10 @@ bool Field::setValue( KABC::Addressee &a, const QString &value ) | |||
359 | } | 366 | } |
360 | return true; | 367 | return true; |
361 | case FieldImpl::CustomField: | 368 | case FieldImpl::CustomField: |
362 | a.insertCustom( mImpl->app(), mImpl->key(), value ); | 369 | a.insertCustom( mImpl->app(), mImpl->key(), value ); |
370 | //US never copy the resourcename back to the adressee. | ||
371 | case FieldImpl::Resource: | ||
363 | default: | 372 | default: |
364 | return false; | 373 | return false; |
365 | } | 374 | } |
366 | } | 375 | } |
@@ -407,8 +416,9 @@ Field::List Field::allFields() | |||
407 | createField( FieldImpl::Role, Organization ); | 416 | createField( FieldImpl::Role, Organization ); |
408 | createField( FieldImpl::Organization, Organization ); | 417 | createField( FieldImpl::Organization, Organization ); |
409 | createField( FieldImpl::Note ); | 418 | createField( FieldImpl::Note ); |
410 | createField( FieldImpl::Url ); | 419 | createField( FieldImpl::Url ); |
420 | createField( FieldImpl::Resource ); | ||
411 | } | 421 | } |
412 | 422 | ||
413 | return mAllFields; | 423 | return mAllFields; |
414 | } | 424 | } |
@@ -467,15 +477,15 @@ void Field::saveFields( KConfig *cfg, const QString &identifier, | |||
467 | { | 477 | { |
468 | QValueList<int> fieldIds; | 478 | QValueList<int> fieldIds; |
469 | 479 | ||
470 | //US | 480 | //US |
471 | //US qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); | 481 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); |
472 | 482 | ||
473 | int custom = 0; | 483 | int custom = 0; |
474 | Field::List::ConstIterator it; | 484 | Field::List::ConstIterator it; |
475 | for( it = fields.begin(); it != fields.end(); ++it ) { | 485 | for( it = fields.begin(); it != fields.end(); ++it ) { |
476 | //US | 486 | //US |
477 | //US qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); | 487 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); |
478 | 488 | ||
479 | fieldIds.append( (*it)->mImpl->fieldId() ); | 489 | fieldIds.append( (*it)->mImpl->fieldId() ); |
480 | if( (*it)->isCustom() ) { | 490 | if( (*it)->isCustom() ) { |
481 | QStringList customEntry; | 491 | QStringList customEntry; |
@@ -490,8 +500,11 @@ void Field::saveFields( KConfig *cfg, const QString &identifier, | |||
490 | } | 500 | } |
491 | 501 | ||
492 | Field::List Field::restoreFields( const QString &identifier ) | 502 | Field::List Field::restoreFields( const QString &identifier ) |
493 | { | 503 | { |
504 | //US | ||
505 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); | ||
506 | |||
494 | KConfig *cfg = KGlobal::config(); | 507 | KConfig *cfg = KGlobal::config(); |
495 | KConfigGroupSaver( cfg, "KABCFields" ); | 508 | KConfigGroupSaver( cfg, "KABCFields" ); |
496 | cfg->setGroup( "KABCFields" ); | 509 | cfg->setGroup( "KABCFields" ); |
497 | 510 | ||
@@ -503,9 +516,9 @@ Field::List Field::restoreFields( const QString &identifier ) | |||
503 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) | 516 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) |
504 | { | 517 | { |
505 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); | 518 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); |
506 | //US | 519 | //US |
507 | qDebug("Field::restoreFields from %s", cfg->getFileName().latin1()); | 520 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); |
508 | 521 | ||
509 | Field::List fields; | 522 | Field::List fields; |
510 | 523 | ||
511 | int custom = 0; | 524 | int custom = 0; |
@@ -543,8 +556,11 @@ Field *Field::createCustomField( const QString &label, int category, | |||
543 | { | 556 | { |
544 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, | 557 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, |
545 | category | CustomCategory, | 558 | category | CustomCategory, |
546 | label, key, app ) ); | 559 | label, key, app ) ); |
560 | //US | ||
561 | // qDebug("Field::createCustomField label %s", label.latin1() ); | ||
562 | |||
547 | mCustomFields.append( field ); | 563 | mCustomFields.append( field ); |
548 | 564 | ||
549 | return field; | 565 | return field; |
550 | } | 566 | } |