summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/resourcedir.cpp17
-rw-r--r--kabc/plugins/dir/resourcedir.h3
-rw-r--r--kabc/plugins/file/resourcefile.cpp20
-rw-r--r--kabc/plugins/file/resourcefile.h3
-rw-r--r--microkde/kresources/configpage.cpp14
5 files changed, 35 insertions, 22 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$
55 55
56//US 56//US
57#include <qdir.h> 57#include <qdir.h>
58 58
59#define NO_DIRWATCH
59#include "resourcedir.h" 60#include "resourcedir.h"
60#include "syncprefwidget.h" 61#include "syncprefwidget.h"
61 62
62//#define ALLOW_LOCKING 63//#define ALLOW_LOCKING
@@ -112,13 +113,13 @@ ResourceDir::ResourceDir( const KConfig *config, bool syncable )
112 mFormat = new BinaryFormat(); 113 mFormat = new BinaryFormat();
113 else 114 else
114 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); 115 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
115*/ 116*/
116 117#ifndef NO_DIRWATCH
117 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); 118 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
118 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); 119 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
119 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); 120 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
120 121#endif
121 setPath( path ); 122 setPath( path );
122} 123}
123 124
124ResourceDir::~ResourceDir() 125ResourceDir::~ResourceDir()
@@ -207,11 +208,11 @@ bool ResourceDir::load()
207bool ResourceDir::save( Ticket *ticket ) 208bool ResourceDir::save( Ticket *ticket )
208{ 209{
209 AddressBook::Iterator it; 210 AddressBook::Iterator it;
210 bool ok = true; 211 bool ok = true;
211 212#ifndef NO_DIRWATCH
212 mDirWatch.stopScan(); 213 mDirWatch.stopScan();
213 214#endif
214 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 215 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
215 if ( (*it).resource() != this || !(*it).changed() ) 216 if ( (*it).resource() != this || !(*it).changed() )
216 continue; 217 continue;
217 218
@@ -227,10 +228,11 @@ bool ResourceDir::save( Ticket *ticket )
227 (*it).setChanged( false ); 228 (*it).setChanged( false );
228 229
229 file.close(); 230 file.close();
230 } 231 }
232#ifndef NO_DIRWATCH
231 mDirWatch.startScan(); 233 mDirWatch.startScan();
232 234#endif
233 delete ticket; 235 delete ticket;
234#ifdef ALLOW_LOCKING 236#ifdef ALLOW_LOCKING
235 unlock( mPath ); 237 unlock( mPath );
236#endif 238#endif
@@ -300,16 +302,19 @@ void ResourceDir::unlock( const QString &path )
300} 302}
301 303
302void ResourceDir::setPath( const QString &path ) 304void ResourceDir::setPath( const QString &path )
303{ 305{
306#ifndef NO_DIRWATCH
304 mDirWatch.stopScan(); 307 mDirWatch.stopScan();
305 mDirWatch.removeDir( mPath ); 308 mDirWatch.removeDir( mPath );
306 309
307 mPath = path; 310 mPath = path;
308 311
309 mDirWatch.addDir( mPath, true ); 312 mDirWatch.addDir( mPath, true );
310 mDirWatch.startScan(); 313 mDirWatch.startScan();
311 314#else
315 mPath = path;
316#endif
312//US simulate KDirWatch event 317//US simulate KDirWatch event
313//US pathChanged(); 318//US pathChanged();
314 319
315} 320}
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:
103 103
104private: 104private:
105 FormatPlugin *mFormat; 105 FormatPlugin *mFormat;
106 106
107#ifndef NO_DIRWATCH
107 KDirWatch mDirWatch; 108 KDirWatch mDirWatch;
108 109#endif
109 QString mPath; 110 QString mPath;
110 QString mFormatName; 111 QString mFormatName;
111 QString mLockUniqueName; 112 QString mLockUniqueName;
112}; 113};
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$
48 48
49#include "resource.h" 49#include "resource.h"
50#include "resourcefileconfig.h" 50#include "resourcefileconfig.h"
51#include "stdaddressbook.h" 51#include "stdaddressbook.h"
52 52#define NO_DIRWATCH
53#include "resourcefile.h" 53#include "resourcefile.h"
54#include "syncprefwidget.h" 54#include "syncprefwidget.h"
55 55
56//#define ALLOW_LOCKING 56//#define ALLOW_LOCKING
57 57
58
59
58using namespace KABC; 60using namespace KABC;
59 61
60extern "C" 62extern "C"
61#ifdef _WIN32_ 63#ifdef _WIN32_
@@ -114,13 +116,13 @@ void ResourceFile::init( const QString &fileName, const QString &formatName )
114 mFormatName = "vcard"; 116 mFormatName = "vcard";
115 mFormat = factory->format( mFormatName ); 117 mFormat = factory->format( mFormatName );
116 } 118 }
117 119
118 120#ifndef NO_DIRWATCH
119 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 121 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
120 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 122 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
121 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 123 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
122 124#endif
123 setFileName( fileName ); 125 setFileName( fileName );
124} 126}
125 127
126ResourceFile::~ResourceFile() 128ResourceFile::~ResourceFile()
@@ -226,10 +228,11 @@ bool ResourceFile::save( Ticket *ticket )
226 } 228 }
227*/ 229*/
228 230
229//US ToDo: write backupfile 231//US ToDo: write backupfile
232#ifndef NO_DIRWATCH
230 mDirWatch.stopScan(); 233 mDirWatch.stopScan();
231 234#endif
232 QFile info; 235 QFile info;
233 info.setName( mFileName ); 236 info.setName( mFileName );
234 bool ok = info.open( IO_WriteOnly ); 237 bool ok = info.open( IO_WriteOnly );
235 if ( ok ) { 238 if ( ok ) {
@@ -243,11 +246,11 @@ bool ResourceFile::save( Ticket *ticket )
243 } 246 }
244 247
245 if ( !ok ) 248 if ( !ok )
246 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 249 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
247 250#ifndef NO_DIRWATCH
248 mDirWatch.startScan(); 251 mDirWatch.startScan();
249 252#endif
250 delete ticket; 253 delete ticket;
251#ifdef ALLOW_LOCKING 254#ifdef ALLOW_LOCKING
252 unlock( mFileName ); 255 unlock( mFileName );
253#endif 256#endif
@@ -325,16 +328,19 @@ void ResourceFile::unlock( const QString &fileName )
325} 328}
326 329
327void ResourceFile::setFileName( const QString &fileName ) 330void ResourceFile::setFileName( const QString &fileName )
328{ 331{
332#ifndef NO_DIRWATCH
329 mDirWatch.stopScan(); 333 mDirWatch.stopScan();
330 mDirWatch.removeFile( mFileName ); 334 mDirWatch.removeFile( mFileName );
331
332 mFileName = fileName; 335 mFileName = fileName;
333 336
334 337
335 mDirWatch.addFile( mFileName ); 338 mDirWatch.addFile( mFileName );
336 mDirWatch.startScan(); 339 mDirWatch.startScan();
340#else
341 mFileName = fileName;
342#endif
337 343
338//US simulate KDirWatch event 344//US simulate KDirWatch event
339//US fileChanged(); 345//US fileChanged();
340} 346}
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:
152 152
153 FormatPlugin *mFormat; 153 FormatPlugin *mFormat;
154 154
155 QString mLockUniqueName; 155 QString mLockUniqueName;
156 156#ifndef NO_DIRWATCH
157 KDirWatch mDirWatch; 157 KDirWatch mDirWatch;
158#endif
158}; 159};
159 160
160} 161}
161 162
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 1a3a22c..02c5fb1 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -99,10 +99,10 @@ ConfigPage::ConfigPage( QWidget *parent, const char *name )
99 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 99 QVBoxLayout *mainLayout = new QVBoxLayout( this );
100 100
101 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); 101 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this );
102 groupBox->setColumnLayout(0, Qt::Vertical ); 102 groupBox->setColumnLayout(0, Qt::Vertical );
103 groupBox->layout()->setSpacing( 6 ); 103 groupBox->layout()->setSpacing( 3 );
104 groupBox->layout()->setMargin( 11 ); 104 groupBox->layout()->setMargin( 5 );
105 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 ); 105 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 );
106 106
107//US mFamilyCombo = new KComboBox( false, groupBox ); 107//US mFamilyCombo = new KComboBox( false, groupBox );
108 mFamilyCombo = new KComboBox( groupBox ); 108 mFamilyCombo = new KComboBox( groupBox );
@@ -111,21 +111,21 @@ ConfigPage::ConfigPage( QWidget *parent, const char *name )
111 mListView = new KListView( groupBox ); 111 mListView = new KListView( groupBox );
112 mListView->setAllColumnsShowFocus( true ); 112 mListView->setAllColumnsShowFocus( true );
113 mListView->addColumn( i18n( "Name" ) ); 113 mListView->addColumn( i18n( "Name" ) );
114 mListView->addColumn( i18n( "Type" ) ); 114 mListView->addColumn( i18n( "Type" ) );
115 mListView->addColumn( i18n( "Standard" ) ); 115 mListView->addColumn( i18n( "Standard" ) );
116 116
117//US groupBoxLayout->addWidget( mListView, 1, 0 ); 117//US groupBoxLayout->addWidget( mListView, 1, 0 );
118 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); 118 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 );
119 119
120 120
121 mAddButton = new QPushButton( i18n( "&Add..." ), this ); 121 mAddButton = new QPushButton( i18n( "&Add..." ), groupBox );
122 groupBoxLayout->addWidget( mAddButton, 2, 0 ); 122 groupBoxLayout->addWidget( mAddButton, 2, 0 );
123 mRemoveButton = new QPushButton( i18n( "&Remove" ), this ); 123 mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox );
124 groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); 124 groupBoxLayout->addWidget( mRemoveButton, 2, 1 );
125 mEditButton = new QPushButton( i18n( "&Edit..." ), this ); 125 mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox );
126 groupBoxLayout->addWidget( mEditButton, 3, 0 ); 126 groupBoxLayout->addWidget( mEditButton, 3, 0 );
127 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), this ); 127 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox );
128 groupBoxLayout->addWidget( mStandardButton, 3, 1 ); 128 groupBoxLayout->addWidget( mStandardButton, 3, 1 );
129 129
130 mRemoveButton->setEnabled( false ); 130 mRemoveButton->setEnabled( false );
131 mEditButton->setEnabled( false ); 131 mEditButton->setEnabled( false );