author | ulf69 <ulf69> | 2004-06-30 22:07:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-30 22:07:56 (UTC) |
commit | 1b7b7755bfbedddc72293b784577ded4e684bd6f (patch) (side-by-side diff) | |
tree | ff4eba9b8bb53401d2000d70e73a40f7c330d577 /kabc | |
parent | c6f3a3f49498dca52d10418d845f4a84c0c6d941 (diff) | |
download | kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.zip kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.tar.gz kdepimpi-1b7b7755bfbedddc72293b784577ded4e684bd6f.tar.bz2 |
added a new field of type Resource. This allowes us to display in KAddressbook for each
Addressbookentry its location
-rw-r--r-- | kabc/addressee.cpp | 6 | ||||
-rw-r--r-- | kabc/addressee.h | 6 | ||||
-rw-r--r-- | kabc/field.cpp | 24 |
3 files changed, 32 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 5cb194a..d484073 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -1502,16 +1502,22 @@ void Addressee::setResource( Resource *resource ) mData->resource = resource; } Resource *Addressee::resource() const { return mData->resource; } +//US +QString Addressee::resourceLabel() +{ + return i18n("Resource"); +} + void Addressee::setChanged( bool value ) { detach(); mData->changed = value; } bool Addressee::changed() const { diff --git a/kabc/addressee.h b/kabc/addressee.h index ee98e03..393d1cc 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -787,16 +787,22 @@ class Addressee void setResource( Resource *resource ); /** Return pointer to resource. */ Resource *resource() const; /** + Return resourcelabel. + */ + //US + static QString resourceLabel(); + + /** Mark addressee as changed. */ void setChanged( bool value ); /** Return whether the addressee is changed. */ bool changed() const; diff --git a/kabc/field.cpp b/kabc/field.cpp index 41bbfde..bc2e176 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -27,16 +27,17 @@ $Id$ */ #include <klocale.h> #include <kconfig.h> #include <kconfigbase.h> #include <kglobal.h> #include "field.h" +#include "resource.h" using namespace KABC; class Field::FieldImpl { public: FieldImpl( int fieldId, int category = 0, const QString &label = QString::null, @@ -77,17 +78,18 @@ class Field::FieldImpl Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, - Url + Url, + Resource }; int fieldId() { return mFieldId; } int category() { return mCategory; } QString label() { return mLabel; } QString key() { return mKey; } QString app() { return mApp; } @@ -185,16 +187,18 @@ QString Field::label() case FieldImpl::Role: return Addressee::roleLabel(); case FieldImpl::Organization: return Addressee::organizationLabel(); case FieldImpl::Note: return Addressee::noteLabel(); case FieldImpl::Url: return Addressee::urlLabel(); + case FieldImpl::Resource: + return Addressee::resourceLabel(); case FieldImpl::CustomField: return mImpl->label(); default: return i18n("Unknown Field"); } } int Field::category() @@ -262,16 +266,19 @@ QString Field::value( const KABC::Addressee &a ) QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false); KGlobal::locale()->setDateFormat(_oldFormat); return dt; } else return QString::null; case FieldImpl::Url: return a.url().prettyURL(); +//US + case FieldImpl::Resource: + return a.resource()->resourceName(); case FieldImpl::HomePhone: return a.phoneNumber( PhoneNumber::Home ).number(); case FieldImpl::BusinessPhone: return a.phoneNumber( PhoneNumber::Work ).number(); case FieldImpl::MobilePhone: return a.phoneNumber( PhoneNumber::Cell ).number(); case FieldImpl::HomeFax: return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); @@ -355,16 +362,18 @@ bool Field::setValue( KABC::Addressee &a, const QString &value ) // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? { QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate a.setBirthday(dt); } return true; case FieldImpl::CustomField: a.insertCustom( mImpl->app(), mImpl->key(), value ); +//US never copy the resourcename back to the adressee. + case FieldImpl::Resource: default: return false; } } bool Field::isCustom() { return mImpl->fieldId() == FieldImpl::CustomField; @@ -403,16 +412,17 @@ Field::List Field::allFields() createField( FieldImpl::Pager ); createField( FieldImpl::Email, Email|Frequent ); createField( FieldImpl::Mailer, Email ); createField( FieldImpl::Title, Organization ); createField( FieldImpl::Role, Organization ); createField( FieldImpl::Organization, Organization ); createField( FieldImpl::Note ); createField( FieldImpl::Url ); + createField( FieldImpl::Resource ); } return mAllFields; } Field::List Field::defaultFields() { if ( mDefaultFields.isEmpty() ) { @@ -463,53 +473,56 @@ void Field::saveFields( const QString &identifier, } void Field::saveFields( KConfig *cfg, const QString &identifier, const Field::List &fields ) { QValueList<int> fieldIds; //US -//US qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); +// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); int custom = 0; Field::List::ConstIterator it; for( it = fields.begin(); it != fields.end(); ++it ) { //US -//US qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); +// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); fieldIds.append( (*it)->mImpl->fieldId() ); if( (*it)->isCustom() ) { QStringList customEntry; customEntry << (*it)->mImpl->label(); customEntry << (*it)->mImpl->key(); customEntry << (*it)->mImpl->app(); cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + QString::number( custom++ ), customEntry ); } } cfg->writeEntry( identifier, fieldIds ); } Field::List Field::restoreFields( const QString &identifier ) { +//US +// qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); + KConfig *cfg = KGlobal::config(); KConfigGroupSaver( cfg, "KABCFields" ); cfg->setGroup( "KABCFields" ); Field::List l = restoreFields( cfg, identifier ); return l; } Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) { QValueList<int> fieldIds = cfg->readIntListEntry( identifier); //US - qDebug("Field::restoreFields from %s", cfg->getFileName().latin1()); +// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); Field::List fields; int custom = 0; QValueList<int>::ConstIterator it; for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { FieldImpl *f = 0; if ( (*it) == FieldImpl::CustomField ) { @@ -539,12 +552,15 @@ bool Field::equals( Field *field ) } Field *Field::createCustomField( const QString &label, int category, const QString &key, const QString &app ) { Field *field = new Field( new FieldImpl( FieldImpl::CustomField, category | CustomCategory, label, key, app ) ); +//US +// qDebug("Field::createCustomField label %s", label.latin1() ); + mCustomFields.append( field ); return field; } |