fix a couple of bugs in the M.O.M and fix the options tab and file priorities in the torrent add window (success!)

This commit is contained in:
Damien Churchill 2009-10-27 10:25:16 +00:00
parent acc850dab9
commit 81949449ae
2 changed files with 15 additions and 12 deletions

View File

@ -85,7 +85,7 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
bodyStyle: 'padding: 5px;', bodyStyle: 'padding: 5px;',
border: false, border: false,
height: 170, height: 170,
disabled: true //disabled: true
}); });
var fieldset = this.form.add({ var fieldset = this.form.add({
@ -198,8 +198,6 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
form.layout = new Ext.layout.FormLayout(); form.layout = new Ext.layout.FormLayout();
form.layout.setContainer(form); form.layout.setContainer(form);
form.doLayout(); form.doLayout();
this.optionsManager.changeId(null);
}, },
addTorrent: function(torrent) { addTorrent: function(torrent) {
@ -215,9 +213,9 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
priorities[index] = fileIndexes[index]; priorities[index] = fileIndexes[index];
}); });
var oldId = this.optionsManager.changeId(torrent['info_hash'], false); var oldId = this.optionsManager.changeId(torrent['info_hash'], true);
this.optionsManager.set('file_priorities', priorities); this.optionsManager.setDefault('file_priorities', priorities);
this.optionsManager.changeId(oldId, false); this.optionsManager.changeId(oldId, true);
}, },
clear: function() { clear: function() {
@ -263,9 +261,9 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}, },
getOptions: function(torrentId) { getOptions: function(torrentId) {
var oldId = this.optionsManager.changeId(torrentId, false); var oldId = this.optionsManager.changeId(torrentId, true);
var options = this.optionsManager.get(); var options = this.optionsManager.get();
this.optionsManager.changeId(oldTorrentId, false); this.optionsManager.changeId(oldId, true);
Ext.each(options['file_priorities'], function(priority, index) { Ext.each(options['file_priorities'], function(priority, index) {
options['file_priorities'][index] = (priority) ? 1 : 0; options['file_priorities'][index] = (priority) ? 1 : 0;
}); });
@ -334,7 +332,7 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
} }
priorities[child.attributes.fileindex] = checked; priorities[child.attributes.fileindex] = checked;
}, this); }, this);
this.optionsManager.update('file_priorities', priorities); this.optionsManager.setDefault('file_priorities', priorities);
}, },
onNodeCheck: function(node, checked) { onNodeCheck: function(node, checked) {

View File

@ -48,10 +48,10 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* Changes bound fields to use the specified id. * Changes bound fields to use the specified id.
* @param {String} id * @param {String} id
*/ */
changeId: function(id, updateBinds) { changeId: function(id, dontUpdateBinds) {
var oldId = this.currentId; var oldId = this.currentId;
this.currentId = id; this.currentId = id;
if (updateBinds) { if (!dontUpdateBinds) {
for (var option in this.options) { for (var option in this.options) {
if (!this.binds[option]) continue; if (!this.binds[option]) continue;
Ext.each(this.binds[option], function(bind) { Ext.each(this.binds[option], function(bind) {
@ -80,10 +80,15 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
if (arguments.length == 1) { if (arguments.length == 1) {
var option = arguments[0]; var option = arguments[0];
return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
} else if (arguments.length == 0) {
var options = {};
for (var option in this.options) {
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
}
return options;
} else { } else {
var options = {}; var options = {};
Ext.each(arguments, function(option) { Ext.each(arguments, function(option) {
if (!this.has(option)) return;
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
}, this); }, this);
return options; return options;