Add stalled filters to GUI and Web API/UI

`/api/v2/torrents/info` can now take the following new values for the`filter` parameter: `stalled`, `stalled_uploading` and `stalled_downloading`.

Requires Web API version bump.

Closes #11787
This commit is contained in:
FranciscoPombal
2020-01-13 11:41:37 +00:00
committed by sledgehammer999
parent d15fdf2dde
commit 575bde1d1d
9 changed files with 69 additions and 1 deletions

View File

@@ -41,6 +41,9 @@ const TorrentFilter TorrentFilter::PausedTorrent(TorrentFilter::Paused);
const TorrentFilter TorrentFilter::ResumedTorrent(TorrentFilter::Resumed);
const TorrentFilter TorrentFilter::ActiveTorrent(TorrentFilter::Active);
const TorrentFilter TorrentFilter::InactiveTorrent(TorrentFilter::Inactive);
const TorrentFilter TorrentFilter::StalledTorrent(TorrentFilter::Stalled);
const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::StalledUploading);
const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading);
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
using BitTorrent::TorrentHandle;
@@ -95,6 +98,12 @@ bool TorrentFilter::setTypeByName(const QString &filter)
type = Active;
else if (filter == "inactive")
type = Inactive;
else if (filter == "stalled")
type = Stalled;
else if (filter == "stalled_uploading")
type = StalledUploading;
else if (filter == "stalled_downloading")
type = StalledDownloading;
else if (filter == "errored")
type = Errored;
@@ -163,6 +172,13 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c
return torrent->isActive();
case Inactive:
return torrent->isInactive();
case Stalled:
return (torrent->state() == BitTorrent::TorrentState::StalledUploading)
|| (torrent->state() == BitTorrent::TorrentState::StalledDownloading);
case StalledUploading:
return torrent->state() == BitTorrent::TorrentState::StalledUploading;
case StalledDownloading:
return torrent->state() == BitTorrent::TorrentState::StalledDownloading;
case Errored:
return torrent->isErrored();
default: // All

View File

@@ -52,6 +52,9 @@ public:
Paused,
Active,
Inactive,
Stalled,
StalledUploading,
StalledDownloading,
Errored
};
@@ -67,6 +70,9 @@ public:
static const TorrentFilter ResumedTorrent;
static const TorrentFilter ActiveTorrent;
static const TorrentFilter InactiveTorrent;
static const TorrentFilter StalledTorrent;
static const TorrentFilter StalledUploadingTorrent;
static const TorrentFilter StalledDownloadingTorrent;
static const TorrentFilter ErroredTorrent;
TorrentFilter();