Commit 3ad7526b authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Get columns to show from first file entry

Currently, we use the first entry in an archive to determine which
columns to show. If the first entry happens to be a directory, then all
relevant columns might not be shown.

Make sure we always check the first file entry for columns to
show.

BUG: 406135
FIXED-IN: 19.04.2
Differential Revision: D20683
parent f1444e45
......@@ -46,6 +46,7 @@ ArchiveModel::ArchiveModel(const QString &dbusPathName, QObject *parent)
, m_dbusPathName(dbusPathName)
, m_numberOfFiles(0)
, m_numberOfFolders(0)
, m_fileEntryListed(false)
{
initRootEntry();
......@@ -463,9 +464,9 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
return;
}
//if there are no addidional columns registered, then have a look at the
//entry and populate some
if (m_showColumns.isEmpty()) {
// If there are no columns registered, then populate columns from entry. If the first entry
// is a directory we check again for the first file entry to ensure all relevent columms are shown.
if (m_showColumns.isEmpty() || !m_fileEntryListed) {
QList<int> toInsert;
const auto size = receivedEntry->property("size").toULongLong();
......@@ -477,7 +478,9 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
}
if (!receivedEntry->property(i.value().constData()).toString().isEmpty()) {
if (i.key() != CompressedSize || receivedEntry->compressedSizeIsSet) {
toInsert << i.key();
if (!m_showColumns.contains(i.key())) {
toInsert << i.key();
}
}
}
}
......@@ -489,7 +492,7 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
endInsertColumns();
}
qCDebug(ARK) << "Showing columns: " << m_showColumns;
m_fileEntryListed = !receivedEntry->isDir();
}
// #194241: Filenames such as "./file" should be displayed as "file"
......@@ -537,8 +540,12 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
void ArchiveModel::slotLoadingFinished(KJob *job)
{
std::sort(m_showColumns.begin(), m_showColumns.end());
if (!job->error()) {
qCDebug(ARK) << "Showing columns: " << m_showColumns;
m_archive.reset(qobject_cast<LoadJob*>(job)->archive());
beginResetModel();
......
......@@ -194,6 +194,10 @@ private:
qulonglong m_numberOfFiles;
qulonglong m_numberOfFolders;
qulonglong m_uncompressedSize;
// Whether a file entry has been listed. Used to ensure all relevent columns are shown,
// since directories might have fewer columns than files.
bool m_fileEntryListed;
};
#endif // ARCHIVEMODEL_H
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