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

View file

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

View file

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

View file

@ -258,9 +258,11 @@ QString TransferListDelegate::getStatusString(const int state) const
case BitTorrent::TorrentState::CheckingUploading: case BitTorrent::TorrentState::CheckingUploading:
str = tr("Checking", "Torrent local data is being checked"); str = tr("Checking", "Torrent local data is being checked");
break; break;
#if LIBTORRENT_VERSION_NUM < 10100
case BitTorrent::TorrentState::QueuedForChecking: case BitTorrent::TorrentState::QueuedForChecking:
str = tr("Queued for checking", "i.e. torrent is queued for hash checking"); str = tr("Queued for checking", "i.e. torrent is queued for hash checking");
break; break;
#endif
case BitTorrent::TorrentState::CheckingResumeData: 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."); 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; break;