author | zautrix <zautrix> | 2005-04-07 07:42:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-07 07:42:53 (UTC) |
commit | c82f9b40f6023dc7b39ac555cba8c4c313f15ca8 (patch) (side-by-side diff) | |
tree | e9e4f0c0ed3243ec060a475983b271bd27b40d15 /kabc | |
parent | 76e220bf1236ae6afa9d91f18f0cd9ced730cff0 (diff) | |
download | kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.zip kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.gz kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.bz2 |
added fields to kapi
-rw-r--r-- | kabc/addressee.cpp | 25 | ||||
-rw-r--r-- | kabc/addressee.h | 5 | ||||
-rw-r--r-- | kabc/field.cpp | 20 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 11 |
4 files changed, 54 insertions, 7 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 39d14bb..7f592e9 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -22,64 +22,65 @@ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kconfig.h> #include <ksharedptr.h> #include <kdebug.h> #include <kapplication.h> #include <klocale.h> #include <kidmanager.h> //US #include <kstandarddirs.h> #include <libkcal/syncdefines.h> //US #include "resource.h" #include "addressee.h" using namespace KABC; static bool matchBinaryPattern( int value, int pattern ); static bool matchBinaryPatternA( int value, int pattern ); static bool matchBinaryPatternP( int value, int pattern ); struct Addressee::AddresseeData : public KShared { QString uid; QString name; QString formattedName; + QString defaultFormattedName; QString familyName; QString givenName; QString additionalName; QString prefix; QString suffix; QString nickName; QDateTime birthday; QString mailer; TimeZone timeZone; Geo geo; QString title; QString role; QString organization; QString note; QString productId; QDateTime revision; QString sortString; QString externalUID; QString originalExternalUID; KURL url; Secrecy secrecy; Picture logo; Picture photo; Sound sound; Agent agent; QString mExternalId; PhoneNumber::List phoneNumbers; Address::List addresses; Key::List keys; QStringList emails; QStringList categories; QStringList custom; @@ -718,75 +719,91 @@ const QString Addressee::uid() const QString Addressee::uidLabel() { return i18n("Unique Identifier"); } void Addressee::setName( const QString &name ) { if ( name == mData->name ) return; detach(); mData->empty = false; mData->name = name; } QString Addressee::name() const { return mData->name; } QString Addressee::nameLabel() { return i18n("Name"); } void Addressee::setFormattedName( const QString &formattedName ) { if ( formattedName == mData->formattedName ) return; detach(); mData->empty = false; mData->formattedName = formattedName; } +void Addressee::setDefaultFormattedName( const QString &formattedName ) +{ + if ( formattedName == mData->defaultFormattedName ) return; + detach(); + mData->empty = false; + mData->defaultFormattedName = formattedName; +} QString Addressee::formattedName() const { return mData->formattedName; } +QString Addressee::defaultFormattedName() const +{ + return mData->defaultFormattedName; +} QString Addressee::formattedNameLabel() { return i18n("Formatted Name"); } +QString Addressee::defaultFormattedNameLabel() +{ + return i18n("Def.Formatted Name"); +} + void Addressee::setFamilyName( const QString &familyName ) { if ( familyName == mData->familyName ) return; detach(); mData->empty = false; mData->familyName = familyName; } QString Addressee::familyName() const { return mData->familyName; } QString Addressee::familyNameLabel() { return i18n("Family Name"); } void Addressee::setGivenName( const QString &givenName ) { if ( givenName == mData->givenName ) return; detach(); mData->empty = false; mData->givenName = givenName; } QString Addressee::givenName() const { return mData->givenName; } @@ -951,64 +968,72 @@ QString Addressee::businessAddressPostalCodeLabel() return i18n("Business Address Postal Code"); } QString Addressee::businessAddressCountryLabel() { return i18n("Business Address Country"); } QString Addressee::businessAddressLabelLabel() { return i18n("Business Address Label"); } QString Addressee::homePhoneLabel() { return i18n("Home Phone"); } QString Addressee::businessPhoneLabel() { return i18n("Business Phone"); } QString Addressee::mobilePhoneLabel() { return i18n("Mobile Phone"); } +QString Addressee::mobileWorkPhoneLabel() +{ + return i18n("Mobile (work)"); +} +QString Addressee::mobileHomePhoneLabel() +{ + return i18n("Mobile (home)"); +} QString Addressee::homeFaxLabel() { return i18n("Home Fax"); } QString Addressee::businessFaxLabel() { return i18n("Business Fax"); } QString Addressee::carPhoneLabel() { return i18n("Car Phone"); } QString Addressee::isdnLabel() { return i18n("ISDN"); } QString Addressee::pagerLabel() { return i18n("Pager"); } QString Addressee::sipLabel() diff --git a/kabc/addressee.h b/kabc/addressee.h index 8051fec..0d688f8 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -125,72 +125,75 @@ class Addressee bool containsAdr(const Addressee& addr ); /** Set unique identifier. */ void setUid( const QString &uid ); /** Return unique identifier. */ const QString uid() const; /** Return translated label for uid field. */ static QString uidLabel(); /** Set name. */ void setName( const QString &name ); /** Return name. */ QString name() const; /** Return translated label for name field. */ static QString nameLabel(); /** Set formatted name. */ void setFormattedName( const QString &formattedName ); + void setDefaultFormattedName( const QString &formattedName ); /** Return formatted name. */ QString formattedName() const; + QString defaultFormattedName() const; /** Return translated label for formattedName field. */ static QString formattedNameLabel(); + static QString defaultFormattedNameLabel(); /** Set family name. */ void setFamilyName( const QString &familyName ); /** Return family name. */ QString familyName() const; /** Return translated label for familyName field. */ static QString familyNameLabel(); /** Set given name. */ void setGivenName( const QString &givenName ); /** Return given name. */ QString givenName() const; /** Return translated label for givenName field. */ static QString givenNameLabel(); /** Set additional names. */ void setAdditionalName( const QString &additionalName ); /** @@ -299,64 +302,66 @@ class Addressee */ static QString businessAddressRegionLabel(); /** Return translated label for businessAddressPostalCode field. */ static QString businessAddressPostalCodeLabel(); /** Return translated label for businessAddressCountry field. */ static QString businessAddressCountryLabel(); /** Return translated label for businessAddressLabel field. */ static QString businessAddressLabelLabel(); /** Return translated label for homePhone field. */ static QString homePhoneLabel(); /** Return translated label for businessPhone field. */ static QString businessPhoneLabel(); /** Return translated label for mobilePhone field. */ static QString mobilePhoneLabel(); + static QString mobileWorkPhoneLabel(); + static QString mobileHomePhoneLabel(); /** Return translated label for homeFax field. */ static QString homeFaxLabel(); /** Return translated label for businessFax field. */ static QString businessFaxLabel(); /** Return translated label for carPhone field. */ static QString carPhoneLabel(); /** Return translated label for isdn field. */ static QString isdnLabel(); /** Return translated label for pager field. */ static QString pagerLabel(); /** Return translated label for sip field. */ static QString sipLabel(); /** diff --git a/kabc/field.cpp b/kabc/field.cpp index 89d0b77..5c561c3 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -57,148 +57,157 @@ class Field::FieldImpl Suffix, NickName, Birthday, Category, HomeAddressStreet, HomeAddressLocality, HomeAddressRegion, HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel, BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion, BusinessAddressPostalCode, BusinessAddressCountry, BusinessAddressLabel, HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, CarPhone, Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, Url, Resource, - Sip + Sip, + DefaultFormattedName, + MobileWorkPhone, + MobileHomePhone }; int fieldId() { return mFieldId; } int category() { return mCategory; } QString label() { return mLabel; } QString key() { return mKey; } QString app() { return mApp; } private: int mFieldId; int mCategory; QString mLabel; QString mKey; QString mApp; }; Field::List Field::mAllFields; Field::List Field::mDefaultFields; Field::List Field::mCustomFields; Field::Field( FieldImpl *impl ) { mImpl = impl; } Field::~Field() { delete mImpl; } QString Field::label() { switch ( mImpl->fieldId() ) { case FieldImpl::FormattedName: return Addressee::formattedNameLabel(); + case FieldImpl::DefaultFormattedName: + return Addressee::defaultFormattedNameLabel(); case FieldImpl::FamilyName: return Addressee::familyNameLabel(); case FieldImpl::GivenName: return Addressee::givenNameLabel(); case FieldImpl::AdditionalName: return Addressee::additionalNameLabel(); case FieldImpl::Prefix: return Addressee::prefixLabel(); case FieldImpl::Suffix: return Addressee::suffixLabel(); case FieldImpl::NickName: return Addressee::nickNameLabel(); case FieldImpl::Birthday: return Addressee::birthdayLabel(); case FieldImpl::HomeAddressStreet: return Addressee::homeAddressStreetLabel(); case FieldImpl::HomeAddressLocality: return Addressee::homeAddressLocalityLabel(); case FieldImpl::HomeAddressRegion: return Addressee::homeAddressRegionLabel(); case FieldImpl::HomeAddressPostalCode: return Addressee::homeAddressPostalCodeLabel(); case FieldImpl::HomeAddressCountry: return Addressee::homeAddressCountryLabel(); case FieldImpl::HomeAddressLabel: return Addressee::homeAddressLabelLabel(); case FieldImpl::BusinessAddressStreet: return Addressee::businessAddressStreetLabel(); case FieldImpl::BusinessAddressLocality: return Addressee::businessAddressLocalityLabel(); case FieldImpl::BusinessAddressRegion: return Addressee::businessAddressRegionLabel(); case FieldImpl::BusinessAddressPostalCode: return Addressee::businessAddressPostalCodeLabel(); case FieldImpl::BusinessAddressCountry: return Addressee::businessAddressCountryLabel(); case FieldImpl::BusinessAddressLabel: return Addressee::businessAddressLabelLabel(); case FieldImpl::HomePhone: return Addressee::homePhoneLabel(); case FieldImpl::BusinessPhone: return Addressee::businessPhoneLabel(); case FieldImpl::MobilePhone: return Addressee::mobilePhoneLabel(); + case FieldImpl::MobileHomePhone: + return Addressee::mobileHomePhoneLabel(); + case FieldImpl::MobileWorkPhone: + return Addressee::mobileWorkPhoneLabel(); case FieldImpl::HomeFax: return Addressee::homeFaxLabel(); case FieldImpl::BusinessFax: return Addressee::businessFaxLabel(); case FieldImpl::CarPhone: return Addressee::carPhoneLabel(); case FieldImpl::Isdn: return Addressee::isdnLabel(); case FieldImpl::Pager: return Addressee::pagerLabel(); case FieldImpl::Email: return Addressee::emailLabel(); case FieldImpl::Mailer: return Addressee::mailerLabel(); case FieldImpl::Title: return Addressee::titleLabel(); 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::Category: return Addressee::categoryLabel(); case FieldImpl::Sip: return Addressee::sipLabel(); case FieldImpl::CustomField: return mImpl->label(); @@ -210,113 +219,119 @@ QString Field::label() int Field::category() { return mImpl->category(); } QString Field::categoryLabel( int category ) { switch ( category ) { case All: return i18n("All"); case Frequent: return i18n("Frequent"); case Address: return i18n("Address"); case Email: return i18n("Email"); case Personal: return i18n("Personal"); case Organization: return i18n("Organization"); case CustomCategory: return i18n("Custom"); default: return i18n("Undefined"); } } QString Field::value( const KABC::Addressee &a ) { switch ( mImpl->fieldId() ) { case FieldImpl::FormattedName: return a.formattedName(); + case FieldImpl::DefaultFormattedName: + return a.defaultFormattedName(); case FieldImpl::FamilyName: return a.familyName(); case FieldImpl::GivenName: return a.givenName(); case FieldImpl::AdditionalName: return a.additionalName(); case FieldImpl::Prefix: return a.prefix(); case FieldImpl::Suffix: return a.suffix(); case FieldImpl::NickName: return a.nickName(); case FieldImpl::Mailer: return a.mailer(); case FieldImpl::Title: return a.title(); case FieldImpl::Role: return a.role(); case FieldImpl::Organization: return a.organization(); case FieldImpl::Note: return a.note(); case FieldImpl::Email: return a.preferredEmail(); case FieldImpl::Birthday: if ( a.birthday().isValid() ) { //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); // But Qt::IsoDate was not specified. // QString _oldFormat = KGlobal::locale()->dateFormat(); // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); // 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::Category: return a.categories().join(","); 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::MobileWorkPhone: + return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number(); + case FieldImpl::MobileHomePhone: + return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number(); case FieldImpl::HomeFax: return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); case FieldImpl::BusinessFax: return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); case FieldImpl::CarPhone: return a.phoneNumber( PhoneNumber::Car ).number(); case FieldImpl::Isdn: return a.phoneNumber( PhoneNumber::Isdn ).number(); case FieldImpl::Pager: return a.phoneNumber( PhoneNumber::Pager ).number(); case FieldImpl::Sip: return a.phoneNumber( PhoneNumber::Sip ).number(); case FieldImpl::HomeAddressStreet: return a.address( Address::Home ).street(); case FieldImpl::HomeAddressLocality: return a.address( Address::Home ).locality(); case FieldImpl::HomeAddressRegion: return a.address( Address::Home ).region(); case FieldImpl::HomeAddressPostalCode: return a.address( Address::Home ).postalCode(); case FieldImpl::HomeAddressCountry: return a.address( Address::Home ).country(); case FieldImpl::BusinessAddressStreet: return a.address( Address::Work ).street(); case FieldImpl::BusinessAddressLocality: return a.address( Address::Work ).locality(); case FieldImpl::BusinessAddressRegion: return a.address( Address::Work ).region(); case FieldImpl::BusinessAddressPostalCode: return a.address( Address::Work ).postalCode(); case FieldImpl::BusinessAddressCountry: return a.address( Address::Work ).country(); @@ -364,87 +379,90 @@ bool Field::setValue( KABC::Addressee &a, const QString &value ) a.setOrganization( value ); return true; case FieldImpl::Note: a.setNote( value ); return true; case FieldImpl::Birthday: //US //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); // 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; } Field::List Field::allFields() { if ( mAllFields.isEmpty() ) { createField( FieldImpl::FormattedName, Frequent ); + createField( FieldImpl::DefaultFormattedName, Frequent ); createField( FieldImpl::FamilyName, Frequent ); createField( FieldImpl::GivenName, Frequent ); createField( FieldImpl::AdditionalName ); createField( FieldImpl::Prefix ); createField( FieldImpl::Suffix ); createField( FieldImpl::NickName, Personal ); createField( FieldImpl::Birthday, Personal ); createField( FieldImpl::Category ); createField( FieldImpl::HomeAddressStreet, Address|Personal ); createField( FieldImpl::HomeAddressLocality, Address|Personal ); createField( FieldImpl::HomeAddressRegion, Address|Personal ); createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); createField( FieldImpl::HomeAddressCountry, Address|Personal ); createField( FieldImpl::HomeAddressLabel, Address|Personal ); createField( FieldImpl::BusinessAddressStreet, Address|Organization ); createField( FieldImpl::BusinessAddressLocality, Address|Organization ); createField( FieldImpl::BusinessAddressRegion, Address|Organization ); createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); createField( FieldImpl::BusinessAddressCountry, Address|Organization ); createField( FieldImpl::BusinessAddressLabel, Address|Organization ); createField( FieldImpl::HomePhone, Personal|Frequent ); createField( FieldImpl::BusinessPhone, Organization|Frequent ); createField( FieldImpl::MobilePhone, Frequent ); + createField( FieldImpl::MobileHomePhone, Frequent ); + createField( FieldImpl::MobileWorkPhone, Frequent ); createField( FieldImpl::HomeFax ); createField( FieldImpl::BusinessFax ); createField( FieldImpl::CarPhone ); createField( FieldImpl::Isdn ); 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 ); createField( FieldImpl::Sip ); } return mAllFields; } Field::List Field::defaultFields() { if ( mDefaultFields.isEmpty() ) { createDefaultField( FieldImpl::GivenName ); createDefaultField( FieldImpl::FamilyName ); createDefaultField( FieldImpl::Email ); } return mDefaultFields; } void Field::createField( int id, int category ) { diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 041effc..4c6231d 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp @@ -148,73 +148,72 @@ QString PhoneNumber::typeLabel() const if ( first ) first = false; } } return label; } QString PhoneNumber::label() const { return typeLabel( type() ); } PhoneNumber::TypeList PhoneNumber::typeList() { TypeList list; list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; return list; } QString PhoneNumber::label( int type ) { return typeLabel( type ); } QString PhoneNumber::typeLabel( int type ) { QString typeString; - if ((type & Home) == Home) - typeString += i18n("Home"); - else if ((type & Work) == Work) - typeString += i18n("Work"); - if (!typeString.isEmpty()) - typeString += " "; if ((type & Cell) == Cell) typeString += i18n("Mobile") +" "; + if ((type & Home) == Home) + typeString += i18n("Home")+" "; + else if ((type & Work) == Work) + typeString += i18n("Work")+" "; + if ((type & Sip) == Sip) typeString += i18n("SIP")+" "; if ((type & Car) == Car) typeString += i18n("Car")+" "; if ((type & Fax) == Fax) typeString += i18n("Fax"); else if ((type & Msg) == Msg) typeString += i18n("Messenger"); else if ((type & Video) == Video) typeString += i18n("Video"); else if ((type & Bbs) == Bbs) typeString += i18n("Mailbox"); else if ((type & Modem) == Modem) typeString += i18n("Modem"); else if ((type & Isdn) == Isdn) typeString += i18n("ISDN"); else if ((type & Pcs) == Pcs) typeString += i18n("PCS"); else if ((type & Pager) == Pager) typeString += i18n("Pager"); // add the prefered flag /* if ((type & Pref) == Pref) typeString += i18n("(p)"); */ //if we still have no match, return "other" if (typeString.isEmpty()) { if ((type & Voice) == Voice) return i18n("Voice"); else return i18n("Other"); |