author | zautrix <zautrix> | 2004-09-15 10:22:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-15 10:22:55 (UTC) |
commit | d4adafe41cf399585b8e35cb600ff35706d55ae0 (patch) (unidiff) | |
tree | 1becc87f6c40390fd73082996d18f71fb5e9c772 | |
parent | 8889ffd6f6958c3a1d07bafedcc8af5d786a1660 (diff) | |
download | kdepimpi-d4adafe41cf399585b8e35cb600ff35706d55ae0.zip kdepimpi-d4adafe41cf399585b8e35cb600ff35706d55ae0.tar.gz kdepimpi-d4adafe41cf399585b8e35cb600ff35706d55ae0.tar.bz2 |
fixes for desktop version
-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 | ||||
-rw-r--r-- | microkde/kresources/configpage.cpp | 14 |
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 | |||
@@ -43,32 +43,33 @@ $Id$ | |||
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | #include <klocale.h> | 44 | #include <klocale.h> |
45 | #include <kstandarddirs.h> | 45 | #include <kstandarddirs.h> |
46 | #include <kurlrequester.h> | 46 | #include <kurlrequester.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | 48 | ||
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | 50 | ||
51 | #include "formatfactory.h" | 51 | #include "formatfactory.h" |
52 | 52 | ||
53 | #include "resourcedirconfig.h" | 53 | #include "resourcedirconfig.h" |
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
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 |
63 | 64 | ||
64 | using namespace KABC; | 65 | using namespace KABC; |
65 | 66 | ||
66 | extern "C" | 67 | extern "C" |
67 | #ifdef _WIN32_ | 68 | #ifdef _WIN32_ |
68 | __declspec(dllexport) | 69 | __declspec(dllexport) |
69 | #else | 70 | #else |
70 | { | 71 | { |
71 | #endif | 72 | #endif |
72 | 73 | ||
73 | //US void *init_kabc_dir() | 74 | //US void *init_kabc_dir() |
74 | void *init_microkabc_dir() | 75 | void *init_microkabc_dir() |
@@ -100,37 +101,37 @@ ResourceDir::ResourceDir( const KConfig *config, bool syncable ) | |||
100 | mFormat = factory->format( mFormatName ); | 101 | mFormat = factory->format( mFormatName ); |
101 | 102 | ||
102 | if ( !mFormat ) { | 103 | if ( !mFormat ) { |
103 | mFormatName = "vcard"; | 104 | mFormatName = "vcard"; |
104 | mFormat = factory->format( mFormatName ); | 105 | mFormat = factory->format( mFormatName ); |
105 | } | 106 | } |
106 | 107 | ||
107 | /*US | 108 | /*US |
108 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); | 109 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); |
109 | if (mFormatName == "vcard") | 110 | if (mFormatName == "vcard") |
110 | mFormat = new VCardFormatPlugin2(); | 111 | mFormat = new VCardFormatPlugin2(); |
111 | else if (mFormatName == "binary") | 112 | else if (mFormatName == "binary") |
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 | ||
124 | ResourceDir::~ResourceDir() | 125 | ResourceDir::~ResourceDir() |
125 | { | 126 | { |
126 | delete mFormat; | 127 | delete mFormat; |
127 | mFormat = 0; | 128 | mFormat = 0; |
128 | } | 129 | } |
129 | 130 | ||
130 | void ResourceDir::writeConfig( KConfig *config ) | 131 | void ResourceDir::writeConfig( KConfig *config ) |
131 | { | 132 | { |
132 | config->setGroup( "Resource_" + identifier() ); | 133 | config->setGroup( "Resource_" + identifier() ); |
133 | Resource::writeConfig( config ); | 134 | Resource::writeConfig( config ); |
134 | 135 | ||
135 | config->writeEntry( "FilePath", mPath ); | 136 | config->writeEntry( "FilePath", mPath ); |
136 | config->writeEntry( "FileFormat", mFormatName ); | 137 | config->writeEntry( "FileFormat", mFormatName ); |
@@ -195,54 +196,55 @@ bool ResourceDir::load() | |||
195 | continue; | 196 | continue; |
196 | } | 197 | } |
197 | 198 | ||
198 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) | 199 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) |
199 | ok = false; | 200 | ok = false; |
200 | 201 | ||
201 | file.close(); | 202 | file.close(); |
202 | } | 203 | } |
203 | 204 | ||
204 | return ok; | 205 | return ok; |
205 | } | 206 | } |
206 | 207 | ||
207 | bool ResourceDir::save( Ticket *ticket ) | 208 | bool 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 | ||
218 | QFile file( mPath + "/" + (*it).uid() ); | 219 | QFile file( mPath + "/" + (*it).uid() ); |
219 | if ( !file.open( IO_WriteOnly ) ) { | 220 | if ( !file.open( IO_WriteOnly ) ) { |
220 | addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); | 221 | addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); |
221 | continue; | 222 | continue; |
222 | } | 223 | } |
223 | 224 | ||
224 | mFormat->save( *it, &file ); | 225 | mFormat->save( *it, &file ); |
225 | 226 | ||
226 | // mark as unchanged | 227 | // mark as unchanged |
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 |
237 | return ok; | 239 | return ok; |
238 | } | 240 | } |
239 | 241 | ||
240 | bool ResourceDir::lock( const QString &path ) | 242 | bool ResourceDir::lock( const QString &path ) |
241 | { | 243 | { |
242 | #ifdef ALLOW_LOCKING | 244 | #ifdef ALLOW_LOCKING |
243 | QString p = path; | 245 | QString p = path; |
244 | //US change the implementation how the lockfilename is getting created | 246 | //US change the implementation how the lockfilename is getting created |
245 | //US p.replace( QRegExp("/"), "_" ); | 247 | //US p.replace( QRegExp("/"), "_" ); |
246 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); | 248 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); |
247 | KURL url(p); | 249 | KURL url(p); |
248 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 250 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
@@ -288,40 +290,43 @@ void ResourceDir::unlock( const QString &path ) | |||
288 | //US change the implementation how the lockfilename is getting created | 290 | //US change the implementation how the lockfilename is getting created |
289 | //US p.replace( QRegExp( "/" ), "_" ); | 291 | //US p.replace( QRegExp( "/" ), "_" ); |
290 | //US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); | 292 | //US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); |
291 | KURL url(p); | 293 | KURL url(p); |
292 | QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 294 | QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
293 | 295 | ||
294 | ::unlink( QFile::encodeName( lockName ) ); | 296 | ::unlink( QFile::encodeName( lockName ) ); |
295 | QFile::remove( mLockUniqueName ); | 297 | QFile::remove( mLockUniqueName ); |
296 | addressBook()->emitAddressBookUnlocked(); | 298 | addressBook()->emitAddressBookUnlocked(); |
297 | #else | 299 | #else |
298 | return; | 300 | return; |
299 | #endif | 301 | #endif |
300 | } | 302 | } |
301 | 303 | ||
302 | void ResourceDir::setPath( const QString &path ) | 304 | void 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 | } |
316 | 321 | ||
317 | QString ResourceDir::path() const | 322 | QString ResourceDir::path() const |
318 | { | 323 | { |
319 | return mPath; | 324 | return mPath; |
320 | } | 325 | } |
321 | 326 | ||
322 | void ResourceDir::setFormat( const QString &format ) | 327 | void ResourceDir::setFormat( const QString &format ) |
323 | { | 328 | { |
324 | mFormatName = format; | 329 | mFormatName = format; |
325 | 330 | ||
326 | if ( mFormat ) | 331 | if ( mFormat ) |
327 | delete mFormat; | 332 | delete mFormat; |
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 | |||
@@ -91,25 +91,26 @@ public: | |||
91 | /** | 91 | /** |
92 | * This method is called by an error handler if the application | 92 | * This method is called by an error handler if the application |
93 | * crashed | 93 | * crashed |
94 | */ | 94 | */ |
95 | virtual void cleanUp(); | 95 | virtual void cleanUp(); |
96 | 96 | ||
97 | protected slots: | 97 | protected slots: |
98 | void pathChanged(); | 98 | void pathChanged(); |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | bool lock( const QString &path ); | 101 | bool lock( const QString &path ); |
102 | void unlock( const QString &path ); | 102 | void unlock( const QString &path ); |
103 | 103 | ||
104 | private: | 104 | private: |
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 | }; |
113 | 114 | ||
114 | } | 115 | } |
115 | #endif | 116 | #endif |
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 | |||
@@ -36,38 +36,40 @@ $Id$ | |||
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | 46 | ||
47 | #include "formatfactory.h" | 47 | #include "formatfactory.h" |
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 | |||
58 | using namespace KABC; | 60 | using namespace KABC; |
59 | 61 | ||
60 | extern "C" | 62 | extern "C" |
61 | #ifdef _WIN32_ | 63 | #ifdef _WIN32_ |
62 | __declspec(dllexport) | 64 | __declspec(dllexport) |
63 | #else | 65 | #else |
64 | { | 66 | { |
65 | #endif | 67 | #endif |
66 | 68 | ||
67 | //US void *init_kabc_file() | 69 | //US void *init_kabc_file() |
68 | void *init_microkabc_file() | 70 | void *init_microkabc_file() |
69 | { | 71 | { |
70 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); | 72 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); |
71 | } | 73 | } |
72 | #ifndef _WIN32_ | 74 | #ifndef _WIN32_ |
73 | } | 75 | } |
@@ -102,37 +104,37 @@ ResourceFile::ResourceFile( const QString &fileName, bool syncable , | |||
102 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 104 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
103 | init( fileName, formatName ); | 105 | init( fileName, formatName ); |
104 | } | 106 | } |
105 | 107 | ||
106 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 108 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
107 | { | 109 | { |
108 | mFormatName = formatName; | 110 | mFormatName = formatName; |
109 | 111 | ||
110 | FormatFactory *factory = FormatFactory::self(); | 112 | FormatFactory *factory = FormatFactory::self(); |
111 | mFormat = factory->format( mFormatName ); | 113 | mFormat = factory->format( mFormatName ); |
112 | 114 | ||
113 | if ( !mFormat ) { | 115 | if ( !mFormat ) { |
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 | ||
126 | ResourceFile::~ResourceFile() | 128 | ResourceFile::~ResourceFile() |
127 | { | 129 | { |
128 | delete mFormat; | 130 | delete mFormat; |
129 | mFormat = 0; | 131 | mFormat = 0; |
130 | } | 132 | } |
131 | 133 | ||
132 | void ResourceFile::writeConfig( KConfig *config ) | 134 | void ResourceFile::writeConfig( KConfig *config ) |
133 | { | 135 | { |
134 | 136 | ||
135 | config->setGroup( "Resource_" + identifier() ); | 137 | config->setGroup( "Resource_" + identifier() ); |
136 | Resource::writeConfig( config ); | 138 | Resource::writeConfig( config ); |
137 | 139 | ||
138 | config->writeEntry( "FileName", mFileName ); | 140 | config->writeEntry( "FileName", mFileName ); |
@@ -214,52 +216,53 @@ bool ResourceFile::save( Ticket *ticket ) | |||
214 | 216 | ||
215 | /*US we use a simpler method to create a backupfile | 217 | /*US we use a simpler method to create a backupfile |
216 | 218 | ||
217 | (void) KSaveFile::backupFile( mFileName, QString::null | 219 | (void) KSaveFile::backupFile( mFileName, QString::null |
218 | ,extension ); | 220 | ,extension ); |
219 | 221 | ||
220 | KSaveFile saveFile( mFileName ); | 222 | KSaveFile saveFile( mFileName ); |
221 | bool ok = false; | 223 | bool ok = false; |
222 | if ( saveFile.status() == 0 && saveFile.file() ) | 224 | if ( saveFile.status() == 0 && saveFile.file() ) |
223 | { | 225 | { |
224 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | 226 | mFormat->saveAll( addressBook(), this, saveFile.file() ); |
225 | ok = saveFile.close(); | 227 | ok = saveFile.close(); |
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 ) { |
236 | mFormat->saveAll( addressBook(), this, &info ); | 239 | mFormat->saveAll( addressBook(), this, &info ); |
237 | 240 | ||
238 | info.close(); | 241 | info.close(); |
239 | ok = true; | 242 | ok = true; |
240 | } | 243 | } |
241 | else { | 244 | else { |
242 | 245 | ||
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 |
254 | 257 | ||
255 | return ok; | 258 | return ok; |
256 | } | 259 | } |
257 | 260 | ||
258 | bool ResourceFile::lock( const QString &fileName ) | 261 | bool ResourceFile::lock( const QString &fileName ) |
259 | { | 262 | { |
260 | #ifdef ALLOW_LOCKING | 263 | #ifdef ALLOW_LOCKING |
261 | 264 | ||
262 | 265 | ||
263 | QString fn = fileName; | 266 | QString fn = fileName; |
264 | 267 | ||
265 | //US change the implementation how the lockfilename is getting created | 268 | //US change the implementation how the lockfilename is getting created |
@@ -313,40 +316,43 @@ void ResourceFile::unlock( const QString &fileName ) | |||
313 | //US fn.replace( QRegExp( "/" ), "_" ); | 316 | //US fn.replace( QRegExp( "/" ), "_" ); |
314 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 317 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
315 | //US QString lockName = fn + ".lock"; | 318 | //US QString lockName = fn + ".lock"; |
316 | KURL url(fn); | 319 | KURL url(fn); |
317 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 320 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
318 | 321 | ||
319 | QFile::remove( lockName ); | 322 | QFile::remove( lockName ); |
320 | QFile::remove( mLockUniqueName ); | 323 | QFile::remove( mLockUniqueName ); |
321 | addressBook()->emitAddressBookUnlocked(); | 324 | addressBook()->emitAddressBookUnlocked(); |
322 | #else | 325 | #else |
323 | return; | 326 | return; |
324 | #endif | 327 | #endif |
325 | } | 328 | } |
326 | 329 | ||
327 | void ResourceFile::setFileName( const QString &fileName ) | 330 | void 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 | } |
341 | 347 | ||
342 | QString ResourceFile::fileName() const | 348 | QString ResourceFile::fileName() const |
343 | { | 349 | { |
344 | return mFileName; | 350 | return mFileName; |
345 | } | 351 | } |
346 | 352 | ||
347 | void ResourceFile::setFormat( const QString &format ) | 353 | void ResourceFile::setFormat( const QString &format ) |
348 | { | 354 | { |
349 | mFormatName = format; | 355 | mFormatName = format; |
350 | delete mFormat; | 356 | delete mFormat; |
351 | 357 | ||
352 | FormatFactory *factory = FormatFactory::self(); | 358 | FormatFactory *factory = FormatFactory::self(); |
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 | |||
@@ -140,23 +140,24 @@ public: | |||
140 | protected slots: | 140 | protected slots: |
141 | void fileChanged(); | 141 | void fileChanged(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | void init( const QString &fileName, const QString &format ); | 144 | void init( const QString &fileName, const QString &format ); |
145 | 145 | ||
146 | bool lock( const QString &fileName ); | 146 | bool lock( const QString &fileName ); |
147 | void unlock( const QString &fileName ); | 147 | void unlock( const QString &fileName ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | QString mFileName; | 150 | QString mFileName; |
151 | QString mFormatName; | 151 | QString mFormatName; |
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 | ||
162 | #endif | 163 | #endif |
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 | |||
@@ -87,57 +87,57 @@ class ConfigViewItem : public QCheckListItem | |||
87 | Resource* mResource; | 87 | Resource* mResource; |
88 | 88 | ||
89 | bool mIsStandard; | 89 | bool mIsStandard; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | ConfigPage::ConfigPage( QWidget *parent, const char *name ) | 92 | ConfigPage::ConfigPage( QWidget *parent, const char *name ) |
93 | : QWidget( parent, name ), | 93 | : QWidget( parent, name ), |
94 | mCurrentManager( 0 ), | 94 | mCurrentManager( 0 ), |
95 | mCurrentConfig( 0 ) | 95 | mCurrentConfig( 0 ) |
96 | { | 96 | { |
97 | setCaption( i18n( "Resource Configuration" ) ); | 97 | setCaption( i18n( "Resource Configuration" ) ); |
98 | 98 | ||
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 ); |
109 | groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); | 109 | groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); |
110 | 110 | ||
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 ); |
132 | mStandardButton->setEnabled( false ); | 132 | mStandardButton->setEnabled( false ); |
133 | 133 | ||
134 | 134 | ||
135 | connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); | 135 | connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); |
136 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); | 136 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); |
137 | connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); | 137 | connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); |
138 | connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); | 138 | connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); |
139 | 139 | ||
140 | 140 | ||
141 | mainLayout->addWidget( groupBox ); | 141 | mainLayout->addWidget( groupBox ); |
142 | 142 | ||
143 | connect( mFamilyCombo, SIGNAL( activated( int ) ), | 143 | connect( mFamilyCombo, SIGNAL( activated( int ) ), |