Browse Source

Cut down number of signal emits

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
72d1d5d2dd
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 17
      src/gui/transferlistmodel.cpp

17
src/gui/transferlistmodel.cpp

@ -325,13 +325,20 @@ void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *co
void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents) void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents)
{ {
const int columns = (columnCount() - 1); const int columns = (columnCount() - 1);
for (BitTorrent::TorrentHandle *const torrent : torrents) {
const int row = m_torrentMap.value(torrent, -1);
if (row < 0) if (torrents.size() <= (m_torrentList.size() * 0.5)) {
continue; for (BitTorrent::TorrentHandle *const torrent : torrents) {
const int row = m_torrentMap.value(torrent, -1);
emit dataChanged(index(row, 0), index(row, columns)); if (row < 0)
continue;
emit dataChanged(index(row, 0), index(row, columns));
}
}
else {
// save the overhead when more than half of the torrent list needs update
emit dataChanged(index(0, 0), index((rowCount() - 1), columns));
} }
} }

Loading…
Cancel
Save