-rw-r--r-- | kabc/addressbook.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4c4ae09..8487ff3 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -1099,128 +1099,139 @@ Field::List AddressBook::fields( int category ) { if ( d->mAllFields.isEmpty() ) { d->mAllFields = Field::allFields(); } if ( category == Field::All ) return d->mAllFields; Field::List result; Field::List::ConstIterator it; for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { if ( (*it)->category() & category ) result.append( *it ); } return result; } bool AddressBook::addCustomField( const QString &label, int category, const QString &key, const QString &app ) { if ( d->mAllFields.isEmpty() ) { d->mAllFields = Field::allFields(); } //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; QString a = app.isNull() ? KGlobal::getAppName() : app; QString k = key.isNull() ? label : key; Field *field = Field::createCustomField( label, category, k, a ); if ( !field ) return false; d->mAllFields.append( field ); return true; } QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) { if (!ab.d) return s; return s << ab.d->mAddressees; } QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) { if (!ab.d) return s; s >> ab.d->mAddressees; return s; } bool AddressBook::addResource( Resource *resource ) { if ( !resource->open() ) { kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; return false; } resource->setAddressBook( this ); d->mManager->add( resource ); return true; } +void AddressBook::removeResources() +{ + //remove all possible resources. This should cleanup the configfile. + QPtrList<KABC::Resource> mResources = resources(); + + QPtrListIterator<KABC::Resource> it(mResources); + for ( ; it.current(); ++it ) { + KABC::Resource *res = it.current(); + removeResource(res); + } +} bool AddressBook::removeResource( Resource *resource ) { resource->close(); if ( resource == standardResource() ) d->mManager->setStandardResource( 0 ); resource->setAddressBook( 0 ); d->mManager->remove( resource ); return true; } QPtrList<Resource> AddressBook::resources() { QPtrList<Resource> list; // qDebug("AddressBook::resources() 1"); KRES::Manager<Resource>::ActiveIterator it; for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) list.append( *it ); return list; } /*US void AddressBook::setErrorHandler( ErrorHandler *handler ) { delete d->mErrorHandler; d->mErrorHandler = handler; } */ void AddressBook::error( const QString& msg ) { /*US if ( !d->mErrorHandler ) // create default error handler d->mErrorHandler = new ConsoleErrorHandler; if ( d->mErrorHandler ) d->mErrorHandler->error( msg ); else kdError(5700) << "no error handler defined" << endl; */ kdDebug(5700) << "msg" << endl; qDebug(msg); } void AddressBook::deleteRemovedAddressees() { Addressee::List::Iterator it; for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { Resource *resource = (*it).resource(); if ( resource && !resource->readOnly() && resource->isOpen() ) resource->removeAddressee( *it ); } d->mRemovedAddressees.clear(); } void AddressBook::setStandardResource( Resource *resource ) { |