Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 1d3acec..361b36b 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -53,2 +53,4 @@ $Id$ #include "resourcefile.h" +#include "syncwidget.h" + @@ -58,3 +60,3 @@ extern "C" #ifdef _WIN32_ -__declspec(dllexport) +__declspec(dllexport) #else @@ -66,3 +68,3 @@ __declspec(dllexport) { - return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); + return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, KRES::SyncWidget>(); } @@ -72,4 +74,4 @@ __declspec(dllexport) -ResourceFile::ResourceFile( const KConfig *config ) - : Resource( config ) , mFormat( 0 ) +ResourceFile::ResourceFile( const KConfig *config, bool syncable ) + : Resource( config, syncable ) , mFormat( 0 ) { @@ -91,5 +93,5 @@ ResourceFile::ResourceFile( const KConfig *config ) -ResourceFile::ResourceFile( const QString &fileName, +ResourceFile::ResourceFile( const QString &fileName, bool syncable , const QString &formatName ) - : Resource( 0 ) + : Resource( 0, syncable ) { @@ -141,3 +143,3 @@ void ResourceFile::writeConfig( KConfig *config ) - config->setGroup( "Resource_" + identifier() ); + config->setGroup( "Resource_" + identifier() ); Resource::writeConfig( config ); @@ -146,5 +148,5 @@ void ResourceFile::writeConfig( KConfig *config ) config->writeEntry( "FileFormat", mFormatName ); - + // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); - + } @@ -199,3 +201,3 @@ bool ResourceFile::load() { - + @@ -208,3 +210,3 @@ bool ResourceFile::load() // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); - + return mFormat->loadAll( addressBook(), this, &file ); @@ -215,3 +217,3 @@ bool ResourceFile::save( Ticket *ticket ) // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); - + @@ -219,5 +221,5 @@ bool ResourceFile::save( Ticket *ticket ) QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); - + /*US we use a simpler method to create a backupfile - + (void) KSaveFile::backupFile( mFileName, QString::null @@ -234,3 +236,3 @@ bool ResourceFile::save( Ticket *ticket ) -//US ToDo: write backupfile +//US ToDo: write backupfile QFile info; @@ -240,3 +242,3 @@ bool ResourceFile::save( Ticket *ticket ) mFormat->saveAll( addressBook(), this, &info ); - + info.close(); @@ -245,11 +247,11 @@ bool ResourceFile::save( Ticket *ticket ) else { - + } - + if ( !ok ) addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); - + delete ticket; unlock( mFileName ); - + return ok; @@ -262,3 +264,3 @@ bool ResourceFile::lock( const QString &fileName ) { - + @@ -269,7 +271,7 @@ bool ResourceFile::lock( const QString &fileName ) //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); - - KURL url(fn); + + KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); - - + + @@ -279,4 +281,4 @@ bool ResourceFile::lock( const QString &fileName ) lockUniqueName = fn + KApplication::randomString( 8 ); - - url = lockUniqueName; + + url = lockUniqueName; //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); @@ -313,5 +315,5 @@ void ResourceFile::unlock( const QString &fileName ) //US QString lockName = fn + ".lock"; - KURL url(fn); + KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); - + QFile::remove( lockName ); @@ -325,6 +327,6 @@ void ResourceFile::setFileName( const QString &fileName ) mDirWatch.removeFile( mFileName ); - + mFileName = fileName; - + mDirWatch.addFile( mFileName ); @@ -332,3 +334,3 @@ void ResourceFile::setFileName( const QString &fileName ) -//US simulate KDirWatch event +//US simulate KDirWatch event //US fileChanged(); @@ -348,3 +350,3 @@ void ResourceFile::setFormat( const QString &format ) mFormat = factory->format( mFormatName ); -/*US +/*US //qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); @@ -361,3 +363,3 @@ void ResourceFile::setFormat( const QString &format ) */ - + } @@ -375,4 +377,4 @@ void ResourceFile::fileChanged() return; - - + + QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); |