Browse Source

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
adaptive-webui-19844
FranciscoPombal 5 years ago
parent
commit
f4742a98c5
  1. 16
      src/base/torrentfilter.cpp
  2. 6
      src/base/torrentfilter.h
  3. 21
      src/gui/transferlistfilterswidget.cpp
  4. 1
      src/icons/icons.qrc
  5. 3
      src/icons/skin/filterstalled.svg
  6. 2
      src/webui/api/torrentscontroller.cpp
  7. 6
      src/webui/www/private/scripts/client.js
  8. 12
      src/webui/www/private/scripts/dynamicTable.js
  9. 3
      src/webui/www/private/views/filters.html

16
src/base/torrentfilter.cpp

@ -41,6 +41,9 @@ const TorrentFilter TorrentFilter::PausedTorrent(TorrentFilter::Paused); @@ -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) @@ -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 @@ -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

6
src/base/torrentfilter.h

@ -52,6 +52,9 @@ public: @@ -52,6 +52,9 @@ public:
Paused,
Active,
Inactive,
Stalled,
StalledUploading,
StalledDownloading,
Errored
};
@ -67,6 +70,9 @@ public: @@ -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();

21
src/gui/transferlistfilterswidget.cpp

@ -186,6 +186,15 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran @@ -186,6 +186,15 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
auto *inactive = new QListWidgetItem(this);
inactive->setData(Qt::DisplayRole, tr("Inactive (0)"));
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.svg"));
auto *stalled = new QListWidgetItem(this);
stalled->setData(Qt::DisplayRole, tr("Stalled (0)"));
stalled->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterstalled.svg"));
auto *stalledUploading = new QListWidgetItem(this);
stalledUploading->setData(Qt::DisplayRole, tr("Stalled Uploading (0)"));
stalledUploading->setData(Qt::DecorationRole, QIcon(":/icons/skin/stalledUP.svg"));
auto *stalledDownloading = new QListWidgetItem(this);
stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)"));
stalledDownloading->setData(Qt::DecorationRole, QIcon(":/icons/skin/stalledDL.svg"));
auto *errored = new QListWidgetItem(this);
errored->setData(Qt::DisplayRole, tr("Errored (0)"));
errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.svg"));
@ -209,6 +218,9 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -209,6 +218,9 @@ void StatusFilterWidget::updateTorrentNumbers()
int nbPaused = 0;
int nbActive = 0;
int nbInactive = 0;
int nbStalled = 0;
int nbStalledUploading = 0;
int nbStalledDownloading = 0;
int nbErrored = 0;
const QHash<BitTorrent::InfoHash, BitTorrent::TorrentHandle *> torrents = BitTorrent::Session::instance()->torrents();
@ -227,10 +239,16 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -227,10 +239,16 @@ void StatusFilterWidget::updateTorrentNumbers()
++nbActive;
if (torrent->isInactive())
++nbInactive;
if (torrent->state() == BitTorrent::TorrentState::StalledUploading)
++nbStalledUploading;
if (torrent->state() == BitTorrent::TorrentState::StalledDownloading)
++nbStalledDownloading;
if (torrent->isErrored())
++nbErrored;
}
nbStalled = nbStalledUploading + nbStalledDownloading;
item(TorrentFilter::All)->setData(Qt::DisplayRole, tr("All (%1)").arg(torrents.count()));
item(TorrentFilter::Downloading)->setData(Qt::DisplayRole, tr("Downloading (%1)").arg(nbDownloading));
item(TorrentFilter::Seeding)->setData(Qt::DisplayRole, tr("Seeding (%1)").arg(nbSeeding));
@ -239,6 +257,9 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -239,6 +257,9 @@ void StatusFilterWidget::updateTorrentNumbers()
item(TorrentFilter::Paused)->setData(Qt::DisplayRole, tr("Paused (%1)").arg(nbPaused));
item(TorrentFilter::Active)->setData(Qt::DisplayRole, tr("Active (%1)").arg(nbActive));
item(TorrentFilter::Inactive)->setData(Qt::DisplayRole, tr("Inactive (%1)").arg(nbInactive));
item(TorrentFilter::Stalled)->setData(Qt::DisplayRole, tr("Stalled (%1)").arg(nbStalled));
item(TorrentFilter::StalledUploading)->setData(Qt::DisplayRole, tr("Stalled Uploading (%1)").arg(nbStalledUploading));
item(TorrentFilter::StalledDownloading)->setData(Qt::DisplayRole, tr("Stalled Downloading (%1)").arg(nbStalledDownloading));
item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(nbErrored));
}

