Browse Source

Merge pull request #2797 from pmzqla/completed-status

WebUI: Implement a 'Completed' status
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
75e1101321
  1. 17
      src/webui/qtorrentfilter.cpp
  2. 2
      src/webui/qtorrentfilter.h
  3. 2
      src/webui/webapplication.cpp
  4. 3
      src/webui/www/public/filters.html
  5. 1
      src/webui/www/public/scripts/client.js
  6. 6
      src/webui/www/public/scripts/dynamicTable.js

17
src/webui/qtorrentfilter.cpp

@ -35,6 +35,8 @@ QTorrentFilter::QTorrentFilter(QString filter, QString label)
{ {
if (filter == "downloading") if (filter == "downloading")
type_ = Downloading; type_ = Downloading;
else if (filter == "seeding")
type_ = Seeding;
else if (filter == "completed") else if (filter == "completed")
type_ = Completed; type_ = Completed;
else if (filter == "paused") else if (filter == "paused")
@ -55,6 +57,8 @@ bool QTorrentFilter::apply(const QTorrentHandle& h) const
switch (type_) { switch (type_) {
case Downloading: case Downloading:
return isTorrentDownloading(h); return isTorrentDownloading(h);
case Seeding:
return isTorrentSeeding(h);
case Completed: case Completed:
return isTorrentCompleted(h); return isTorrentCompleted(h);
case Paused: case Paused:
@ -82,6 +86,16 @@ bool QTorrentFilter::isTorrentDownloading(const QTorrentHandle &h) const
|| state == QTorrentState::Error; || state == QTorrentState::Error;
} }
bool QTorrentFilter::isTorrentSeeding(const QTorrentHandle &h) const
{
const QTorrentState state = h.torrentState();
return state == QTorrentState::Uploading
|| state == QTorrentState::StalledUploading
|| state == QTorrentState::CheckingUploading
|| state == QTorrentState::QueuedUploading;
}
bool QTorrentFilter::isTorrentCompleted(const QTorrentHandle &h) const bool QTorrentFilter::isTorrentCompleted(const QTorrentHandle &h) const
{ {
const QTorrentState state = h.torrentState(); const QTorrentState state = h.torrentState();
@ -97,8 +111,7 @@ bool QTorrentFilter::isTorrentPaused(const QTorrentHandle &h) const
{ {
const QTorrentState state = h.torrentState(); const QTorrentState state = h.torrentState();
return state == QTorrentState::PausedDownloading return state == QTorrentState::PausedUploading
|| state == QTorrentState::PausedUploading
|| state == QTorrentState::Error; || state == QTorrentState::Error;
} }

2
src/webui/qtorrentfilter.h

@ -38,6 +38,7 @@ public:
{ {
All, All,
Downloading, Downloading,
Seeding,
Completed, Completed,
Paused, Paused,
Resumed, Resumed,
@ -54,6 +55,7 @@ private:
QString label_; QString label_;
bool isTorrentDownloading(const QTorrentHandle &h) const; bool isTorrentDownloading(const QTorrentHandle &h) const;
bool isTorrentSeeding(const QTorrentHandle &h) const;
bool isTorrentCompleted(const QTorrentHandle &h) const; bool isTorrentCompleted(const QTorrentHandle &h) const;
bool isTorrentPaused(const QTorrentHandle &h) const; bool isTorrentPaused(const QTorrentHandle &h) const;
bool isTorrentResumed(const QTorrentHandle &h) const; bool isTorrentResumed(const QTorrentHandle &h) const;

2
src/webui/webapplication.cpp

@ -213,7 +213,7 @@ void WebApplication::action_public_images()
} }
// GET params: // GET params:
// - filter (string): all, downloading, completed, paused, resumed, active, inactive // - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive
// - label (string): torrent label for filtering by it (empty string means "unlabeled"; no "label" param presented means "any label") // - 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 // - sort (string): name of column for sorting by its value
// - reverse (bool): enable reverse sorting // - reverse (bool): enable reverse sorting

3
src/webui/www/public/filters.html

@ -1,7 +1,8 @@
<ul class="filterList"> <ul class="filterList">
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All)QBT_TR</a></li> <li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All)QBT_TR</a></li>
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading)QBT_TR</a></li> <li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading)QBT_TR</a></li>
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Completed)QBT_TR</a></li> <li id="seeding_filter"><a href="#" onclick="setFilter('seeding');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Seeding)QBT_TR</a></li>
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/completed.png"/>QBT_TR(Completed)QBT_TR</a></li>
<li id="resumed_filter"><a href="#" onclick="setFilter('resumed');return false;"><img src="images/skin/resumed.png"/>QBT_TR(Resumed)QBT_TR</a></li> <li id="resumed_filter"><a href="#" onclick="setFilter('resumed');return false;"><img src="images/skin/resumed.png"/>QBT_TR(Resumed)QBT_TR</a></li>
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused)QBT_TR</a></li> <li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused)QBT_TR</a></li>
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active)QBT_TR</a></li> <li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active)QBT_TR</a></li>

1
src/webui/www/public/scripts/client.js

@ -95,6 +95,7 @@ window.addEvent('load', function () {
// Visually Select the right filter // Visually Select the right filter
$("all_filter").removeClass("selectedFilter"); $("all_filter").removeClass("selectedFilter");
$("downloading_filter").removeClass("selectedFilter"); $("downloading_filter").removeClass("selectedFilter");
$("seeding_filter").removeClass("selectedFilter");
$("completed_filter").removeClass("selectedFilter"); $("completed_filter").removeClass("selectedFilter");
$("paused_filter").removeClass("selectedFilter"); $("paused_filter").removeClass("selectedFilter");
$("resumed_filter").removeClass("selectedFilter"); $("resumed_filter").removeClass("selectedFilter");

6
src/webui/www/public/scripts/dynamicTable.js

@ -253,12 +253,16 @@ var dynamicTable = new Class({
if ((state != 'downloading') && !~state.indexOf('DL')) if ((state != 'downloading') && !~state.indexOf('DL'))
return false; return false;
break; break;
case 'seeding':
if ((state != 'uploading') && (state != 'stalledUP') && (state != 'queuedUP') && (state != 'checkingUP'))
return false;
break;
case 'completed': case 'completed':
if ((state != 'uploading') && !~state.indexOf('UP')) if ((state != 'uploading') && !~state.indexOf('UP'))
return false; return false;
break; break;
case 'paused': case 'paused':
if (!~state.indexOf('paused')) if (state != 'pausedDL')
return false; return false;
break; break;
case 'resumed': case 'resumed':

Loading…
Cancel
Save