mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 06:02:29 -06:00
Add sequential downloading menu items
This commit is contained in:
@@ -99,14 +99,21 @@ var loadTorrentsInfo = function () {
|
||||
data[10] = event.ratio;
|
||||
if (row[2] != null)
|
||||
queueing_enabled = true;
|
||||
|
||||
attrs = {};
|
||||
attrs['downloaded'] = (event.progress == 1.0);
|
||||
attrs['state'] = event.state;
|
||||
attrs['seq_dl'] = (event.seq_dl == true);
|
||||
attrs['f_l_piece_prio'] = (event.f_l_piece_prio == true);
|
||||
|
||||
if (!torrent_hashes.contains(event.hash)) {
|
||||
// New unfinished torrent
|
||||
torrent_hashes[torrent_hashes.length] = event.hash;
|
||||
//alert("Inserting row");
|
||||
myTable.insertRow(event.hash, row, data, event.state, pos);
|
||||
myTable.insertRow(event.hash, row, data, attrs, pos);
|
||||
} else {
|
||||
// Update torrent data
|
||||
myTable.updateRow(event.hash, row, data, event.state, pos);
|
||||
myTable.updateRow(event.hash, row, data, attrs, pos);
|
||||
}
|
||||
|
||||
pos++;
|
||||
|
||||
@@ -127,9 +127,36 @@ var ContextMenu = new Class({
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
updateMenuItems: function () {
|
||||
all_are_seq_dl = true;
|
||||
all_are_f_l_piece_prio = true;
|
||||
all_are_downloaded = true;
|
||||
|
||||
var h = myTable.selectedIds();
|
||||
h.each(function(item, index){
|
||||
tr = myTable.rows.get(item);
|
||||
if (tr.getAttribute('seq_dl') != 'true')
|
||||
all_are_seq_dl = false;
|
||||
if (tr.getAttribute('f_l_piece_prio') != 'true')
|
||||
all_are_f_l_piece_prio = false;
|
||||
if (tr.getAttribute('downloaded') != 'true')
|
||||
all_are_downloaded = false;
|
||||
});
|
||||
|
||||
if (all_are_downloaded) {
|
||||
this.hideItem('SequentialDownload');
|
||||
this.hideItem('FirstLastPiecePrio');
|
||||
} else {
|
||||
this.showItem('SequentialDownload');
|
||||
this.showItem('FirstLastPiecePrio');
|
||||
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
||||
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
||||
}
|
||||
},
|
||||
|
||||
//show menu
|
||||
show: function(trigger) {
|
||||
//this.menu.fade('in');
|
||||
this.updateMenuItems();
|
||||
this.fx.start(1);
|
||||
this.fireEvent('show');
|
||||
this.shown = true;
|
||||
@@ -147,15 +174,21 @@ var ContextMenu = new Class({
|
||||
return this;
|
||||
},
|
||||
|
||||
//disable an item
|
||||
disableItem: function(item) {
|
||||
this.menu.getElements('a[href$=' + item + ']').addClass('disabled');
|
||||
setItemChecked: function(item, checked) {
|
||||
this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity =
|
||||
checked ? '1' : '0';
|
||||
return this;
|
||||
},
|
||||
|
||||
//enable an item
|
||||
enableItem: function(item) {
|
||||
this.menu.getElements('a[href$=' + item + ']').removeClass('disabled');
|
||||
//hide an item
|
||||
hideItem: function(item) {
|
||||
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
|
||||
return this;
|
||||
},
|
||||
|
||||
//show an item
|
||||
showItem: function(item) {
|
||||
this.menu.getElement('a[href$=' + item + ']').parentNode.removeClass('invisible');
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
@@ -102,11 +102,13 @@ var dynamicTable = new Class({
|
||||
this.priority_hidden = false;
|
||||
},
|
||||
|
||||
insertRow : function (id, row, data, status, pos) {
|
||||
insertRow : function (id, row, data, attrs, pos) {
|
||||
if (this.rows.has(id)) {
|
||||
return;
|
||||
}
|
||||
var tr = new Element('tr');
|
||||
for (var a in attrs)
|
||||
tr.set(a, attrs[a]);
|
||||
tr.addClass("menu-target");
|
||||
this.rows.set(id, tr);
|
||||
for (var i = 0; i < row.length; i++) {
|
||||
@@ -246,12 +248,14 @@ var dynamicTable = new Class({
|
||||
}, this);
|
||||
},
|
||||
|
||||
updateRow : function (id, row, data, status, newpos) {
|
||||
updateRow : function (id, row, data, attrs, newpos) {
|
||||
if (!this.rows.has(id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var tr = this.rows.get(id);
|
||||
for (var a in attrs)
|
||||
tr.set(a, attrs[a]);
|
||||
var tds = tr.getElements('td');
|
||||
for (var i = 0; i < row.length; i++) {
|
||||
if (i == 1)
|
||||
|
||||
@@ -134,6 +134,34 @@ initializeWindows = function() {
|
||||
}
|
||||
};
|
||||
|
||||
toggleSequentialDownloadFN = function() {
|
||||
var h = myTable.selectedIds();
|
||||
if (h.length) {
|
||||
new Request({
|
||||
url: 'command/toggleSequentialDownload',
|
||||
method: 'post',
|
||||
data: {
|
||||
hashes: h.join("|")
|
||||
}
|
||||
}).send();
|
||||
updateTransferList();
|
||||
}
|
||||
};
|
||||
|
||||
toggleFirstLastPiecePrioFN = function() {
|
||||
var h = myTable.selectedIds();
|
||||
if (h.length) {
|
||||
new Request({
|
||||
url: 'command/toggleFirstLastPiecePrio',
|
||||
method: 'post',
|
||||
data: {
|
||||
hashes: h.join("|")
|
||||
}
|
||||
}).send();
|
||||
updateTransferList();
|
||||
}
|
||||
};
|
||||
|
||||
globalDownloadLimitFN = function() {
|
||||
new MochaUI.Window({
|
||||
id: 'downloadLimitPage',
|
||||
|
||||
Reference in New Issue
Block a user