resourcefile.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KABC_RESOURCEFILE_H
00022 #define KABC_RESOURCEFILE_H
00023
00024 #include <kconfig.h>
00025 #include <kdirwatch.h>
00026
00027 #include <sys/types.h>
00028
00029 #include <kabc/resource.h>
00030
00031 namespace KABC {
00032
00033 class FormatPlugin;
00034 class ResourceConfigWidget;
00035 class Lock;
00036
00040 class KABC_EXPORT ResourceFile : public Resource
00041 {
00042 Q_OBJECT
00043
00044 public:
00050 ResourceFile( const KConfig *cfg );
00051
00055 ResourceFile( const QString &fileName, const QString &formatName = "vcard" );
00056
00060 ~ResourceFile();
00061
00065 virtual void writeConfig( KConfig *cfg );
00066
00071 virtual bool doOpen();
00072
00076 virtual void doClose();
00077
00081 virtual Ticket *requestSaveTicket();
00082
00083 virtual void releaseSaveTicket( Ticket* );
00084
00089 virtual bool load();
00090
00091 virtual bool asyncLoad();
00092
00099 virtual bool save( Ticket *ticket );
00100
00101 virtual bool asyncSave( Ticket *ticket );
00102
00106 void setFileName( const QString & );
00107
00111 QString fileName() const;
00112
00116 void setFormat( const QString &name );
00117
00121 QString format() const;
00122
00127 virtual void removeAddressee( const Addressee& addr );
00128
00129 private slots:
00130 void emitLoadingFinished();
00131 void emitLoadingError();
00132 void emitSavingFinished();
00133 void emitSavingError();
00134
00135 protected slots:
00136 void fileChanged();
00137
00138 protected:
00139 void init( const QString &fileName, const QString &format );
00140
00141 bool lock( const QString &fileName );
00142 void unlock( const QString &fileName );
00143
00144 private:
00145 QString mFileName;
00146 QString mFormatName;
00147
00148 FormatPlugin *mFormat;
00149
00150 Lock *mLock;
00151
00152 KDirWatch mDirWatch;
00153
00154 bool mAsynchronous;
00155
00156 class ResourceFilePrivate;
00157 ResourceFilePrivate *d;
00158 };
00159
00160 }
00161
00162 #endif
|