From b37795d3447b4f5b5d9cd7923979f7c801346646 Mon Sep 17 00:00:00 2001 From: warren Date: Mon, 2 Dec 2019 21:56:44 +0500 Subject: [PATCH] Expand single-item folders in torrent content --- src/gui/addnewtorrentdialog.cpp | 8 ++++++-- src/gui/properties/propertieswidget.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index f1845b15d..8c924ce1c 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -625,8 +625,12 @@ void AddNewTorrentDialog::setupTreeview() m_ui->contentTreeView->hideColumn(REMAINING); m_ui->contentTreeView->hideColumn(AVAILABILITY); - // Expand root folder - m_ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true); + // Expand single-item folders recursively + QModelIndex currentIndex; + while (m_contentModel->rowCount(currentIndex) == 1) { + currentIndex = m_contentModel->index(0, 0, currentIndex); + m_ui->contentTreeView->setExpanded(currentIndex, true); + } } updateDiskSpaceLabel(); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 607617747..b461bd57e 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -322,8 +322,13 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent // List files in torrent m_propListModel->model()->setupModelData(m_torrent->info()); - if (m_propListModel->model()->rowCount() == 1) - m_ui->filesList->setExpanded(m_propListModel->index(0, 0), true); + + // Expand single-item folders recursively + QModelIndex currentIndex; + while (m_propListModel->rowCount(currentIndex) == 1) { + currentIndex = m_propListModel->index(0, 0, currentIndex); + m_ui->filesList->setExpanded(currentIndex, true); + } // Load file priorities m_propListModel->model()->updateFilesPriorities(m_torrent->filePriorities());