Browse Source

Fix torrent content sorting

Fix improper sorting of the list of files contained by a torrent.
Always load all torrent content data so that the files list can be sorted properly.
Load torrent content only when needed. Don't load the list of files contained by a torrent if the list widget is not visible.

PR #15604.
adaptive-webui-19844
a-sum-duma 3 years ago committed by GitHub
parent
commit
5dd70b88d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 54
      src/gui/properties/propertieswidget.cpp

54
src/gui/properties/propertieswidget.cpp

@ -362,20 +362,6 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent) @@ -362,20 +362,6 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent)
loadUrlSeeds();
m_ui->labelCreatedByVal->setText(m_torrent->creator());
// List files in torrent
m_propListModel->model()->setupModelData(m_torrent->info());
// 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());
}
// Load dynamic data
loadDynamicData();
@ -536,12 +522,40 @@ void PropertiesWidget::loadDynamicData() @@ -536,12 +522,40 @@ void PropertiesWidget::loadDynamicData()
{
qDebug("Updating priorities in files tab");
m_ui->filesList->setUpdatesEnabled(false);
m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
// XXX: We don't update file priorities regularly for performance
// reasons. This means that priorities will not be updated if
// set from the Web UI.
// PropListModel->model()->updateFilesPriorities(h.file_priorities());
// Load torrent content if not yet done so
const bool isContentInitialized = m_propListModel->model()->hasIndex(0, 0);
if (!isContentInitialized)
{
// List files in torrent
m_propListModel->model()->setupModelData(m_torrent->info());
// Load file priorities
m_propListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
// Update file progress/availability
m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
// Expand single-item folders recursively.
// This will trigger sorting and filtering so do it after all relevant data is loaded.
QModelIndex currentIndex;
while (m_propListModel->rowCount(currentIndex) == 1)
{
currentIndex = m_propListModel->index(0, 0, currentIndex);
m_ui->filesList->setExpanded(currentIndex, true);
}
}
else
{
// Torrent content was loaded already, only make some updates
m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
// XXX: We don't update file priorities regularly for performance
// reasons. This means that priorities will not be updated if
// set from the Web UI.
// m_propListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
}
m_ui->filesList->setUpdatesEnabled(true);
}
break;

Loading…
Cancel
Save