mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
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.
This commit is contained in:
parent
40f2718265
commit
5dd70b88d3
@ -362,20 +362,6 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent)
|
|||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
|
|
||||||
m_ui->labelCreatedByVal->setText(m_torrent->creator());
|
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
|
// Load dynamic data
|
||||||
loadDynamicData();
|
loadDynamicData();
|
||||||
@ -536,12 +522,40 @@ void PropertiesWidget::loadDynamicData()
|
|||||||
{
|
{
|
||||||
qDebug("Updating priorities in files tab");
|
qDebug("Updating priorities in files tab");
|
||||||
m_ui->filesList->setUpdatesEnabled(false);
|
m_ui->filesList->setUpdatesEnabled(false);
|
||||||
m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
|
|
||||||
m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
|
// Load torrent content if not yet done so
|
||||||
// XXX: We don't update file priorities regularly for performance
|
const bool isContentInitialized = m_propListModel->model()->hasIndex(0, 0);
|
||||||
// reasons. This means that priorities will not be updated if
|
if (!isContentInitialized)
|
||||||
// set from the Web UI.
|
{
|
||||||
// PropListModel->model()->updateFilesPriorities(h.file_priorities());
|
// 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);
|
m_ui->filesList->setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user