1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-02-05 11:24:15 +00:00

Use switch() statement

This commit is contained in:
Chocobo1 2022-07-14 16:50:15 +08:00
parent b6b0b54cdb
commit bafe4e909c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -838,47 +838,80 @@ bool TorrentImpl::isChecking() const
bool TorrentImpl::isDownloading() const bool TorrentImpl::isDownloading() const
{ {
return m_state == TorrentState::Downloading switch (m_state)
|| m_state == TorrentState::DownloadingMetadata {
|| m_state == TorrentState::ForcedDownloadingMetadata case TorrentState::Downloading:
|| m_state == TorrentState::StalledDownloading case TorrentState::DownloadingMetadata:
|| m_state == TorrentState::CheckingDownloading case TorrentState::ForcedDownloadingMetadata:
|| m_state == TorrentState::PausedDownloading case TorrentState::StalledDownloading:
|| m_state == TorrentState::QueuedDownloading case TorrentState::CheckingDownloading:
|| m_state == TorrentState::ForcedDownloading; case TorrentState::PausedDownloading:
case TorrentState::QueuedDownloading:
case TorrentState::ForcedDownloading:
return true;
default:
break;
};
return false;
} }
bool TorrentImpl::isUploading() const bool TorrentImpl::isUploading() const
{ {
return m_state == TorrentState::Uploading switch (m_state)
|| m_state == TorrentState::StalledUploading {
|| m_state == TorrentState::CheckingUploading case TorrentState::Uploading:
|| m_state == TorrentState::QueuedUploading case TorrentState::StalledUploading:
|| m_state == TorrentState::ForcedUploading; case TorrentState::CheckingUploading:
case TorrentState::QueuedUploading:
case TorrentState::ForcedUploading:
return true;
default:
break;
};
return false;
} }
bool TorrentImpl::isCompleted() const bool TorrentImpl::isCompleted() const
{ {
return m_state == TorrentState::Uploading switch (m_state)
|| m_state == TorrentState::StalledUploading {
|| m_state == TorrentState::CheckingUploading case TorrentState::Uploading:
|| m_state == TorrentState::PausedUploading case TorrentState::StalledUploading:
|| m_state == TorrentState::QueuedUploading case TorrentState::CheckingUploading:
|| m_state == TorrentState::ForcedUploading; case TorrentState::PausedUploading:
case TorrentState::QueuedUploading:
case TorrentState::ForcedUploading:
return true;
default:
break;
};
return false;
} }
bool TorrentImpl::isActive() const bool TorrentImpl::isActive() const
{ {
if (m_state == TorrentState::StalledDownloading) switch (m_state)
{
case TorrentState::StalledDownloading:
return (uploadPayloadRate() > 0); return (uploadPayloadRate() > 0);
return m_state == TorrentState::DownloadingMetadata case TorrentState::DownloadingMetadata:
|| m_state == TorrentState::ForcedDownloadingMetadata case TorrentState::ForcedDownloadingMetadata:
|| m_state == TorrentState::Downloading case TorrentState::Downloading:
|| m_state == TorrentState::ForcedDownloading case TorrentState::ForcedDownloading:
|| m_state == TorrentState::Uploading case TorrentState::Uploading:
|| m_state == TorrentState::ForcedUploading case TorrentState::ForcedUploading:
|| m_state == TorrentState::Moving; case TorrentState::Moving:
return true;
default:
break;
};
return false;
} }
bool TorrentImpl::isInactive() const bool TorrentImpl::isInactive() const
@ -888,8 +921,8 @@ bool TorrentImpl::isInactive() const
bool TorrentImpl::isErrored() const bool TorrentImpl::isErrored() const
{ {
return m_state == TorrentState::MissingFiles return ((m_state == TorrentState::MissingFiles)
|| m_state == TorrentState::Error; || (m_state == TorrentState::Error));
} }
bool TorrentImpl::isSeed() const bool TorrentImpl::isSeed() const