Skip to content

Commit 01307b3

Browse files
Improve drawing speed of transferlist with many torrents.
1 parent 0322002 commit 01307b3

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

Changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- BUGFIX: Add confirmation dialog for "Force recheck" action (closes #131)
1010
- BUGFIX: Greatly improve RSS manager performance (closes #34)
1111
- OTHER: Generate translations at configure time to reduce tarball size
12+
- PERFORMANCE: Impove drawing speed of tranferlist when there are many torrents(>100)
1213

1314
* Thu Aug 09 2012 - Christophe Dumez <chris@qbittorrent.org> - v3.0.0
1415
- FEATURE: Brand new torrent addition dialog

src/qtlibtorrent/torrentmodel.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030

3131
#include <QDebug>
32+
#include <QFontMetrics>
3233

3334
#include "torrentmodel.h"
3435
#include "torrentpersistentdata.h"
@@ -301,6 +302,19 @@ QVariant TorrentModel::data(const QModelIndex &index, int role) const
301302
if (!index.isValid()) return QVariant();
302303
try {
303304
if (index.row() >= 0 && index.row() < rowCount() && index.column() >= 0 && index.column() < columnCount())
305+
if (role == Qt::SizeHintRole)
306+
{
307+
QSize size(m_torrents[index.row()]->data(index.column(), role).toSize());
308+
QFont font;
309+
QFontMetrics fm(font);
310+
QIcon icon(":/Icons/skin/downloading.png");
311+
int fm_height(fm.height());
312+
QList<QSize> ic_sizes(icon.availableSizes());
313+
int icon_height(ic_sizes[0].height());
314+
size.setHeight(fm_height > icon_height ? fm_height : icon_height);
315+
return QVariant(size);
316+
}
317+
else
304318
return m_torrents[index.row()]->data(index.column(), role);
305319
} catch(invalid_handle&) {}
306320
return QVariant();

src/transferlistwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ using namespace libtorrent;
6767
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession *_BTSession):
6868
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
6969

70+
setUniformRowHeights(true);
7071
// Load settings
7172
bool column_loaded = loadSettings();
7273

0 commit comments

Comments
 (0)