mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +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.attributes.download = value;
|
||||||
node.ui.updateColumns();
|
node.ui.updateColumns();
|
||||||
|
|
||||||
if (node.isLeaf()) {
|
if (node.isLeaf()) {
|
||||||
return this.fireEvent('filechecked', node, value, !value);
|
if (!suppress) {
|
||||||
|
return this.fireEvent('fileschecked', [node], value, !value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var nodes = [node];
|
||||||
node.cascade(function(n) {
|
node.cascade(function(n) {
|
||||||
n.attributes.download = value;
|
n.attributes.download = value;
|
||||||
n.ui.updateColumns();
|
n.ui.updateColumns();
|
||||||
return this.fireEvent('filechecked', n, value, !value);
|
nodes.push(n);
|
||||||
}, this);
|
}, 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.files = this.add(new Deluge.add.FilesTab());
|
||||||
this.form = this.add(new Deluge.add.OptionsTab());
|
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) {
|
addTorrent: function(torrent) {
|
||||||
|
@ -125,34 +125,35 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFileChecked: function(node, newValue, oldValue) {
|
onFilesChecked: function(nodes, newValue, oldValue) {
|
||||||
if (!Ext.isNumber(node.attributes.fileindex)) return;
|
if (this.form.optionsManager.get('compact_allocation')) {
|
||||||
|
Ext.Msg.show({
|
||||||
// if (this.form.optionsManager.get('compact_allocation')) {
|
title: _('Unable to set file priority!'),
|
||||||
// Ext.Msg.show({
|
msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
||||||
// title: _('Unable to set file priority!'),
|
buttons: Ext.Msg.YESNO,
|
||||||
// msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
fn: function(result) {
|
||||||
// buttons: Ext.Msg.YESNO,
|
if (result == 'yes') {
|
||||||
// fn: function(result) {
|
this.form.optionsManager.update('compact_allocation', false);
|
||||||
// if (result == 'yes') {
|
Ext.each(nodes, function(node) {
|
||||||
// var priorities = this.form.optionsManager.get('file_priorities');
|
if (node.attributes.fileindex < 0) return;
|
||||||
// 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');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
priorities[node.attributes.fileindex] = newValue;
|
priorities[node.attributes.fileindex] = newValue;
|
||||||
this.form.optionsManager.update('file_priorities', priorities);
|
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
Add a link
Reference in a new issue