-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 17 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.h | 3 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 20 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.h | 3 |
4 files changed, 28 insertions, 15 deletions
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index 7d96cb7..e58e4f7 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp @@ -55,8 +55,9 @@ $Id$ //US #include <qdir.h> +#define NO_DIRWATCH #include "resourcedir.h" #include "syncprefwidget.h" //#define ALLOW_LOCKING @@ -112,13 +113,13 @@ ResourceDir::ResourceDir( const KConfig *config, bool syncable ) mFormat = new BinaryFormat(); else qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); */ - +#ifndef NO_DIRWATCH connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); - +#endif setPath( path ); } ResourceDir::~ResourceDir() @@ -207,11 +208,11 @@ bool ResourceDir::load() bool ResourceDir::save( Ticket *ticket ) { AddressBook::Iterator it; bool ok = true; - +#ifndef NO_DIRWATCH mDirWatch.stopScan(); - +#endif for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { if ( (*it).resource() != this || !(*it).changed() ) continue; @@ -227,10 +228,11 @@ bool ResourceDir::save( Ticket *ticket ) (*it).setChanged( false ); file.close(); } +#ifndef NO_DIRWATCH mDirWatch.startScan(); - +#endif delete ticket; #ifdef ALLOW_LOCKING unlock( mPath ); #endif @@ -300,16 +302,19 @@ void ResourceDir::unlock( const QString &path ) } void ResourceDir::setPath( const QString &path ) { +#ifndef NO_DIRWATCH mDirWatch.stopScan(); mDirWatch.removeDir( mPath ); mPath = path; mDirWatch.addDir( mPath, true ); mDirWatch.startScan(); - +#else + mPath = path; +#endif //US simulate KDirWatch event //US pathChanged(); } diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h index c2aedad..77cd18c 100644 --- a/kabc/plugins/dir/resourcedir.h +++ b/kabc/plugins/dir/resourcedir.h @@ -103,10 +103,11 @@ protected: private: FormatPlugin *mFormat; +#ifndef NO_DIRWATCH KDirWatch mDirWatch; - +#endif QString mPath; QString mFormatName; QString mLockUniqueName; }; diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 17263ae..b8c32d5 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -48,14 +48,16 @@ $Id$ #include "resource.h" #include "resourcefileconfig.h" #include "stdaddressbook.h" - +#define NO_DIRWATCH #include "resourcefile.h" #include "syncprefwidget.h" //#define ALLOW_LOCKING + + using namespace KABC; extern "C" #ifdef _WIN32_ @@ -114,13 +116,13 @@ void ResourceFile::init( const QString &fileName, const QString &formatName ) mFormatName = "vcard"; mFormat = factory->format( mFormatName ); } - +#ifndef NO_DIRWATCH connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); - +#endif setFileName( fileName ); } ResourceFile::~ResourceFile() @@ -226,10 +228,11 @@ bool ResourceFile::save( Ticket *ticket ) } */ //US ToDo: write backupfile +#ifndef NO_DIRWATCH mDirWatch.stopScan(); - +#endif QFile info; info.setName( mFileName ); bool ok = info.open( IO_WriteOnly ); if ( ok ) { @@ -243,11 +246,11 @@ bool ResourceFile::save( Ticket *ticket ) } if ( !ok ) addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); - +#ifndef NO_DIRWATCH mDirWatch.startScan(); - +#endif delete ticket; #ifdef ALLOW_LOCKING unlock( mFileName ); #endif @@ -325,16 +328,19 @@ void ResourceFile::unlock( const QString &fileName ) } void ResourceFile::setFileName( const QString &fileName ) { +#ifndef NO_DIRWATCH mDirWatch.stopScan(); mDirWatch.removeFile( mFileName ); - mFileName = fileName; mDirWatch.addFile( mFileName ); mDirWatch.startScan(); +#else + mFileName = fileName; +#endif //US simulate KDirWatch event //US fileChanged(); } diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h index 0a3027c..8339340 100644 --- a/kabc/plugins/file/resourcefile.h +++ b/kabc/plugins/file/resourcefile.h @@ -152,10 +152,11 @@ private: FormatPlugin *mFormat; QString mLockUniqueName; - +#ifndef NO_DIRWATCH KDirWatch mDirWatch; +#endif }; } |