summaryrefslogtreecommitdiffabout
path: root/kabc/stdaddressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/stdaddressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index f17f366..a14ae20 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -68,104 +68,105 @@ StdAddressBook *StdAddressBook::self()
mSelf = addressBookDeleter.setObject( new StdAddressBook );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
QString StdAddressBook::setTempAppDir()
{
QString appDIR = KStandardDirs::appDir();
#ifdef DESKTOP_VERSION
QString appdir = QDir::homeDirPath();
if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
appdir += "kaddressbook/";
else
appdir += "/kaddressbook/";
KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
#else
QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
KStandardDirs::setAppDir( appdir );
#endif
return appDIR;
}
StdAddressBook *StdAddressBook::self( bool onlyFastResources )
{
if ( !mSelf )
{
QString appdir =StdAddressBook::setTempAppDir();
#ifdef KAB_EMBEDDED
mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
StdAddressBook::StdAddressBook()
: AddressBook( "kabcrc" )
{
- init( false );
+ //init( false );
}
StdAddressBook::StdAddressBook( bool onlyFastResources )
: AddressBook( "kabcrc" )
{
- init( onlyFastResources );
+ if ( onlyFastResources )
+ init( onlyFastResources );
}
StdAddressBook::~StdAddressBook()
{
if ( mAutomaticSave )
save();
}
void StdAddressBook::init( bool )
{
KRES::Manager<Resource> *manager = resourceManager();
KRES::Manager<Resource>::ActiveIterator it;
for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
(*it)->setAddressBook( this );
if ( !(*it)->open() )
error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
}
Resource *res = standardResource();
if ( !res ) {
res = manager->createResource( "file" );
if ( res )
{
addResource( res );
}
else
qDebug(" No resource available!!!");
}
setStandardResource( res );
manager->writeConfig();
load();
}
bool StdAddressBook::save()
{
kdDebug(5700) << "StdAddressBook::save()" << endl;
bool ok = true;
AddressBook *ab = self();
ab->deleteRemovedAddressees();
Iterator ait;
for ( ait = ab->begin(); ait != ab->end(); ++ait ) {
if ( !(*ait).IDStr().isEmpty() ) {
(*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );