Browse Source

Add filter "Checking" to side panel (#15166)

adaptive-webui-19844
AbeniMatteo 4 years ago committed by GitHub
parent
commit
e5943b64c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/base/torrentfilter.cpp
  2. 2
      src/base/torrentfilter.h
  3. 7
      src/gui/transferlistfilterswidget.cpp
  4. 2
      src/webui/www/private/scripts/client.js
  5. 4
      src/webui/www/private/scripts/dynamicTable.js
  6. 1
      src/webui/www/private/views/filters.html

7
src/base/torrentfilter.cpp

@ -45,6 +45,7 @@ const TorrentFilter TorrentFilter::InactiveTorrent(TorrentFilter::Inactive); @@ -45,6 +45,7 @@ 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::CheckingTorrent(TorrentFilter::Checking);
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
using BitTorrent::Torrent;
@ -101,6 +102,8 @@ bool TorrentFilter::setTypeByName(const QString &filter) @@ -101,6 +102,8 @@ bool TorrentFilter::setTypeByName(const QString &filter)
type = StalledUploading;
else if (filter == "stalled_downloading")
type = StalledDownloading;
else if (filter == "checking")
type = Checking;
else if (filter == "errored")
type = Errored;
@ -180,6 +183,10 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const @@ -180,6 +183,10 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
return torrent->state() == BitTorrent::TorrentState::StalledUploading;
case StalledDownloading:
return torrent->state() == BitTorrent::TorrentState::StalledDownloading;
case Checking:
return (torrent->state() == BitTorrent::TorrentState::CheckingUploading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingDownloading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingResumeData);
case Errored:
return torrent->isErrored();
default: // All

2
src/base/torrentfilter.h

@ -56,6 +56,7 @@ public: @@ -56,6 +56,7 @@ public:
Stalled,
StalledUploading,
StalledDownloading,
Checking,
Errored
};
@ -74,6 +75,7 @@ public: @@ -74,6 +75,7 @@ public:
static const TorrentFilter StalledTorrent;
static const TorrentFilter StalledUploadingTorrent;
static const TorrentFilter StalledDownloadingTorrent;
static const TorrentFilter CheckingTorrent;
static const TorrentFilter ErroredTorrent;
TorrentFilter() = default;

7
src/gui/transferlistfilterswidget.cpp

@ -212,6 +212,9 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran @@ -212,6 +212,9 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
auto *stalledDownloading = new QListWidgetItem(this);
stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)"));
stalledDownloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("stalledDL")));
auto *checking = new QListWidgetItem(this);
checking->setData(Qt::DisplayRole, tr("Checking (0)"));
checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("checking")));
auto *errored = new QListWidgetItem(this);
errored->setData(Qt::DisplayRole, tr("Errored (0)"));
errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("error")));
@ -238,6 +241,7 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -238,6 +241,7 @@ void StatusFilterWidget::updateTorrentNumbers()
int nbStalled = 0;
int nbStalledUploading = 0;
int nbStalledDownloading = 0;
int nbChecking = 0;
int nbErrored = 0;
const QVector<BitTorrent::Torrent *> torrents = BitTorrent::Session::instance()->torrents();
@ -261,6 +265,8 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -261,6 +265,8 @@ void StatusFilterWidget::updateTorrentNumbers()
++nbStalledUploading;
if (torrent->state() == BitTorrent::TorrentState::StalledDownloading)
++nbStalledDownloading;
if (torrent->isChecking())
++nbChecking;
if (torrent->isErrored())
++nbErrored;
}
@ -278,6 +284,7 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -278,6 +284,7 @@ void StatusFilterWidget::updateTorrentNumbers()
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::Checking)->setData(Qt::DisplayRole, tr("Checking (%1)").arg(nbChecking));
item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(nbErrored));
}

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

@ -225,6 +225,7 @@ window.addEvent('load', function() { @@ -225,6 +225,7 @@ window.addEvent('load', function() {
$("stalled_filter").removeClass("selectedFilter");
$("stalled_uploading_filter").removeClass("selectedFilter");
$("stalled_downloading_filter").removeClass("selectedFilter");
$("checking_filter").removeClass("selectedFilter");
$("errored_filter").removeClass("selectedFilter");
$(f + "_filter").addClass("selectedFilter");
selected_filter = f;
@ -383,6 +384,7 @@ window.addEvent('load', function() { @@ -383,6 +384,7 @@ window.addEvent('load', function() {
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('checking', 'QBT_TR(Checking (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
};

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

@ -1314,6 +1314,10 @@ window.qBittorrent.DynamicTable = (function() { @@ -1314,6 +1314,10 @@ window.qBittorrent.DynamicTable = (function() {
if (r == inactive)
return false;
break;
case 'checking':
if (state !== 'checkingUP' && state !== 'checkingDL' && state !== 'checkingResumeData')
return false;
break;
case 'errored':
if (state != 'error' && state != "unknown" && state != "missingFiles")
return false;

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

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
<li id="stalled_filter"><a href="#" onclick="setFilter('stalled');return false;"><img src="icons/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="icons/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="icons/stalledDL.svg" alt="Stalled Downloading" />QBT_TR(Stalled Downloading (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="checking_filter"><a href="#" onclick="setFilter('checking'); return false;"><img src="icons/checking.svg" alt="Checking" />QBT_TR(Checking (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
<li id="errored_filter"><a href="#" onclick="setFilter('errored');return false;"><img src="icons/error.svg" alt="Errored" />QBT_TR(Errored (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
</ul>
</div>

Loading…
Cancel
Save