summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <rthomsen6@gmail.com>2016-11-05 15:32:35 (GMT)
committerRagnar Thomsen <rthomsen6@gmail.com>2016-11-05 15:45:00 (GMT)
commit9de9b974eb6cdcbb77c64d97a304cc22411a84d3 (patch)
tree121c830b7e2c1807839e79b4b31edd2e3e8dd8a1
parent862ac22eedcf2e3e68ed157da88ac31834395829 (diff)
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
-rw-r--r--kerfuffle/cliinterface.cpp21
-rw-r--r--kerfuffle/cliinterface.h4
2 files changed, 23 insertions, 2 deletions
diff --git a/kerfuffle/cliinterface.cpp b/kerfuffle/cliinterface.cpp
index 1b39370..25bef68 100644
--- a/kerfuffle/cliinterface.cpp
+++ b/kerfuffle/cliinterface.cpp
@@ -65,7 +65,9 @@ CliInterface::CliInterface(QObject *parent, const QVariantList & args)
m_abortingOperation(false),
m_listEmptyLines(false),
m_extractTempDir(Q_NULLPTR),
- m_commentTempFile(Q_NULLPTR)
+ m_commentTempFile(Q_NULLPTR),
+ m_archiveSizeOnDisk(0),
+ m_listedSize(0)
{
//because this interface uses the event loop
setWaitForFinishedSignal(true);
@@ -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);
+ }
+ }
+}
+
}
diff --git a/kerfuffle/cliinterface.h b/kerfuffle/cliinterface.h
index bc7bb64..10c9b23 100644
--- a/kerfuffle/cliinterface.h
+++ b/kerfuffle/cliinterface.h
@@ -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);
};
}