Don't use deprecated torrent_status fields

This commit is contained in:
Vladimir Golovnev (Glassez) 2017-05-01 19:45:08 +03:00
parent 72a54910e9
commit 5dc54aa224
4 changed files with 26 additions and 3 deletions

View file

@ -147,8 +147,10 @@ QString TorrentState::toString() const
return QLatin1String("checkingDL");
case ForcedDownloading:
return QLatin1String("forcedDL");
#if LIBTORRENT_VERSION_NUM < 10100
case QueuedForChecking:
return QLatin1String("queuedForChecking");
#endif
case CheckingResumeData:
return QLatin1String("checkingResumeData");
default:
@ -658,9 +660,12 @@ bool TorrentHandle::isQueued() const
bool TorrentHandle::isChecking() const
{
return ((m_nativeStatus.state == libt::torrent_status::queued_for_checking)
|| (m_nativeStatus.state == libt::torrent_status::checking_files)
|| (m_nativeStatus.state == libt::torrent_status::checking_resume_data));
return ((m_nativeStatus.state == libt::torrent_status::checking_files)
|| (m_nativeStatus.state == libt::torrent_status::checking_resume_data)
#if LIBTORRENT_VERSION_NUM < 10100
|| (m_nativeStatus.state == libt::torrent_status::queued_for_checking)
#endif
);
}
bool TorrentHandle::isDownloading() const
@ -799,9 +804,11 @@ void TorrentHandle::updateState()
case libt::torrent_status::allocating:
m_state = TorrentState::Allocating;
break;
#if LIBTORRENT_VERSION_NUM < 10100
case libt::torrent_status::queued_for_checking:
m_state = TorrentState::QueuedForChecking;
break;
#endif
case libt::torrent_status::checking_resume_data:
m_state = TorrentState::CheckingResumeData;
break;
@ -837,7 +844,11 @@ bool TorrentHandle::hasMissingFiles() const
bool TorrentHandle::hasError() const
{
#if LIBTORRENT_VERSION_NUM < 10100
return (m_nativeStatus.paused && !m_nativeStatus.error.empty());
#else
return (m_nativeStatus.paused && m_nativeStatus.errc);
#endif
}
bool TorrentHandle::hasFilteredPieces() const
@ -859,7 +870,11 @@ int TorrentHandle::queuePosition() const
QString TorrentHandle::error() const
{
#if LIBTORRENT_VERSION_NUM < 10100
return QString::fromStdString(m_nativeStatus.error);
#else
return QString::fromStdString(m_nativeStatus.errc.message());
#endif
}
qlonglong TorrentHandle::totalDownload() const

View file

@ -140,7 +140,9 @@ namespace BitTorrent
CheckingUploading,
CheckingDownloading,
#if LIBTORRENT_VERSION_NUM < 10100
QueuedForChecking,
#endif
CheckingResumeData,
PausedDownloading,

View file

@ -338,7 +338,9 @@ QIcon getIconByState(BitTorrent::TorrentState state)
return getQueuedIcon();
case BitTorrent::TorrentState::CheckingDownloading:
case BitTorrent::TorrentState::CheckingUploading:
#if LIBTORRENT_VERSION_NUM < 10100
case BitTorrent::TorrentState::QueuedForChecking:
#endif
case BitTorrent::TorrentState::CheckingResumeData:
return getCheckingIcon();
case BitTorrent::TorrentState::Unknown:
@ -391,7 +393,9 @@ QColor getColorByState(BitTorrent::TorrentState state)
case BitTorrent::TorrentState::QueuedUploading:
case BitTorrent::TorrentState::CheckingDownloading:
case BitTorrent::TorrentState::CheckingUploading:
#if LIBTORRENT_VERSION_NUM < 10100
case BitTorrent::TorrentState::QueuedForChecking:
#endif
case BitTorrent::TorrentState::CheckingResumeData:
if (!dark)
return QColor(0, 128, 128); // Teal

View file

@ -258,9 +258,11 @@ QString TransferListDelegate::getStatusString(const int state) const
case BitTorrent::TorrentState::CheckingUploading:
str = tr("Checking", "Torrent local data is being checked");
break;
#if LIBTORRENT_VERSION_NUM < 10100
case BitTorrent::TorrentState::QueuedForChecking:
str = tr("Queued for checking", "i.e. torrent is queued for hash checking");
break;
#endif
case BitTorrent::TorrentState::CheckingResumeData:
str = tr("Checking resume data", "used when loading the torrents from disk after qbt is launched. It checks the correctness of the .fastresume file. Normally it is completed in a fraction of a second, unless loading many many torrents.");
break;