mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #4282 from buinsky/master
WebUI: Show filtered torrents number
This commit is contained in:
commit
719e71264b
@ -241,7 +241,7 @@ void AbstractWebApplication::translateDocument(QString& data)
|
|||||||
"HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel",
|
"HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel",
|
||||||
"options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel",
|
"options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel",
|
||||||
"PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc",
|
"PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc",
|
||||||
"StatusBar", "AboutDlg", "about", "PeerListWidget"
|
"StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget"
|
||||||
};
|
};
|
||||||
const size_t context_count = sizeof(contexts) / sizeof(contexts[0]);
|
const size_t context_count = sizeof(contexts) / sizeof(contexts[0]);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
QBT_TR(Torrents)QBT_TR
|
QBT_TR(Torrents)QBT_TR
|
||||||
<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 (0))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 (0))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="seeding_filter"><a href="#" onclick="setFilter('seeding');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Seeding (0))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="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/completed.png"/>QBT_TR(Completed (0))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 (0))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 (0))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 (0))QBT_TR</a></li>
|
||||||
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive)QBT_TR</a></li>
|
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive (0))QBT_TR</a></li>
|
||||||
|
<li id="errored_filter"><a href="#" onclick="setFilter('errored');return false;"><img src="images/skin/error.png"/>QBT_TR(Errored (0))QBT_TR</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<br/>
|
<br/>
|
||||||
QBT_TR(Labels)QBT_TR
|
QBT_TR(Labels)QBT_TR
|
||||||
|
@ -115,6 +115,7 @@ window.addEvent('load', function () {
|
|||||||
$("resumed_filter").removeClass("selectedFilter");
|
$("resumed_filter").removeClass("selectedFilter");
|
||||||
$("active_filter").removeClass("selectedFilter");
|
$("active_filter").removeClass("selectedFilter");
|
||||||
$("inactive_filter").removeClass("selectedFilter");
|
$("inactive_filter").removeClass("selectedFilter");
|
||||||
|
$("errored_filter").removeClass("selectedFilter");
|
||||||
$(f + "_filter").addClass("selectedFilter");
|
$(f + "_filter").addClass("selectedFilter");
|
||||||
selected_filter = f;
|
selected_filter = f;
|
||||||
localStorage.setItem('selected_filter', f);
|
localStorage.setItem('selected_filter', f);
|
||||||
@ -219,6 +220,22 @@ window.addEvent('load', function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var updateFilter = function(filter, filterTitle) {
|
||||||
|
$(filter + '_filter').firstChild.childNodes[1].nodeValue = filterTitle.replace('%1', torrentsTable.getFilteredTorrentsNumber(filter));
|
||||||
|
};
|
||||||
|
|
||||||
|
var updateFiltersList = function() {
|
||||||
|
updateFilter('all', 'QBT_TR(All (%1))QBT_TR');
|
||||||
|
updateFilter('downloading', 'QBT_TR(Downloading (%1))QBT_TR');
|
||||||
|
updateFilter('seeding', 'QBT_TR(Seeding (%1))QBT_TR');
|
||||||
|
updateFilter('completed', 'QBT_TR(Completed (%1))QBT_TR');
|
||||||
|
updateFilter('resumed', 'QBT_TR(Resumed (%1))QBT_TR');
|
||||||
|
updateFilter('paused', 'QBT_TR(Paused (%1))QBT_TR');
|
||||||
|
updateFilter('active', 'QBT_TR(Active (%1))QBT_TR');
|
||||||
|
updateFilter('inactive', 'QBT_TR(Inactive (%1))QBT_TR');
|
||||||
|
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR');
|
||||||
|
};
|
||||||
|
|
||||||
var updateLabelList = function() {
|
var updateLabelList = function() {
|
||||||
var labelList = $('filterLabelList');
|
var labelList = $('filterLabelList');
|
||||||
if (!labelList)
|
if (!labelList)
|
||||||
@ -331,6 +348,7 @@ window.addEvent('load', function () {
|
|||||||
serverState[key] = tmp[key];
|
serverState[key] = tmp[key];
|
||||||
processServerState();
|
processServerState();
|
||||||
}
|
}
|
||||||
|
updateFiltersList();
|
||||||
if (update_labels) {
|
if (update_labels) {
|
||||||
updateLabelList();
|
updateLabelList();
|
||||||
updateContextMenu();
|
updateContextMenu();
|
||||||
|
@ -480,7 +480,7 @@ var TorrentsTable = new Class({
|
|||||||
else if (state == "checkingDL" || state == "checkingUP" ||
|
else if (state == "checkingDL" || state == "checkingUP" ||
|
||||||
state == "queuedForChecking" || state == "checkingResumeData")
|
state == "queuedForChecking" || state == "checkingResumeData")
|
||||||
state = "checking";
|
state = "checking";
|
||||||
else if (state == "unknown")
|
else if (state == "unknown" || state == "error" || state == "missingFiles")
|
||||||
state = "error";
|
state = "error";
|
||||||
|
|
||||||
var img_path = 'images/skin/' + state + '.png';
|
var img_path = 'images/skin/' + state + '.png';
|
||||||
@ -616,6 +616,9 @@ var TorrentsTable = new Class({
|
|||||||
|
|
||||||
applyFilter : function (row, filterName, labelName) {
|
applyFilter : function (row, filterName, labelName) {
|
||||||
var state = row['full_data'].state;
|
var state = row['full_data'].state;
|
||||||
|
var inactive = false;
|
||||||
|
var r;
|
||||||
|
|
||||||
switch(filterName) {
|
switch(filterName) {
|
||||||
case 'downloading':
|
case 'downloading':
|
||||||
if (state != 'downloading' && !~state.indexOf('DL'))
|
if (state != 'downloading' && !~state.indexOf('DL'))
|
||||||
@ -630,19 +633,25 @@ var TorrentsTable = new Class({
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'paused':
|
case 'paused':
|
||||||
if (state != 'pausedDL')
|
if (!~state.indexOf('paused'))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'resumed':
|
case 'resumed':
|
||||||
if (~state.indexOf('paused'))
|
if (~state.indexOf('paused'))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
case 'inactive':
|
||||||
|
inactive = true;
|
||||||
case 'active':
|
case 'active':
|
||||||
if (state != 'downloading' && state != 'forcedDL' && state != 'uploading' && state != 'forcedUP')
|
if (state == 'stalledDL')
|
||||||
|
r = (row['full_data'].upspeed > 0)
|
||||||
|
else
|
||||||
|
r = state == 'metaDL' || state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP';
|
||||||
|
if (r == inactive)
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'inactive':
|
case 'errored':
|
||||||
if (state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP')
|
if (state != 'error' && state != "unknown" && state != "missingFiles")
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -659,6 +668,16 @@ var TorrentsTable = new Class({
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getFilteredTorrentsNumber : function (filterName) {
|
||||||
|
var cnt = 0;
|
||||||
|
var rows = this.rows.getValues();
|
||||||
|
|
||||||
|
for (i = 0; i < rows.length; i++)
|
||||||
|
if (this.applyFilter(rows[i], filterName, LABELS_ALL)) cnt++;
|
||||||
|
|
||||||
|
return cnt;
|
||||||
|
},
|
||||||
|
|
||||||
getFilteredAndSortedRows : function () {
|
getFilteredAndSortedRows : function () {
|
||||||
var filteredRows = new Array();
|
var filteredRows = new Array();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user