author | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
commit | da80b510e4643fa3f78cf3f97af108e87097583d (patch) (side-by-side diff) | |
tree | 01c328362a6bf1898853ba26fd5d48eb5cff1e27 | |
parent | aafa695508796e86e9f267633ea5e6965d876031 (diff) | |
download | kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.zip kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.gz kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.bz2 |
added better category handling to kapi
-rw-r--r-- | kabc/addressee.cpp | 4 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-rw-r--r-- | kabc/field.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 54 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 5 |
5 files changed, 68 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index eec0f1f..3ce733d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -1807,327 +1807,331 @@ Address::List Addressee::addresses( int type ) const if ( matchBinaryPattern( (*it).type(), type ) ) { list.append( *it ); } } return list; } Address Addressee::findAddress( const QString &id ) const { Address::List::ConstIterator it; for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { if ( (*it).id() == id ) { return *it; } } return Address(); } void Addressee::insertCategory( const QString &c ) { detach(); mData->empty = false; if ( mData->categories.contains( c ) ) return; mData->categories.append( c ); } void Addressee::removeCategory( const QString &c ) { detach(); QStringList::Iterator it = mData->categories.find( c ); if ( it == mData->categories.end() ) return; mData->categories.remove( it ); } bool Addressee::hasCategory( const QString &c ) const { return ( mData->categories.contains( c ) ); } void Addressee::setCategories( const QStringList &c ) { detach(); mData->empty = false; mData->categories = c; } QStringList Addressee::categories() const { return mData->categories; } void Addressee::insertCustom( const QString &app, const QString &name, const QString &value ) { if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; detach(); mData->empty = false; QString qualifiedName = app + "-" + name + ":"; QStringList::Iterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { (*it) = qualifiedName + value; return; } } mData->custom.append( qualifiedName + value ); } void Addressee::removeCustom( const QString &app, const QString &name) { detach(); QString qualifiedName = app + "-" + name + ":"; QStringList::Iterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { mData->custom.remove( it ); return; } } } QString Addressee::custom( const QString &app, const QString &name ) const { QString qualifiedName = app + "-" + name + ":"; QString value; QStringList::ConstIterator it; for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { if ( (*it).startsWith( qualifiedName ) ) { value = (*it).mid( (*it).find( ":" ) + 1 ); break; } } return value; } void Addressee::setCustoms( const QStringList &l ) { detach(); mData->empty = false; mData->custom = l; } QStringList Addressee::customs() const { return mData->custom; } void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, QString &email) { int startPos, endPos, len; QString partA, partB, result; char endCh = '>'; startPos = rawEmail.find('<'); if (startPos < 0) { startPos = rawEmail.find('('); endCh = ')'; } if (startPos < 0) { // We couldn't find any separators, so we assume the whole string // is the email address email = rawEmail; fullName = ""; } else { // We have a start position, try to find an end endPos = rawEmail.find(endCh, startPos+1); if (endPos < 0) { // We couldn't find the end of the email address. We can only // assume the entire string is the email address. email = rawEmail; fullName = ""; } else { // We have a start and end to the email address // Grab the name part fullName = rawEmail.left(startPos).stripWhiteSpace(); // grab the email part email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); // Check that we do not have any extra characters on the end of the // strings len = fullName.length(); if (fullName[0]=='"' && fullName[len-1]=='"') fullName = fullName.mid(1, len-2); else if (fullName[0]=='<' && fullName[len-1]=='>') fullName = fullName.mid(1, len-2); else if (fullName[0]=='(' && fullName[len-1]==')') fullName = fullName.mid(1, len-2); } } } void Addressee::setResource( Resource *resource ) { detach(); mData->resource = resource; } Resource *Addressee::resource() const { return mData->resource; } //US QString Addressee::resourceLabel() { return i18n("Resource"); } +QString Addressee::categoryLabel() +{ + return i18n("Category"); +} void Addressee::setChanged( bool value ) { detach(); mData->changed = value; } bool Addressee::changed() const { return mData->changed; } void Addressee::setTagged( bool value ) { detach(); mData->tagged = value; } bool Addressee::tagged() const { return mData->tagged; } QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) { if (!a.mData) return s; s << a.uid(); s << a.mData->name; s << a.mData->formattedName; s << a.mData->familyName; s << a.mData->givenName; s << a.mData->additionalName; s << a.mData->prefix; s << a.mData->suffix; s << a.mData->nickName; s << a.mData->birthday; s << a.mData->mailer; s << a.mData->timeZone; s << a.mData->geo; s << a.mData->title; s << a.mData->role; s << a.mData->organization; s << a.mData->note; s << a.mData->productId; s << a.mData->revision; s << a.mData->sortString; s << a.mData->url; s << a.mData->secrecy; s << a.mData->logo; s << a.mData->photo; s << a.mData->sound; s << a.mData->agent; s << a.mData->phoneNumbers; s << a.mData->addresses; s << a.mData->emails; s << a.mData->categories; s << a.mData->custom; s << a.mData->keys; return s; } QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) { if (!a.mData) return s; s >> a.mData->uid; s >> a.mData->name; s >> a.mData->formattedName; s >> a.mData->familyName; s >> a.mData->givenName; s >> a.mData->additionalName; s >> a.mData->prefix; s >> a.mData->suffix; s >> a.mData->nickName; s >> a.mData->birthday; s >> a.mData->mailer; s >> a.mData->timeZone; s >> a.mData->geo; s >> a.mData->title; s >> a.mData->role; s >> a.mData->organization; s >> a.mData->note; s >> a.mData->productId; s >> a.mData->revision; s >> a.mData->sortString; s >> a.mData->url; s >> a.mData->secrecy; s >> a.mData->logo; s >> a.mData->photo; s >> a.mData->sound; s >> a.mData->agent; s >> a.mData->phoneNumbers; s >> a.mData->addresses; s >> a.mData->emails; s >> a.mData->categories; s >> a.mData->custom; s >> a.mData->keys; a.mData->empty = false; return s; } bool matchBinaryPattern( int value, int pattern ) { /** We want to match all telephonnumbers/addresses which have the bits in the pattern set. More are allowed. if pattern == 0 we have a special handling, then we want only those with exactly no bit set. */ if ( pattern == 0 ) return ( value == 0 ); else return ( pattern == ( pattern & value ) ); } bool matchBinaryPatternP( int value, int pattern ) { if ( pattern == 0 ) return ( value == 0 ); else return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); } bool matchBinaryPatternA( int value, int pattern ) { if ( pattern == 0 ) return ( value == 0 ); else return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); } diff --git a/kabc/addressee.h b/kabc/addressee.h index 2c81c1a..08d2f56 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -634,220 +634,220 @@ class Addressee /** Insert a phone number. If a phone number with the same id already exists in this addressee it is not duplicated. */ void insertPhoneNumber( const PhoneNumber &phoneNumber ); /** Remove phone number. If no phone number with the given id exists for this addresse nothing happens. */ void removePhoneNumber( const PhoneNumber &phoneNumber ); /** Return phone number, which matches the given type. */ PhoneNumber phoneNumber( int type ) const; /** Return list of all phone numbers. */ PhoneNumber::List phoneNumbers() const; /** Return list of phone numbers with a special type. */ PhoneNumber::List phoneNumbers( int type ) const; /** Return phone number with the given id. */ PhoneNumber findPhoneNumber( const QString &id ) const; /** Insert a key. If a key with the same id already exists in this addressee it is not duplicated. */ void insertKey( const Key &key ); /** Remove a key. If no key with the given id exists for this addresse nothing happens. */ void removeKey( const Key &key ); /** Return key, which matches the given type. If @p type == Key::Custom you can specify a string that should match. If you leave the string empty, the first key with a custom value is returned. */ Key key( int type, QString customTypeString = QString::null ) const; /** Return list of all keys. */ Key::List keys() const; /** Set the list of keys @param keys The keys to be set. */ void setKeys( const Key::List& keys); /** Return list of keys with a special type. If @p type == Key::Custom you can specify a string that should match. If you leave the string empty, all custom keys will be returned. */ Key::List keys( int type, QString customTypeString = QString::null ) const; /** Return key with the given id. */ Key findKey( const QString &id ) const; /** Insert an address. If an address with the same id already exists in this addressee it is not duplicated. */ void insertAddress( const Address &address ); /** Remove address. If no address with the given id exists for this addresse nothing happens. */ void removeAddress( const Address &address ); /** Return address, which matches the given type. */ Address address( int type ) const; /** Return list of all addresses. */ Address::List addresses() const; /** Return list of addresses with a special type. */ Address::List addresses( int type ) const; /** Return address with the given id. */ Address findAddress( const QString &id ) const; /** Insert category. If the category already exists it is not duplicated. */ void insertCategory( const QString & ); /** Remove category. */ void removeCategory( const QString & ); /** Return, if addressee has the given category. */ bool hasCategory( const QString & ) const; /** Set categories to given value. */ void setCategories( const QStringList & ); /** Return list of all set categories. */ QStringList categories() const; /** Insert custom entry. The entry is identified by the name of the inserting application and a unique name. If an entry with the given app and name already exists its value is replaced with the new given value. */ void insertCustom( const QString &app, const QString &name, const QString &value ); /** Remove custom entry. */ void removeCustom( const QString &app, const QString &name ); /** Return value of custom entry, identified by app and entry name. */ QString custom( const QString &app, const QString &name ) const; /** Set all custom entries. */ void setCustoms( const QStringList & ); /** Return list of all custom entries. */ QStringList customs() const; /** Parse full email address. The result is given back in fullName and email. */ static void parseEmailAddress( const QString &rawEmail, QString &fullName, QString &email ); /** Debug output. */ void dump() const; /** Returns string representation of the addressee. */ QString asString() const; /** Set resource where the addressee is from. */ void setResource( Resource *resource ); /** Return pointer to resource. */ Resource *resource() const; /** Return resourcelabel. */ //US static QString resourceLabel(); - + static QString categoryLabel(); /** Mark addressee as changed. */ void setChanged( bool value ); /** Return whether the addressee is changed. */ bool changed() const; void setTagged( bool value ); bool tagged() const; private: Addressee copy(); void detach(); struct AddresseeData; mutable KSharedPtr<AddresseeData> mData; }; QDataStream &operator<<( QDataStream &, const Addressee & ); QDataStream &operator>>( QDataStream &, Addressee & ); } #endif diff --git a/kabc/field.cpp b/kabc/field.cpp index d95cd19..89d0b77 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -1,572 +1,578 @@ /*** Warning! This file has been generated by the script makeaddressee ***/ /* This file is part of libkabc. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $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, const QString &key = QString::null, const QString &app = QString::null ) : mFieldId( fieldId ), mCategory( category ), mLabel( label ), mKey( key ), mApp( app ) {} enum FieldId { CustomField, FormattedName, FamilyName, GivenName, AdditionalName, Prefix, 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 }; 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::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::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(); default: return i18n("Unknown Field"); } } 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::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::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(); case FieldImpl::CustomField: return a.custom( mImpl->app(), mImpl->key() ); default: return QString::null; } } bool Field::setValue( KABC::Addressee &a, const QString &value ) { switch ( mImpl->fieldId() ) { case FieldImpl::FormattedName: a.setFormattedName( value ); return true; case FieldImpl::FamilyName: a.setFamilyName( value ); return true; case FieldImpl::GivenName: a.setGivenName( value ); return true; case FieldImpl::AdditionalName: a.setAdditionalName( value ); return true; case FieldImpl::Prefix: a.setPrefix( value ); return true; case FieldImpl::Suffix: a.setSuffix( value ); return true; case FieldImpl::NickName: a.setNickName( value ); return true; case FieldImpl::Mailer: a.setMailer( value ); return true; case FieldImpl::Title: a.setTitle( value ); return true; case FieldImpl::Role: a.setRole( value ); return true; case FieldImpl::Organization: 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::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::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 ) { mAllFields.append( new Field( new FieldImpl( id, category ) ) ); } void Field::createDefaultField( int id, int category ) { mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); } void Field::deleteFields() { Field::List::ConstIterator it; for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { delete (*it); } mAllFields.clear(); for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { delete (*it); } mDefaultFields.clear(); for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { delete (*it); } mCustomFields.clear(); } void Field::saveFields( const QString &identifier, const Field::List &fields ) { KConfig *cfg = KGlobal::config(); KConfigGroupSaver( cfg, "KABCFields" ); saveFields( cfg, identifier, fields ); } void Field::saveFields( KConfig *cfg, const QString &identifier, const Field::List &fields ) { QValueList<int> fieldIds; //US // 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 // 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, 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 ) { QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + identifier + "_" + QString::number( custom++ ) ); f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], customEntry[ 1 ], customEntry[ 2 ] ); } else { f = new FieldImpl( *it ); } fields.append( new Field( f ) ); } return fields; } bool Field::equals( Field *field ) { bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); if ( !sameId ) return false; if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; return mImpl->key() == field->mImpl->key(); } 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; } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e6bdde9..2c2f1a0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1687,604 +1687,654 @@ void KABCore::initGUI() //connect(syncManager , SIGNAL( ), this, SLOT( ) ); #endif //KAB_EMBEDDED initActions(); #ifdef KAB_EMBEDDED addActionsManually(); //US make sure the export and import menues are initialized before creating the xxPortManager. mXXPortManager = new XXPortManager( this, this ); // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); // mActionQuit->plug ( mMainWindow->toolBar()); //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); // mIncSearchWidget->hide(); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); mJumpButtonBar = new JumpButtonBar( this, this ); topLayout->addWidget( mJumpButtonBar ); //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); // mMainWindow->getIconToolBar()->raise(); #endif //KAB_EMBEDDED } void KABCore::initActions() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #ifndef KAB_EMBEDDED connect( QApplication::clipboard(), SIGNAL( dataChanged() ), SLOT( clipboardDataChanged() ) ); #endif //KAB_EMBEDDED // file menu if ( mIsPart ) { mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, SLOT( sendMail() ), actionCollection(), "kaddressbook_mail" ); mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, SLOT( print() ), actionCollection(), "kaddressbook_print" ); } else { mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); } mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, SLOT( save() ), actionCollection(), "file_sync" ); mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, SLOT( newContact() ), actionCollection(), "file_new_contact" ); mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, this, SLOT( mailVCard() ), actionCollection(), "file_mail_vcard"); mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, SLOT( export2phone() ), actionCollection(), "kaddressbook_ex2phone" ); mActionBeamVCard = 0; mActionBeam = 0; #ifndef DESKTOP_VERSION if ( Ir::supported() ) { mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, SLOT( beamVCard() ), actionCollection(), "kaddressbook_beam_vcard" ); mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, SLOT( beamMySelf() ), actionCollection(), "kaddressbook_beam_myself" ); } #endif mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, this, SLOT( editContact2() ), actionCollection(), "file_properties" ); #ifdef KAB_EMBEDDED // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, mMainWindow, SLOT( exit() ), actionCollection(), "quit" ); #endif //KAB_EMBEDDED // edit menu if ( mIsPart ) { mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, SLOT( copyContacts() ), actionCollection(), "kaddressbook_copy" ); mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, SLOT( cutContacts() ), actionCollection(), "kaddressbook_cut" ); mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, SLOT( pasteContacts() ), actionCollection(), "kaddressbook_paste" ); mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, SLOT( selectAllContacts() ), actionCollection(), "kaddressbook_select_all" ); mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, SLOT( undo() ), actionCollection(), "kaddressbook_undo" ); mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, this, SLOT( redo() ), actionCollection(), "kaddressbook_redo" ); } else { mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); } mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", Key_Delete, this, SLOT( deleteContacts() ), actionCollection(), "edit_delete" ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); // settings menu #ifdef KAB_EMBEDDED //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, SLOT( configureResources() ), actionCollection(), "kaddressbook_configure_resources" ); #endif //KAB_EMBEDDED if ( mIsPart ) { mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, SLOT( openConfigDialog() ), actionCollection(), "kaddressbook_configure" ); //US not implemented yet //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, // this, SLOT( configureKeyBindings() ), actionCollection(), // "kaddressbook_configure_shortcuts" ); #ifdef KAB_EMBEDDED mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); mActionConfigureToolbars->setEnabled( false ); #endif //KAB_EMBEDDED } else { mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); //US not implemented yet //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); } mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, actionCollection(), "options_show_jump_bar" ); connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, actionCollection(), "options_show_details" ); connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, SLOT( toggleBeamReceive() ), actionCollection(), "kaddressbook_beam_rec" ); // misc // only enable LDAP lookup if we can handle the protocol #ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, this, SLOT( openLDAPDialog() ), actionCollection(), "ldap_lookup" ); } #else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); #endif //KAB_EMBEDDED mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, SLOT( setWhoAmI() ), actionCollection(), "set_personal" ); - - mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, SLOT( setCategories() ), actionCollection(), "edit_set_categories" ); mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, SLOT( removeVoice() ), actionCollection(), "remove_voice" ); + + mActionSetCat= new KAction( i18n( "Set categories..." ), 0, this, + SLOT( setCat() ), actionCollection(), + "remove_voice" ); + + + mActionAddCat= new KAction( i18n( "Add categories..." ), 0, this, + SLOT( addCat() ), actionCollection(), + "remove_voice" ); + mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, SLOT( importFromOL() ), actionCollection(), "import_OL" ); #ifdef KAB_EMBEDDED mActionLicence = new KAction( i18n( "Licence" ), 0, this, SLOT( showLicence() ), actionCollection(), "licence_about_data" ); mActionFaq = new KAction( i18n( "Faq" ), 0, this, SLOT( faq() ), actionCollection(), "faq_about_data" ); mActionWN = new KAction( i18n( "What's New?" ), 0, this, SLOT( whatsnew() ), actionCollection(), "wn" ); mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, this, SLOT( synchowto() ), actionCollection(), "sync" ); mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, this, SLOT( kdesynchowto() ), actionCollection(), "kdesync" ); mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, this, SLOT( multisynchowto() ), actionCollection(), "multisync" ); mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, this, SLOT( createAboutData() ), actionCollection(), "kaddressbook_about_data" ); #endif //KAB_EMBEDDED clipboardDataChanged(); connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); } //US we need this function, to plug all actions into the correct menues. // KDE uses a XML format to plug the actions, but we work her without this overhead. void KABCore::addActionsManually() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #ifdef KAB_EMBEDDED QPopupMenu *fileMenu = new QPopupMenu( this ); QPopupMenu *editMenu = new QPopupMenu( this ); QPopupMenu *helpMenu = new QPopupMenu( this ); KToolBar* tb = mMainWindow->toolBar(); #ifndef DESKTOP_VERSION if ( KABPrefs::instance()->mFullMenuBarVisible ) { #endif QMenuBar* mb = mMainWindow->menuBar(); //US setup menubar. //Disable the following block if you do not want to have a menubar. mb->insertItem( "&File", fileMenu ); mb->insertItem( "&Edit", editMenu ); mb->insertItem( "&View", viewMenu ); mb->insertItem( "&Settings", settingsMenu ); mb->insertItem( i18n("Synchronize"), syncMenu ); mb->insertItem( "&Change selected", changeMenu ); mb->insertItem( "&Help", helpMenu ); mIncSearchWidget = new IncSearchWidget( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget); #ifndef DESKTOP_VERSION } else { //US setup toolbar QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); QPopupMenu *popupBarTB = new QPopupMenu( this ); menuBarTB->insertItem( "ME", popupBarTB); tb->insertWidget(-1, 0, menuBarTB); mIncSearchWidget = new IncSearchWidget( tb ); tb->enableMoving(false); popupBarTB->insertItem( "&File", fileMenu ); popupBarTB->insertItem( "&Edit", editMenu ); popupBarTB->insertItem( "&View", viewMenu ); popupBarTB->insertItem( "&Settings", settingsMenu ); popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); mViewManager->getFilterAction()->plug ( popupBarTB); popupBarTB->insertItem( "&Change selected", changeMenu ); popupBarTB->insertItem( "&Help", helpMenu ); if (QApplication::desktop()->width() > 320 ) { // mViewManager->getFilterAction()->plug ( tb); } } #endif // mActionQuit->plug ( mMainWindow->toolBar()); //US Now connect the actions with the menue entries. mActionPrint->plug( fileMenu ); mActionMail->plug( fileMenu ); fileMenu->insertSeparator(); mActionNewContact->plug( fileMenu ); mActionNewContact->plug( tb ); mActionEditAddressee->plug( fileMenu ); // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || // (!KABPrefs::instance()->mMultipleViewsAtOnce )) mActionEditAddressee->plug( tb ); fileMenu->insertSeparator(); mActionSave->plug( fileMenu ); fileMenu->insertItem( "&Import", ImportMenu ); fileMenu->insertItem( "&Export", ExportMenu ); fileMenu->insertSeparator(); mActionMailVCard->plug( fileMenu ); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); if ( Ir::supported() ) mActionBeam->plug(fileMenu ); #endif fileMenu->insertSeparator(); mActionQuit->plug( fileMenu ); #ifdef _WIN32_ mActionImportOL->plug( ImportMenu ); #endif // edit menu mActionUndo->plug( editMenu ); mActionRedo->plug( editMenu ); editMenu->insertSeparator(); mActionCut->plug( editMenu ); mActionCopy->plug( editMenu ); mActionPaste->plug( editMenu ); mActionDelete->plug( editMenu ); editMenu->insertSeparator(); mActionSelectAll->plug( editMenu ); mActionRemoveVoice->plug( changeMenu ); + mActionSetCat->plug( changeMenu ); + mActionAddCat->plug( changeMenu ); // settings menu //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! mActionConfigResources->plug( settingsMenu ); settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu ); if ( mIsPart ) { //US not implemented yet //mActionConfigShortcuts->plug( settingsMenu ); //mActionConfigureToolbars->plug( settingsMenu ); } else { //US not implemented yet //mActionKeyBindings->plug( settingsMenu ); } settingsMenu->insertSeparator(); mActionJumpBar->plug( settingsMenu ); mActionDetails->plug( settingsMenu ); //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); mActionBR->plug(settingsMenu ); settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); mActionWN->plug( helpMenu ); mActionSyncHowto->plug( helpMenu ); mActionKdeSyncHowto->plug( helpMenu ); mActionMultiSyncHowto->plug( helpMenu ); mActionFaq->plug( helpMenu ); mActionLicence->plug( helpMenu ); mActionAboutKAddressbook->plug( helpMenu ); if (KGlobal::getDesktopSize() > KGlobal::Small ) { mActionSave->plug( tb ); mViewManager->getFilterAction()->plug ( tb); if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { mActionUndo->plug( tb ); mActionDelete->plug( tb ); mActionRedo->plug( tb ); } } else { mActionSave->plug( tb ); tb->enableMoving(false); } //mActionQuit->plug ( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget, 6); //US link the searchwidget first to this. // The real linkage to the toolbar happens later. //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); //US tb->insertItem( mIncSearchWidget ); /*US mIncSearchWidget = new IncSearchWidget( tb ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); mJumpButtonBar = new JumpButtonBar( this, this ); //US topLayout->addWidget( mJumpButtonBar ); this->layout()->add( mJumpButtonBar ); */ #endif //KAB_EMBEDDED mActionExport2phone->plug( ExportMenu ); connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); syncManager->fillSyncMenu(); } void KABCore::showLicence() { KApplication::showLicence(); } +void KABCore::setCat() +{ + setCategories( true ); +} +void KABCore::addCat() +{ + setCategories( false ); +} +void KABCore::setCategories( bool removeOld ) +{ + KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KABPrefs::instance(), 0 ); + if (! csd->exec()) { + message( i18n("Setting categories cancelled") ); + delete csd; + return; + } + message( i18n("Setting categories ... please wait!") ); + QStringList catList = csd->selectedCategories(); + delete csd; + catList.sort(); + QStringList newList; + KABC::Addressee::List list = mViewManager->selectedAddressees(); + KABC::Addressee::List::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( removeOld ) { + (*it).setCategories( catList ); + } else { + newList = (*it).categories(); + int i; + for( i = 0; i< catList.count(); ++i ) { + if ( !newList.contains (catList[i])) + newList.append( catList[i] ); + } + newList.sort(); + (*it).setCategories( newList ); + } + contactModified((*it) ); + } + message( i18n("Setting categories completed!") ); +} void KABCore::removeVoice() { if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) return; KABC::Addressee::List list = mViewManager->selectedAddressees(); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( (*it).removeVoice() ) contactModified((*it) ); } } void KABCore::clipboardDataChanged() { if ( mReadWrite ) mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); } void KABCore::updateActionMenu() { UndoStack *undo = UndoStack::instance(); RedoStack *redo = RedoStack::instance(); if ( undo->isEmpty() ) mActionUndo->setText( i18n( "Undo" ) ); else mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); mActionUndo->setEnabled( !undo->isEmpty() ); if ( !redo->top() ) mActionRedo->setText( i18n( "Redo" ) ); else mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); mActionRedo->setEnabled( !redo->isEmpty() ); } void KABCore::configureKeyBindings() { #ifndef KAB_EMBEDDED KKeyDialog::configure( actionCollection(), true ); #else //KAB_EMBEDDED qDebug("KABCore::configureKeyBindings() not implemented"); #endif //KAB_EMBEDDED } #ifdef KAB_EMBEDDED void KABCore::configureResources() { KRES::KCMKResources dlg( this, "" , 0 ); if ( !dlg.exec() ) return; KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); } #endif //KAB_EMBEDDED /* this method will be called through the QCop interface from Ko/Pi to select addresses * for the attendees list of an event. */ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) { QStringList nameList; QStringList emailList; QStringList uidList; KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { nameList.append(list[i].realName()); emailList.append(list[i].preferredEmail()); uidList.append(list[i].uid()); } bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); } /* this method will be called through the QCop interface from Ko/Pi to select birthdays * to put them into the calendar. */ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) { // qDebug("KABCore::requestForBirthdayList"); QStringList birthdayList; QStringList anniversaryList; QStringList realNameList; QStringList preferredEmailList; QStringList assembledNameList; QStringList uidList; KABC::AddressBook::Iterator it; int count = 0; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); bar.setCaption (i18n("Collecting birthdays - close to abort!") ); qApp->processEvents(); QDate bday; QString anni; QString formattedbday; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( ! bar.isVisible() ) return; bar.setProgress( count++ ); qApp->processEvents(); bday = (*it).birthday().date(); anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); if ( bday.isValid() || !anni.isEmpty()) { if (bday.isValid()) formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); else formattedbday = "NOTVALID"; if (anni.isEmpty()) anni = "INVALID"; birthdayList.append(formattedbday); anniversaryList.append(anni); //should be ISODate realNameList.append((*it).realName()); preferredEmailList.append((*it).preferredEmail()); assembledNameList.append((*it).assembledName()); uidList.append((*it).uid()); //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); } } bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); } /* this method will be called through the QCop interface from other apps to show details of a contact. */ void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) { //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); QString foundUid = QString::null; if ( ! uid.isEmpty() ) { Addressee adrr = mAddressBook->findByUid( uid ); if ( !adrr.isEmpty() ) { foundUid = uid; } if ( email == "sendbacklist" ) { //qDebug("ssssssssssssssssssssssend "); QStringList nameList; QStringList emailList; QStringList uidList; nameList.append(adrr.realName()); emailList = adrr.emails(); uidList.append( adrr.preferredEmail()); bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); return; } } if ( email == "sendbacklist" ) return; if (foundUid.isEmpty()) { //find the uid of the person first Addressee::List namelist; Addressee::List emaillist; if (!name.isEmpty()) namelist = mAddressBook->findByName( name ); if (!email.isEmpty()) diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c01d598..1bdae5f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -181,328 +181,333 @@ class KABCore : public QWidget, public KSyncInterface Beams the "WhoAmI contact. */ void beamMySelf(); void beamVCard(); void export2phone(); void beamVCard(const QStringList& uids); void beamDone( Ir *ir ); /** Starts the preferred web browser with the given URL as argument. */ void browse( const QString& url ); /** Select all contacts in the view. */ void selectAllContacts(); /** Deletes all selected contacts from the address book. */ void deleteContacts(); /** Deletes given contacts from the address book. @param uids The uids of the contacts, which shall be deleted. */ void deleteContacts( const QStringList &uids ); /** Copys the selected contacts into clipboard for later pasting. */ void copyContacts(); /** Cuts the selected contacts and stores them for later pasting. */ void cutContacts(); /** Paste contacts from clipboard into the address book. */ void pasteContacts(); /** Paste given contacts into the address book. @param list The list of addressee, which shall be pasted. */ void pasteContacts( KABC::Addressee::List &list ); /** Sets the whoAmI contact, that is used by many other programs to get personal information about the current user. */ void setWhoAmI(); /** Displays the category dialog and applies the result to all selected contacts. */ void setCategories(); /** Sets the field list of the Incremental Search Widget. */ void setSearchFields( const KABC::Field::List &fields ); /** Search with the current search field for a contact, that matches the given text, and selects it in the view. */ void incrementalSearch( const QString& text ); /** Marks the address book as modified. */ void setModified(); /** Marks the address book as modified without refreshing the view. */ void setModifiedWOrefresh(); /** Marks the address book as modified concerning the argument. */ void setModified( bool modified ); /** Returns whether the address book is modified. */ bool modified() const; /** Called whenever an contact is modified in the contact editor dialog or the quick edit. */ void contactModified( const KABC::Addressee &addr ); /** DCOP METHODS. */ void addEmail( QString addr ); void importVCard( const KURL& url, bool showPreview ); void importVCard( const QString& vCard, bool showPreview ); void newContact(); QString getNameByPhone( const QString& phone ); /** END DCOP METHODS */ /** Saves the contents of the AddressBook back to disk. */ void save(); /** Undos the last command using the undo stack. */ void undo(); /** Redos the last command that was undone, using the redo stack. */ void redo(); /** Shows the edit dialog for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ void editContact( const QString &uid /*US = QString::null*/ ); //US added a second method without defaultparameter void editContact2(); /** Shows or edits the detail view for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ void executeContact( const QString &uid /*US = QString::null*/ ); /** Launches the configuration dialog. */ void openConfigDialog(); /** Launches the ldap search dialog. */ void openLDAPDialog(); /** Creates a KAddressBookPrinter, which will display the print dialog and do the printing. */ void print(); /** Registers a new GUI client, so plugins can register its actions. */ void addGUIClient( KXMLGUIClient *client ); void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); signals: void contactSelected( const QString &name ); void contactSelected( const QPixmap &pixmap ); public slots: void recieve(QString cmsg ); void getFile( bool success ); void syncFileRequest(); void setDetailsVisible( bool visible ); void setDetailsToState(); // void slotSyncMenu( int ); private slots: void receive( const QCString& cmsg, const QByteArray& data ); void toggleBeamReceive( ); void disableBR(bool); void setJumpButtonBarVisible( bool visible ); void setCaptionBack(); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); void removeVoice(); + void setCat(); + void addCat(); + void setCategories( bool removeOld ); #ifdef KAB_EMBEDDED void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); private: bool mBRdisabled; #ifndef DESKTOP_VERSION QCopChannel* infrared; #endif QTimer *mMessageTimer; void initGUI(); void initActions(); QString getPhoneFile(); AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, const char *name = 0 ); KXMLGUIClient *mGUIClient; KABC::AddressBook *mAddressBook; ViewManager *mViewManager; // QSplitter *mDetailsSplitter; KDGanttMinimizeSplitter *mExtensionBarSplitter; ViewContainer *mDetails; KDGanttMinimizeSplitter* mMiniSplitter; XXPortManager *mXXPortManager; JumpButtonBar *mJumpButtonBar; IncSearchWidget *mIncSearchWidget; ExtensionManager *mExtensionManager; KCMultiDialog *mConfigureDialog; #ifndef KAB_EMBEDDED LDAPSearchDialog *mLdapSearchDialog; #endif //KAB_EMBEDDED // QDict<AddresseeEditorDialog> mEditorDict; AddresseeEditorDialog *mEditorDialog; bool mReadWrite; bool mModified; bool mIsPart; bool mMultipleViewsAtOnce; //US file menu KAction *mActionMail; KAction *mActionBeam; KToggleAction *mActionBR; KAction *mActionExport2phone; KAction* mActionPrint; KAction* mActionNewContact; KAction *mActionSave; KAction *mActionEditAddressee; KAction *mActionMailVCard; KAction *mActionBeamVCard; KAction *mActionQuit; //US edit menu KAction *mActionCopy; KAction *mActionCut; KAction *mActionPaste; KAction *mActionSelectAll; KAction *mActionUndo; KAction *mActionRedo; KAction *mActionDelete; //US settings menu KAction *mActionConfigResources; KAction *mActionConfigKAddressbook; KAction *mActionConfigShortcuts; KAction *mActionConfigureToolbars; KAction *mActionKeyBindings; KToggleAction *mActionJumpBar; KToggleAction *mActionDetails; KAction *mActionWhoAmI; KAction *mActionCategories; KAction *mActionAboutKAddressbook; KAction *mActionLicence; KAction *mActionFaq; KAction *mActionWN; KAction *mActionSyncHowto; KAction *mActionKdeSyncHowto; KAction *mActionMultiSyncHowto; KAction *mActionDeleteView; QPopupMenu *viewMenu; QPopupMenu *filterMenu; QPopupMenu *settingsMenu; QPopupMenu *changeMenu; //US QAction *mActionSave; QPopupMenu *ImportMenu; QPopupMenu *ExportMenu; //LR additional methods KAction *mActionRemoveVoice; + KAction *mActionSetCat; + KAction *mActionAddCat; KAction * mActionImportOL; #ifndef KAB_EMBEDDED KAddressBookService *mAddressBookService; #endif //KAB_EMBEDDED class KABCorePrivate; KABCorePrivate *d; //US bool mBlockSaveFlag; #ifdef KAB_EMBEDDED KAddressBookMain *mMainWindow; // should be the same like mGUIClient #endif //KAB_EMBEDDED //this are the overwritten callbackmethods from the syncinterface virtual bool sync(KSyncManager* manager, QString filename, int mode); virtual bool syncExternal(KSyncManager* manager, QString resource); virtual void removeSyncInfo( QString syncProfile); bool syncPhone(); void message( QString m ); // LR ******************************* // sync stuff! QString sentSyncFile(); QPopupMenu *syncMenu; KSyncManager* syncManager; int mGlobalSyncMode; bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); KABC::Addressee getLastSyncAddressee(); QDateTime mLastAddressbookSync; int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); // ********************* }; #endif |