[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ark] kerfuffle: Show progress in percentage when listing with CliPlugins
From: Ragnar Thomsen <rthomsen6 () gmail ! com>
Date: 2016-11-05 15:45:09
Message-ID: E1c339Z-0000gt-GW () code ! kde ! org
[Download RAW message or body]
Git commit 9de9b974eb6cdcbb77c64d97a304cc22411a84d3 by Ragnar Thomsen.
Committed on 05/11/2016 at 15:45.
Pushed by rthomsen into branch 'master'.
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
M +20 -1 kerfuffle/cliinterface.cpp
M +3 -1 kerfuffle/cliinterface.h
http://commits.kde.org/ark/9de9b974eb6cdcbb77c64d97a304cc22411a84d3
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);
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic