Improve TorrentModel class.

This commit is contained in:
Vladimir Golovnev (Glassez)
2015-06-07 15:03:30 +03:00
parent 7699b7ce6f
commit 64c8f61bb1
15 changed files with 576 additions and 695 deletions

View File

@@ -59,6 +59,7 @@ struct SessionPrivate
virtual void handleTorrentRatioLimitChanged(BitTorrent::TorrentHandle *const torrent) = 0;
virtual void handleTorrentSavePathChanged(BitTorrent::TorrentHandle *const torrent) = 0;
virtual void handleTorrentLabelChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldLabel) = 0;
virtual void handleTorrentMetadataReceived(BitTorrent::TorrentHandle *const torrent) = 0;
virtual void handleTorrentPaused(BitTorrent::TorrentHandle *const torrent) = 0;
virtual void handleTorrentResumed(BitTorrent::TorrentHandle *const torrent) = 0;

View File

@@ -1631,6 +1631,11 @@ void Session::handleTorrentSavePathChanged(TorrentHandle *const torrent)
emit torrentSavePathChanged(torrent);
}
void Session::handleTorrentLabelChanged(TorrentHandle *const torrent, const QString &oldLabel)
{
emit torrentLabelChanged(torrent, oldLabel);
}
void Session::handleTorrentTrackersAdded(TorrentHandle *const torrent, const QList<TrackerEntry> &newTrackers)
{
foreach (const TrackerEntry &newTracker, newTrackers)

View File

@@ -195,6 +195,7 @@ namespace BitTorrent
void torrentFinished(BitTorrent::TorrentHandle *const torrent);
void torrentFinishedChecking(BitTorrent::TorrentHandle *const torrent);
void torrentSavePathChanged(BitTorrent::TorrentHandle *const torrent);
void torrentLabelChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldLabel);
void allTorrentsFinished();
void metadataLoaded(const BitTorrent::TorrentInfo &info);
void torrentMetadataLoaded(BitTorrent::TorrentHandle *const torrent);
@@ -289,6 +290,7 @@ namespace BitTorrent
QString tempPath() const;
void handleTorrentRatioLimitChanged(TorrentHandle *const torrent);
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
void handleTorrentLabelChanged(TorrentHandle *const torrent, const QString &oldLabel);
void handleTorrentMetadataReceived(TorrentHandle *const torrent);
void handleTorrentPaused(TorrentHandle *const torrent);
void handleTorrentResumed(TorrentHandle *const torrent);

View File

@@ -969,6 +969,14 @@ int TorrentHandle::timeSinceDownload() const
return m_nativeStatus.time_since_download;
}
int TorrentHandle::timeSinceActivity() const
{
if (m_nativeStatus.time_since_upload < m_nativeStatus.time_since_download)
return m_nativeStatus.time_since_upload;
else
return m_nativeStatus.time_since_download;
}
int TorrentHandle::downloadLimit() const
{
SAFE_RETURN(int, download_limit, -1)
@@ -1117,9 +1125,11 @@ void TorrentHandle::setName(const QString &name)
void TorrentHandle::setLabel(const QString &label)
{
if (m_label != label) {
QString oldLabel = m_label;
m_label = label;
m_needSaveResumeData = true;
adjustSavePath();
m_session->handleTorrentLabelChanged(this, oldLabel);
}
}

View File

@@ -241,6 +241,7 @@ namespace BitTorrent
QDateTime completedTime() const;
int timeSinceUpload() const;
int timeSinceDownload() const;
int timeSinceActivity() const;
int downloadLimit() const;
int uploadLimit() const;
bool superSeeding() const;