summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/dir/resourcedir.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/dir/resourcedir.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/dir/resourcedir.cpp17
1 files changed, 11 insertions, 6 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
@@ -51,16 +51,17 @@ $Id$
#include "formatfactory.h"
#include "resourcedirconfig.h"
#include "stdaddressbook.h"
//US
#include <qdir.h>
+#define NO_DIRWATCH
#include "resourcedir.h"
#include "syncprefwidget.h"
//#define ALLOW_LOCKING
using namespace KABC;
extern "C"
@@ -108,21 +109,21 @@ ResourceDir::ResourceDir( const KConfig *config, bool syncable )
//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
if (mFormatName == "vcard")
mFormat = new VCardFormatPlugin2();
else if (mFormatName == "binary")
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()
{
delete mFormat;
mFormat = 0;
}
@@ -203,19 +204,19 @@ bool ResourceDir::load()
return ok;
}
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;
QFile file( mPath + "/" + (*it).uid() );
if ( !file.open( IO_WriteOnly ) ) {
addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) );
continue;
@@ -223,18 +224,19 @@ bool ResourceDir::save( Ticket *ticket )
mFormat->save( *it, &file );
// mark as unchanged
(*it).setChanged( false );
file.close();
}
+#ifndef NO_DIRWATCH
mDirWatch.startScan();
-
+#endif
delete ticket;
#ifdef ALLOW_LOCKING
unlock( mPath );
#endif
return ok;
}
bool ResourceDir::lock( const QString &path )
@@ -296,24 +298,27 @@ void ResourceDir::unlock( const QString &path )
addressBook()->emitAddressBookUnlocked();
#else
return;
#endif
}
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();
}
QString ResourceDir::path() const
{
return mPath;