1
src/icons/icons.qrc

@ -349,6 +349,7 @@ @@ -349,6 +349,7 @@
<file>skin/filteractive.svg</file>
<file>skin/filterall.svg</file>
<file>skin/filterinactive.svg</file>
<file>skin/filterstalled.svg</file>
<file>skin/firewalled.svg</file>
<file>skin/handle-icon-horizontal.gif</file>
<file>skin/handle-icon.gif</file>

3
src/icons/skin/filterstalled.svg

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.781139 25.6" width="21.781" height="25.6">
<path d="M21.5 3.7l-7.6 7.5v11.4c0 .5-.2.7-.6.9-.1.1-.3.1-.4.1-.3 0-.6-.1-.7-.3l-4-4c-.2-.2-.3-.5-.3-.7v-7.5L.4 3.7C0 3.3-.1 2.9.1 2.6.3 2.2.6 2 1 2h19.7c.5 0 .7.3.9.6.3.4.2.7-.1 1.1z" fill="#686868"/>
</svg>

After

Width:  |  Height:  |  Size: 310 B

2
src/webui/api/torrentscontroller.cpp

@ -231,7 +231,7 @@ namespace @@ -231,7 +231,7 @@ namespace
// - "force_start": Torrent force start state
// - "category": Torrent category
// GET params:
// - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive
// - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive, stalled, stalled_uploading, stalled_downloading
// - category (string): torrent category for filtering by it (empty string means "uncategorized"; no "category" param presented means "any category")
// - hashes (string): filter by hashes, can contain multiple hashes separated by |
// - sort (string): name of column for sorting by its value

6
src/webui/www/private/scripts/client.js

@ -184,6 +184,9 @@ window.addEvent('load', function() { @@ -184,6 +184,9 @@ window.addEvent('load', function() {
$("resumed_filter").removeClass("selectedFilter");
$("active_filter").removeClass("selectedFilter");
$("inactive_filter").removeClass("selectedFilter");
$("stalled_filter").removeClass("selectedFilter");
$("stalled_uploading_filter").removeClass("selectedFilter");
$("stalled_downloading_filter").removeClass("selectedFilter");
$("errored_filter").removeClass("selectedFilter");
$(f + "_filter").addClass("selectedFilter");
selected_filter = f;
@ -344,6 +347,9 @@ window.addEvent('load', function() { @@ -344,6 +347,9 @@ window.addEvent('load', function() {
updateFilter('paused', 'QBT_TR(Paused (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('active', 'QBT_TR(Active (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('inactive', 'QBT_TR(Inactive (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('stalled', 'QBT_TR(Stalled (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('stalled_uploading', 'QBT_TR(Stalled Uploading (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('stalled_downloading', 'QBT_TR(Stalled Downloading (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
};

12
src/webui/www/private/scripts/dynamicTable.js

@ -1225,6 +1225,18 @@ window.qBittorrent.DynamicTable = (function() { @@ -1225,6 +1225,18 @@ window.qBittorrent.DynamicTable = (function() {
if (~state.indexOf('paused'))
return false;
break;
case 'stalled':
if ((state != 'stalledUP') && (state != 'stalledDL'))
return false;
break;
case 'stalled_uploading':
if (state != 'stalledUP')
return false;
break;
case 'stalled_downloading':
if (state != 'stalledDL')
return false;
break;
case 'inactive':
inactive = true;
// fallthrough

3
src/webui/www/private/views/filters.html

@ -11,6 +11,9 @@ @@ -11,6 +11,9 @@
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.svg" alt="Paused" />QBT_TR(Paused (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.svg" alt="Active" />QBT_TR(Active (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.svg" alt="Inactive" />QBT_TR(Inactive (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="stalled_filter"><a href="#" onclick="setFilter('stalled');return false;"><img src="images/skin/filterstalled.svg" alt="Stalled" />QBT_TR(Stalled (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="stalled_uploading_filter"><a href="#" onclick="setFilter('stalled_uploading');return false;"><img src="images/skin/stalledUP.svg" alt="Stalled Uploading" />QBT_TR(Stalled Uploading (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="stalled_downloading_filter"><a href="#" onclick="setFilter('stalled_downloading');return false;"><img src="images/skin/stalledDL.svg" alt="Stalled Downloading" />QBT_TR(Stalled Downloading (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="errored_filter"><a href="#" onclick="setFilter('errored');return false;"><img src="images/skin/error.svg" alt="Errored" />QBT_TR(Errored (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
</ul>
</div>

Loading…
Cancel
Save