Commit 9de9b974 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Show progress in percentage when listing with CliPlugins

Use the summed compressedSize property of Archive::Entry and compare it
with the archive size on disk to compute the progress in percentage. We
connect the entry signal to a slot in CliInterface.

This works for all Cli-based archives except 7z, since they dont give
compressedSize of individual entries.

Differential Revision: D3138
parent 862ac22e
......@@ -65,7 +65,9 @@ CliInterface::CliInterface(QObject *parent, const QVariantList & args)
//because this interface uses the event loop
......@@ -98,6 +100,10 @@ bool CliInterface::list()
m_operationMode = List;
m_numberOfEntries = 0;
// To compute progress.
m_archiveSizeOnDisk = QFileInfo(filename()).size();
connect(this, &ReadOnlyArchiveInterface::entry, this, &CliInterface::onEntry);
if (!runProcess(m_cliProps->property("listProgram").toString(), m_cliProps->listArgs(filename(), password()))) {
return false;
......@@ -1111,4 +1117,17 @@ CliProperties *CliInterface::cliProperties() const
return m_cliProps;
void CliInterface::onEntry(Archive::Entry *archiveEntry)
if (archiveEntry->compressedSizeIsSet) {
m_listedSize += archiveEntry->property("compressedSize").toUInt();
if (m_listedSize <= m_archiveSizeOnDisk) {
emit progress(float(m_listedSize)/float(m_archiveSizeOnDisk));
} else {
// In case summed compressed size exceeds archive size on disk.
emit progress(1);
......@@ -214,6 +214,8 @@ private:
QTemporaryDir *m_extractTempDir;
QTemporaryFile *m_commentTempFile;
QVector<Archive::Entry*> m_extractedFiles;
uint m_archiveSizeOnDisk;
uint m_listedSize;
protected slots:
virtual void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
......@@ -221,7 +223,7 @@ protected slots:
private slots:
void extractProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void continueCopying(bool result);
void onEntry(Archive::Entry *archiveEntry);
Supports Markdown
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