mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +00:00
fire only one event per check, pass an array of nodes
implement #1161 for the webui
This commit is contained in:
parent
91f44c2ad3
commit
8414b9cfa9
2 changed files with 40 additions and 33 deletions
|
@ -84,18 +84,24 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
|||
});
|
||||
},
|
||||
|
||||
setDownload: function(node, value) {
|
||||
setDownload: function(node, value, suppress) {
|
||||
node.attributes.download = value;
|
||||
node.ui.updateColumns();
|
||||
|
||||
if (node.isLeaf()) {
|
||||
return this.fireEvent('filechecked', node, value, !value);
|
||||
if (!suppress) {
|
||||
return this.fireEvent('fileschecked', [node], value, !value);
|
||||
}
|
||||
} else {
|
||||
var nodes = [node];
|
||||
node.cascade(function(n) {
|
||||
n.attributes.download = value;
|
||||
n.ui.updateColumns();
|
||||
return this.fireEvent('filechecked', n, value, !value);
|
||||
nodes.push(n);
|
||||
}, this);
|
||||
if (!suppress) {
|
||||
return this.fireEvent('fileschecked', nodes, value, !value);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
this.files = this.add(new Deluge.add.FilesTab());
|
||||
this.form = this.add(new Deluge.add.OptionsTab());
|
||||
|
||||
this.files.on('filechecked', this.onFileChecked, this);
|
||||
this.files.on('fileschecked', this.onFilesChecked, this);
|
||||
},
|
||||
|
||||
addTorrent: function(torrent) {
|
||||
|
@ -125,34 +125,35 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
}
|
||||
},
|
||||
|
||||
onFileChecked: function(node, newValue, oldValue) {
|
||||
if (!Ext.isNumber(node.attributes.fileindex)) return;
|
||||
|
||||
// if (this.form.optionsManager.get('compact_allocation')) {
|
||||
// Ext.Msg.show({
|
||||
// title: _('Unable to set file priority!'),
|
||||
// msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
||||
// buttons: Ext.Msg.YESNO,
|
||||
// fn: function(result) {
|
||||
// if (result == 'yes') {
|
||||
// var priorities = this.form.optionsManager.get('file_priorities');
|
||||
// priorities[node.attributes.fileindex] = (result) ? newValue : oldValue;
|
||||
// this.form.optionsManager.update('file_priorities', priorities);
|
||||
// } else {
|
||||
// node.attributes.download = oldValue;
|
||||
// node.ui.updateColumns();
|
||||
// }
|
||||
// },
|
||||
// scope: this,
|
||||
// icon: Ext.MessageBox.QUESTION
|
||||
// });
|
||||
// } else {
|
||||
// var priorities = this.form.optionsManager.get('file_priorities');
|
||||
// priorities[node.attributes.fileindex] = newValue;
|
||||
// this.form.optionsManager.update('file_priorities', priorities);
|
||||
// }
|
||||
var priorities = this.form.optionsManager.get('file_priorities');
|
||||
priorities[node.attributes.fileindex] = newValue;
|
||||
this.form.optionsManager.update('file_priorities', priorities);
|
||||
onFilesChecked: function(nodes, newValue, oldValue) {
|
||||
if (this.form.optionsManager.get('compact_allocation')) {
|
||||
Ext.Msg.show({
|
||||
title: _('Unable to set file priority!'),
|
||||
msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
||||
buttons: Ext.Msg.YESNO,
|
||||
fn: function(result) {
|
||||
if (result == 'yes') {
|
||||
this.form.optionsManager.update('compact_allocation', false);
|
||||
Ext.each(nodes, function(node) {
|
||||
if (node.attributes.fileindex < 0) return;
|
||||
var priorities = this.form.optionsManager.get('file_priorities');
|
||||
priorities[node.attributes.fileindex] = newValue;
|
||||
this.form.optionsManager.update('file_priorities', priorities);
|
||||
}, this);
|
||||
} else {
|
||||
this.files.setDownload(nodes[0], oldValue, true);
|
||||
}
|
||||
},
|
||||
scope: this,
|
||||
icon: Ext.MessageBox.QUESTION
|
||||
});
|
||||
} else {
|
||||
Ext.each(nodes, function(node) {
|
||||
if (node.attributes.fileindex < 0) return;
|
||||
var priorities = this.form.optionsManager.get('file_priorities');
|
||||
priorities[node.attributes.fileindex] = newValue;
|
||||
this.form.optionsManager.update('file_priorities', priorities);
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue