summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp35
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
@@ -213,34 +213,41 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
return ( d->mIt != it.d->mIt );
}
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 );
// qDebug("AddressBook::init 1 config=%s",config.latin1() );
}
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()
{
delete d->mConfig; d->mConfig = 0;
@@ -248,13 +255,13 @@ AddressBook::~AddressBook()
//US delete d->mErrorHandler; d->mErrorHandler = 0;
delete d; d = 0;
}
bool AddressBook::load()
{
-
+
clear();
KRES::Manager<Resource>::ActiveIterator it;
bool ok = true;
for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
@@ -274,13 +281,13 @@ bool AddressBook::load()
bool AddressBook::save( Ticket *ticket )
{
kdDebug(5700) << "AddressBook::save()"<< endl;
if ( ticket->resource() ) {
deleteRemovedAddressees();
-
+
return ticket->resource()->save( ticket );
}
return false;
}
@@ -353,13 +360,13 @@ void AddressBook::insertAddressee( const Addressee &a )
(*it) = a;
if ( (*it).resource() == 0 )
(*it).setResource( standardResource() );
if ( changed ) {
(*it).setRevision( QDateTime::currentDateTime() );
- (*it).setChanged( true );
+ (*it).setChanged( true );
}
return;
}
}
d->mAddressees.append( a );
@@ -432,13 +439,13 @@ Addressee::List AddressBook::findByEmail( const QString &email )
{
Addressee::List results;
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 );
}
}
}
@@ -488,21 +495,21 @@ QString AddressBook::identifier()
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 )
{
@@ -538,14 +545,12 @@ QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
return s;
}
bool AddressBook::addResource( Resource *resource )
{
- qDebug("AddressBook::addResource 1");
-
if ( !resource->open() ) {
kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
return false;
}
resource->setAddressBook( this );
@@ -569,13 +574,13 @@ bool AddressBook::removeResource( Resource *resource )
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;
}