Commit 7e5d3f17 authored by Harald Hvaal's avatar Harald Hvaal
Browse files

Introduced the CompressionOptions type, which can be used for non-required...

Introduced the CompressionOptions type, which can be used for non-required options when compressing.

svn path=/trunk/KDE/kdeutils/ark/; revision=869788
parent 1ff8518a
......@@ -48,6 +48,13 @@ namespace Kerfuffle
typedef QHash<int, QVariant> ArchiveEntry;
/**
These are the extra options for doing the compression. Naming convention
is CamelCase with either Global, or the compression type (such as Zip,
Rar, etc), followed by the property name used
*/
typedef QHash<QString, QVariant> CompressionOptions;
class KERFUFFLE_EXPORT Archive
{
public:
......@@ -67,7 +74,7 @@ namespace Kerfuffle
virtual KJob* create() = 0;
virtual ListJob* list() = 0;
virtual DeleteJob* deleteFiles( const QList<QVariant> & files ) = 0;
virtual AddJob* addFiles( const QStringList & files, const QString& path = QString()) = 0;
virtual AddJob* addFiles( const QStringList & files, const CompressionOptions& options = CompressionOptions()) = 0;
virtual ExtractJob* copyFiles( const QList<QVariant> & files, const QString & destinationDir, Archive::CopyFlags flags) = 0;
virtual bool isSingleFolderArchive() = 0;
......
......@@ -96,10 +96,10 @@ namespace Kerfuffle
return newJob;
}
AddJob* ArchiveBase::addFiles( const QStringList & files, const QString& path)
AddJob* ArchiveBase::addFiles( const QStringList & files, const CompressionOptions& options)
{
Q_ASSERT( !m_iface->isReadOnly() );
AddJob *newJob = new AddJob(path, files, static_cast<ReadWriteArchiveInterface*>( m_iface ), this );
AddJob *newJob = new AddJob(files, options, static_cast<ReadWriteArchiveInterface*>( m_iface ), this );
connect(m_iface, SIGNAL(userQuery(Query*)),
newJob, SIGNAL(userQuery(Query*)));
return newJob;
......
......@@ -54,7 +54,7 @@ namespace Kerfuffle
virtual KJob* create();
virtual ListJob* list();
virtual DeleteJob* deleteFiles( const QList<QVariant> & files );
virtual AddJob* addFiles( const QStringList & files , const QString& path = QString());
virtual AddJob* addFiles( const QStringList & files, const CompressionOptions& options = CompressionOptions() );
virtual ExtractJob* copyFiles( const QList<QVariant> & files, const QString & destinationDir, Archive::CopyFlags flags );
virtual bool isReadOnly();
......
......@@ -103,7 +103,7 @@ namespace Kerfuffle
virtual bool isReadOnly() const;
virtual bool addFiles( const QString& path, const QStringList & files ) = 0;
virtual bool addFiles( const QStringList & files, const CompressionOptions& options ) = 0;
virtual bool deleteFiles( const QList<QVariant> & files ) = 0;
};
......
......@@ -149,8 +149,8 @@ namespace Kerfuffle
}
AddJob::AddJob( const QString& path, const QStringList & files, ReadWriteArchiveInterface *interface, QObject *parent )
: Job( interface, parent ), m_files( files ), m_path(path)
AddJob::AddJob( const QStringList& files, const CompressionOptions& options , ReadWriteArchiveInterface *interface, QObject *parent )
: Job( interface, parent ), m_files( files ), m_options(options)
{
}
......@@ -165,7 +165,7 @@ namespace Kerfuffle
Q_ASSERT(m_writeInterface);
m_writeInterface->registerObserver( this );
setError( !m_writeInterface->addFiles( m_path, m_files ) );
setError( !m_writeInterface->addFiles( m_files, m_options ) );
m_writeInterface->removeObserver( this );
emitResult();
......
......@@ -114,14 +114,14 @@ namespace Kerfuffle
{
Q_OBJECT
public:
AddJob(const QString& path, const QStringList & files,
AddJob(const QStringList & files, const CompressionOptions& options,
ReadWriteArchiveInterface *interface, QObject *parent = 0
);
void doWork();
private:
QStringList m_files;
QString m_path;
CompressionOptions m_options;
};
......
......@@ -677,13 +677,13 @@ ExtractJob* ArchiveModel::extractFiles( const QList<QVariant>& files, const QStr
return newJob;
}
AddJob* ArchiveModel::addFiles( const QStringList & filenames, const QString& path )
AddJob* ArchiveModel::addFiles( const QStringList & filenames, const CompressionOptions& options )
{
Q_ASSERT( m_archive );
if ( !m_archive->isReadOnly())
{
AddJob *job = m_archive->addFiles( filenames, path );
AddJob *job = m_archive->addFiles(filenames, options);
m_jobTracker->registerJob( job );
connect( job, SIGNAL( newEntry( const ArchiveEntry& ) ),
this, SLOT( slotNewEntry( const ArchiveEntry& ) ) );
......
......@@ -65,7 +65,7 @@ class ArchiveModel: public QAbstractItemModel
ExtractJob* extractFile( const QVariant& fileName, const QString & destinationDir, Archive::CopyFlags flags ) const;
ExtractJob* extractFiles( const QList<QVariant>& files, const QString & destinationDir, Kerfuffle::Archive::CopyFlags flags ) const;
AddJob* addFiles( const QStringList & paths, const QString& path = QString() );
AddJob* addFiles( const QStringList & paths, const CompressionOptions& options = CompressionOptions() );
DeleteJob* deleteFiles( const QList<QVariant> & files );
void setJobTracker( KJobTrackerInterface *tracker ) { m_jobTracker = tracker; }
......
......@@ -581,7 +581,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
if ( !filesToAdd.isEmpty() )
{
AddJob *job = m_model->addFiles( filesToAdd, path );
AddJob *job = m_model->addFiles( filesToAdd);
connect( job, SIGNAL( result( KJob* ) ),
this, SLOT( slotAddFilesDone( KJob* ) ) );
job->start();
......
......@@ -230,9 +230,9 @@ bool p7zipInterface::copyFiles( const QList<QVariant> & files, const QString & d
return true;
}
bool p7zipInterface::addFiles( const QString& path, const QStringList & files )
bool p7zipInterface::addFiles( const QStringList & files, const CompressionOptions& options )
{
kDebug( 1601 ) << "Will try to add path " << path << " files " << files << " to " << m_filename << " using " << m_exepath;
kDebug( 1601 ) << "Will try to add files " << files << " to " << m_filename << " using " << m_exepath;
if (m_exepath.isNull())
{
......
......@@ -38,7 +38,7 @@ class p7zipInterface: public ReadWriteArchiveInterface
bool list();
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, Archive::CopyFlags flags );
bool addFiles( const QString& path, const QStringList & files );
bool addFiles( const QStringList & files, const CompressionOptions& options );
bool deleteFiles( const QList<QVariant> & files );
private:
......
......@@ -120,7 +120,7 @@ bool BKInterface::browse( BkFileBase* base, const QString& prefix )
return true;
}
bool BKInterface::addFiles( const QString& path, const QStringList & files )
bool BKInterface::addFiles( const QStringList & files, const CompressionOptions& options )
{
Q_UNUSED(files );
return false;
......
......@@ -36,7 +36,7 @@ class BKInterface: public ReadWriteArchiveInterface
bool list();
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, Archive::CopyFlags flags);
bool addFiles( const QString& path, const QStringList & files );
bool addFiles( const QStringList & files, const CompressionOptions& options );
bool deleteFiles( const QList<QVariant> & files );
private:
......
......@@ -389,7 +389,7 @@ void LibArchiveInterface::copyData( struct archive *source, struct archive *dest
}
}
bool LibArchiveInterface::addFiles(const QString& path, const QStringList & files )
bool LibArchiveInterface::addFiles( const QStringList & files, const CompressionOptions& options )
{
struct archive *arch_reader, *arch_writer;
struct archive_entry *entry;
......@@ -535,7 +535,7 @@ bool LibArchiveInterface::addFiles(const QString& path, const QStringList & file
foreach(const QString& selectedFile, expandedFiles) {
struct stat st;
QFileInfo info(path + selectedFile);
QFileInfo info(selectedFile);
entry = archive_entry_new();
stat(QFile::encodeName(selectedFile).constData(), &st);
......
......@@ -40,7 +40,7 @@ class LibArchiveInterface: public ReadWriteArchiveInterface
bool list();
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, Archive::CopyFlags flags );
bool addFiles(const QString& path, const QStringList & files );
bool addFiles( const QStringList & files, const CompressionOptions& options );
bool deleteFiles( const QList<QVariant> & files );
private:
......
......@@ -261,7 +261,7 @@ class LibZipInterface: public ReadWriteArchiveInterface
return true;
}
bool addFiles( const QString& path, const QStringList & files )
bool addFiles( const QStringList & files, const CompressionOptions& options )
{
kDebug( 1601 ) << "adding " << files.count() << " files";
progress( 0.0 );
......
......@@ -219,7 +219,7 @@ bool RARInterface::copyFiles( const QList<QVariant> & files, const QString & des
return true;
}
bool RARInterface::addFiles(const QString& path, const QStringList & files )
bool RARInterface::addFiles( const QStringList & files, const CompressionOptions& options )
{
kDebug( 1601 ) << "Will try to add " << files << " to " << m_filename << " using " << m_rarpath;
......
......@@ -36,7 +36,7 @@ class RARInterface: public ReadWriteArchiveInterface
bool list();
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, Archive::CopyFlags flags );
bool addFiles(const QString& path, const QStringList & files );
bool addFiles( const QStringList & files, const CompressionOptions& options );
bool deleteFiles( const QList<QVariant> & files );
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment