From f5f9e206fb0c6cb0eb54dc15977753da85062fed Mon Sep 17 00:00:00 2001 From: buinsky Date: Thu, 29 Jan 2015 20:30:54 +0300 Subject: [PATCH] Add 'Resumed' filter --- src/webui/qtorrentfilter.cpp | 12 ++++++++++++ src/webui/qtorrentfilter.h | 2 ++ src/webui/webapplication.cpp | 2 +- src/webui/www/public/filters.html | 1 + src/webui/www/public/scripts/client.js | 1 + src/webui/www/public/scripts/dynamicTable.js | 4 ++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/webui/qtorrentfilter.cpp b/src/webui/qtorrentfilter.cpp index 46504fab5..2c4ac2f6c 100644 --- a/src/webui/qtorrentfilter.cpp +++ b/src/webui/qtorrentfilter.cpp @@ -39,6 +39,8 @@ QTorrentFilter::QTorrentFilter(QString filter, QString label) type_ = Completed; else if (filter == "paused") type_ = Paused; + else if (filter == "resumed") + type_ = Resumed; else if (filter == "active") type_ = Active; else if (filter == "inactive") @@ -57,6 +59,8 @@ bool QTorrentFilter::apply(const QTorrentHandle& h) const return isTorrentCompleted(h); case Paused: return isTorrentPaused(h); + case Resumed: + return isTorrentResumed(h); case Active: return isTorrentActive(h); case Inactive: @@ -98,6 +102,14 @@ bool QTorrentFilter::isTorrentPaused(const QTorrentHandle &h) const || state == QTorrentState::Error; } +bool QTorrentFilter::isTorrentResumed(const QTorrentHandle &h) const +{ + const QTorrentState state = h.torrentState(); + + return state != QTorrentState::PausedUploading + && state != QTorrentState::PausedDownloading; +} + bool QTorrentFilter::isTorrentActive(const QTorrentHandle &h) const { const QTorrentState state = h.torrentState(); diff --git a/src/webui/qtorrentfilter.h b/src/webui/qtorrentfilter.h index 052c9ac6a..10e2bf2c0 100644 --- a/src/webui/qtorrentfilter.h +++ b/src/webui/qtorrentfilter.h @@ -40,6 +40,7 @@ public: Downloading, Completed, Paused, + Resumed, Active, Inactive }; @@ -55,6 +56,7 @@ private: bool isTorrentDownloading(const QTorrentHandle &h) const; bool isTorrentCompleted(const QTorrentHandle &h) const; bool isTorrentPaused(const QTorrentHandle &h) const; + bool isTorrentResumed(const QTorrentHandle &h) const; bool isTorrentActive(const QTorrentHandle &h) const; bool isTorrentInactive(const QTorrentHandle &h) const; bool torrentHasLabel(const QTorrentHandle &h) const; diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index f7140e96c..79fcfb0b0 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -212,7 +212,7 @@ void WebApplication::action_public_images() } // GET params: -// - filter (string): all, downloading, completed, paused, active, inactive +// - filter (string): all, downloading, completed, paused, resumed, active, inactive // - label (string): torrent label for filtering by it (empty string means "unlabeled"; no "label" param presented means "any label") // - sort (string): name of column for sorting by its value // - reverse (bool): enable reverse sorting diff --git a/src/webui/www/public/filters.html b/src/webui/www/public/filters.html index ecc3461c3..1270f4fef 100644 --- a/src/webui/www/public/filters.html +++ b/src/webui/www/public/filters.html @@ -2,6 +2,7 @@
  • QBT_TR(All)QBT_TR
  • QBT_TR(Downloading)QBT_TR
  • QBT_TR(Completed)QBT_TR
  • +
  • QBT_TR(Resumed)QBT_TR
  • QBT_TR(Paused)QBT_TR
  • QBT_TR(Active)QBT_TR
  • QBT_TR(Inactive)QBT_TR
  • diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 4f84ea7ed..a468f4d96 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -96,6 +96,7 @@ window.addEvent('load', function () { $("downloading_filter").removeClass("selectedFilter"); $("completed_filter").removeClass("selectedFilter"); $("paused_filter").removeClass("selectedFilter"); + $("resumed_filter").removeClass("selectedFilter"); $("active_filter").removeClass("selectedFilter"); $("inactive_filter").removeClass("selectedFilter"); $(f + "_filter").addClass("selectedFilter"); diff --git a/src/webui/www/public/scripts/dynamicTable.js b/src/webui/www/public/scripts/dynamicTable.js index 9667ac371..018164d52 100644 --- a/src/webui/www/public/scripts/dynamicTable.js +++ b/src/webui/www/public/scripts/dynamicTable.js @@ -261,6 +261,10 @@ var dynamicTable = new Class({ if (!~state.indexOf('paused')) return false; break; + case 'resumed': + if (~state.indexOf('paused')) + return false; + break; case 'active': if ((state != 'uploading') && (state != 'downloading')) return false;