Commit c1a72a8e authored by Elvis Angelaccio's avatar Elvis Angelaccio

Fix archivemodel columns with singlefile archives

ArchiveModel was setting 0 as Size with singlefile archives,
because the singlefile plugin doesn't report the uncompressed size.

This patch removes the Size column if the size property is 0 but the
compressedSize one is higher than 0, which cannot happen.
As compressedSize for singlefile entries, we just set the size of the
archive.

BUG: 376225
FIXED-IN: 16.12.3

Differential Revision: D4536
parent 0db57f3f
......@@ -583,14 +583,18 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
if (m_showColumns.isEmpty()) {
QList<int> toInsert;
auto i = m_propertiesMap.begin();
while (i != m_propertiesMap.end()) {
const auto size = receivedEntry->property("size").toULongLong();
const auto compressedSize = receivedEntry->property("compressedSize").toULongLong();
for (auto i = m_propertiesMap.begin(); i != m_propertiesMap.end(); i++) {
// Singlefile plugin doesn't report the uncompressed size.
if (i.key() == Size && size == 0 && compressedSize > 0) {
continue;
}
if (!receivedEntry->property(i.value()).toString().isEmpty()) {
if (i.key() != CompressedSize || receivedEntry->compressedSizeIsSet) {
toInsert << i.key();
}
}
++i;
}
if (behaviour == NotifyViews) {
beginInsertColumns(QModelIndex(), 0, toInsert.size() - 1);
......
......@@ -108,6 +108,7 @@ bool LibSingleFileInterface::list()
Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry();
connect(this, &QObject::destroyed, e, &QObject::deleteLater);
e->setProperty("fullPath", uncompressedFileName());
e->setProperty("compressedSize", QFileInfo(filename()).size());
emit entry(e);
return true;
......
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