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

2
src/webui/qtorrentfilter.h

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

2
src/webui/webapplication.cpp

@ -213,7 +213,7 @@ void WebApplication::action_public_images() @@ -213,7 +213,7 @@ void WebApplication::action_public_images()
}
// 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")
// - sort (string): name of column for sorting by its value
// - reverse (bool): enable reverse sorting

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

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
<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="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="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>

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

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

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

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

Loading…
Cancel
Save