mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Merge pull request #4062 from glassez/speedup
Some TransferListWidget speedup.
This commit is contained in:
@@ -112,19 +112,6 @@ AddTorrentParams::AddTorrentParams()
|
||||
{
|
||||
}
|
||||
|
||||
// TorrentStatusReport
|
||||
|
||||
TorrentStatusReport::TorrentStatusReport()
|
||||
: nbDownloading(0)
|
||||
, nbSeeding(0)
|
||||
, nbCompleted(0)
|
||||
, nbActive(0)
|
||||
, nbInactive(0)
|
||||
, nbPaused(0)
|
||||
, nbResumed(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Session
|
||||
|
||||
Session *Session::m_instance = 0;
|
||||
@@ -989,6 +976,11 @@ QHash<InfoHash, TorrentHandle *> Session::torrents() const
|
||||
return m_torrents;
|
||||
}
|
||||
|
||||
TorrentStatusReport Session::torrentStatusReport() const
|
||||
{
|
||||
return m_torrentStatusReport;
|
||||
}
|
||||
|
||||
// source - .torrent file path/url or magnet uri (hash for preloaded torrent)
|
||||
bool Session::addTorrent(QString source, const AddTorrentParams ¶ms)
|
||||
{
|
||||
@@ -2375,31 +2367,29 @@ void Session::handleStateUpdateAlert(libt::state_update_alert *p)
|
||||
{
|
||||
foreach (const libt::torrent_status &status, p->status) {
|
||||
TorrentHandle *const torrent = m_torrents.value(status.info_hash);
|
||||
if (torrent) {
|
||||
if (torrent)
|
||||
torrent->handleStateUpdate(status);
|
||||
emit torrentStatusUpdated(torrent);
|
||||
}
|
||||
}
|
||||
|
||||
TorrentStatusReport torrentStatusReport;
|
||||
m_torrentStatusReport = TorrentStatusReport();
|
||||
foreach (TorrentHandle *const torrent, m_torrents) {
|
||||
if (torrent->isDownloading())
|
||||
++torrentStatusReport.nbDownloading;
|
||||
++m_torrentStatusReport.nbDownloading;
|
||||
if (torrent->isUploading())
|
||||
++torrentStatusReport.nbSeeding;
|
||||
++m_torrentStatusReport.nbSeeding;
|
||||
if (torrent->isCompleted())
|
||||
++torrentStatusReport.nbCompleted;
|
||||
++m_torrentStatusReport.nbCompleted;
|
||||
if (torrent->isPaused())
|
||||
++torrentStatusReport.nbPaused;
|
||||
++m_torrentStatusReport.nbPaused;
|
||||
if (torrent->isResumed())
|
||||
++torrentStatusReport.nbResumed;
|
||||
++m_torrentStatusReport.nbResumed;
|
||||
if (torrent->isActive())
|
||||
++torrentStatusReport.nbActive;
|
||||
++m_torrentStatusReport.nbActive;
|
||||
if (torrent->isInactive())
|
||||
++torrentStatusReport.nbInactive;
|
||||
++m_torrentStatusReport.nbInactive;
|
||||
}
|
||||
|
||||
emit torrentsUpdated(torrentStatusReport);
|
||||
emit torrentsUpdated();
|
||||
}
|
||||
|
||||
bool readFile(const QString &path, QByteArray &buf)
|
||||
|
||||
@@ -127,15 +127,13 @@ namespace BitTorrent
|
||||
|
||||
struct TorrentStatusReport
|
||||
{
|
||||
uint nbDownloading;
|
||||
uint nbSeeding;
|
||||
uint nbCompleted;
|
||||
uint nbActive;
|
||||
uint nbInactive;
|
||||
uint nbPaused;
|
||||
uint nbResumed;
|
||||
|
||||
TorrentStatusReport();
|
||||
uint nbDownloading = 0;
|
||||
uint nbSeeding = 0;
|
||||
uint nbCompleted = 0;
|
||||
uint nbActive = 0;
|
||||
uint nbInactive = 0;
|
||||
uint nbPaused = 0;
|
||||
uint nbResumed = 0;
|
||||
};
|
||||
|
||||
class Session : public QObject
|
||||
@@ -161,6 +159,7 @@ namespace BitTorrent
|
||||
|
||||
TorrentHandle *findTorrent(const InfoHash &hash) const;
|
||||
QHash<InfoHash, TorrentHandle *> torrents() const;
|
||||
TorrentStatusReport torrentStatusReport() const;
|
||||
bool hasActiveTorrents() const;
|
||||
bool hasUnfinishedTorrents() const;
|
||||
SessionStatus status() const;
|
||||
@@ -214,11 +213,10 @@ namespace BitTorrent
|
||||
void handleTorrentTrackerAuthenticationRequired(TorrentHandle *const torrent, const QString &trackerUrl);
|
||||
|
||||
signals:
|
||||
void torrentsUpdated(const BitTorrent::TorrentStatusReport &torrentStatusReport = BitTorrent::TorrentStatusReport());
|
||||
void torrentsUpdated();
|
||||
void addTorrentFailed(const QString &error);
|
||||
void torrentAdded(BitTorrent::TorrentHandle *const torrent);
|
||||
void torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent);
|
||||
void torrentStatusUpdated(BitTorrent::TorrentHandle *const torrent);
|
||||
void torrentPaused(BitTorrent::TorrentHandle *const torrent);
|
||||
void torrentResumed(BitTorrent::TorrentHandle *const torrent);
|
||||
void torrentFinished(BitTorrent::TorrentHandle *const torrent);
|
||||
@@ -362,6 +360,7 @@ namespace BitTorrent
|
||||
QHash<InfoHash, TorrentHandle *> m_torrents;
|
||||
QHash<InfoHash, AddTorrentData> m_addingTorrents;
|
||||
QHash<QString, AddTorrentParams> m_downloadedTorrents;
|
||||
TorrentStatusReport m_torrentStatusReport;
|
||||
|
||||
QMutex m_alertsMutex;
|
||||
QWaitCondition m_alertsWaitCondition;
|
||||
|
||||
Reference in New Issue
Block a user