-rw-r--r-- | kabc/addressbook.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 0838157..20310a0 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -215,17 +215,24 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) AddressBook::AddressBook() { - init(0); + init(0, "contact"); } AddressBook::AddressBook( const QString &config ) { - init(config); + init(config, "contact"); } -void AddressBook::init(const QString &config) +AddressBook::AddressBook( const QString &config, const QString &family ) +{ + init(config, family); + +} + +// the default family is "contact" +void AddressBook::init(const QString &config, const QString &family ) { d = new AddressBookData; if (config != 0) { d->mConfig = new KConfig( config ); @@ -234,11 +241,11 @@ void AddressBook::init(const QString &config) else { d->mConfig = 0; // qDebug("AddressBook::init 1 config=0"); } - + //US d->mErrorHandler = 0; - d->mManager = new KRES::Manager<Resource>( "contact" ); + d->mManager = new KRES::Manager<Resource>( family, false ); d->mManager->readConfig( d->mConfig ); } AddressBook::~AddressBook() @@ -250,9 +257,9 @@ AddressBook::~AddressBook() } bool AddressBook::load() { - + clear(); KRES::Manager<Resource>::ActiveIterator it; @@ -276,9 +283,9 @@ bool AddressBook::save( Ticket *ticket ) kdDebug(5700) << "AddressBook::save()"<< endl; if ( ticket->resource() ) { deleteRemovedAddressees(); - + return ticket->resource()->save( ticket ); } return false; @@ -355,9 +362,9 @@ void AddressBook::insertAddressee( const Addressee &a ) (*it).setResource( standardResource() ); if ( changed ) { (*it).setRevision( QDateTime::currentDateTime() ); - (*it).setChanged( true ); + (*it).setChanged( true ); } return; } @@ -434,9 +441,9 @@ Addressee::List AddressBook::findByEmail( const QString &email ) QStringList mailList; Iterator it; for ( it = begin(); it != end(); ++it ) { - mailList = (*it).emails(); + mailList = (*it).emails(); for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { if ( email == (*ite) ) { results.append( *it ); } @@ -490,17 +497,17 @@ 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, @@ -540,10 +547,8 @@ QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) } bool AddressBook::addResource( Resource *resource ) { - qDebug("AddressBook::addResource 1"); - if ( !resource->open() ) { kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; return false; } @@ -571,9 +576,9 @@ 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 ); |