ark
internaljobs.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KERFUFFLE_INTERNAL_JOBS_H
00027 #define KERFUFFLE_INTERNAL_JOBS_H
00028
00029 #include <ThreadWeaver/Job>
00030 #include <ThreadWeaver/Weaver>
00031
00032 #include "archiveinterface.h"
00033 #include "observer.h"
00034 #include <QList>
00035
00036
00037 namespace Kerfuffle
00038 {
00039 class ArchiveJobHelper;
00040
00041 class InternalJob: public ThreadWeaver::Job
00042 {
00043 Q_OBJECT
00044 public:
00045 InternalJob( QObject *parent = 0 );
00046 ~InternalJob();
00047
00048 bool success() const { return m_success; }
00049
00050 protected:
00051 void setSuccess( bool success ) { m_success = success; }
00052
00053 private:
00054 bool m_success;
00055 };
00056
00057 class InternalListingJob: public InternalJob
00058 {
00059 Q_OBJECT
00060 public:
00061 explicit InternalListingJob( ReadOnlyArchiveInterface *archive, QObject *parent = 0 );
00062 ~InternalListingJob();
00063
00064 protected:
00065 void run();
00066
00067 signals:
00068 void entry( const ArchiveEntry & );
00069 void progress( double );
00070 void error( const QString& errorMessage, const QString& details );
00071
00072 private:
00073 QList<ArchiveEntry> m_entries;
00074 ArchiveJobHelper *m_helper;
00075 ReadOnlyArchiveInterface *m_archive;
00076 };
00077
00078 class InternalExtractJob: public InternalJob
00079 {
00080 Q_OBJECT
00081 public:
00082 InternalExtractJob( ReadOnlyArchiveInterface *archive, const QList<QVariant> & files, const QString & destinationDirectory, bool preservePaths = false, QObject *parent = 0 );
00083 ~InternalExtractJob();
00084
00085 protected:
00086 void run();
00087
00088 signals:
00089 void progress( double p );
00090 void error( const QString& errorMessage, const QString& details );
00091
00092 private:
00093 ReadOnlyArchiveInterface *m_archive;
00094 QList<QVariant> m_files;
00095 QString m_destinationDirectory;
00096 ArchiveJobHelper *m_helper;
00097 bool m_preservePaths;
00098 };
00099
00100 class InternalAddJob: public InternalJob
00101 {
00102 Q_OBJECT
00103 public:
00104 InternalAddJob( ReadWriteArchiveInterface *archive, const QStringList & files, QObject *parent = 0 );
00105 ~InternalAddJob();
00106
00107 protected:
00108 void run();
00109
00110 signals:
00111 void entry( const ArchiveEntry & );
00112 void progress( double );
00113 void error( const QString& errorMessage, const QString& details );
00114
00115 private:
00116 QStringList m_files;
00117 ReadWriteArchiveInterface *m_archive;
00118 ArchiveJobHelper *m_helper;
00119 };
00120
00121 class InternalDeleteJob: public InternalJob
00122 {
00123 Q_OBJECT
00124 public:
00125 InternalDeleteJob( ReadWriteArchiveInterface *archive, const QList<QVariant> & entries, QObject *parent = 0 );
00126 ~InternalDeleteJob();
00127
00128 protected:
00129 void run();
00130
00131 signals:
00132 void entryRemoved( const QString& path );
00133
00134 private:
00135 QList<QVariant> m_entries;
00136 ReadWriteArchiveInterface *m_archive;
00137 ArchiveJobHelper *m_helper;
00138
00139 };
00140
00141 class ArchiveJobHelper: public QObject, public ArchiveObserver
00142 {
00143 Q_OBJECT
00144 public:
00145 explicit ArchiveJobHelper( ReadOnlyArchiveInterface *archive, QObject *parent = 0 );
00146 ~ArchiveJobHelper();
00147
00148 bool getTheListing();
00149
00150 void onError( const QString & message, const QString & details = QString() );
00151 void onEntry( const ArchiveEntry & archiveEntry );
00152 void onEntryRemoved( const QString & path );
00153 void onProgress( double );
00154
00155 signals:
00156 void entry( const ArchiveEntry & );
00157 void progress( double );
00158 void error( const QString & message, const QString & details );
00159 void entryRemoved( const QString & path );
00160
00161 private:
00162 ReadOnlyArchiveInterface *m_archive;
00163 };
00164
00165 }
00166
00167 #endif // KERFUFFLE_INTERNAL_JOBS_H