add checkboxes to folders and change all the child checkboxes on a change
This commit is contained in:
parent
1edafe2b6c
commit
6fb180ed23
|
@ -253,6 +253,46 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
setTorrent: function(torrent) {
|
||||||
|
var self = this;
|
||||||
|
function walk(files, parent) {
|
||||||
|
for (var file in files) {
|
||||||
|
var item = files[file];
|
||||||
|
|
||||||
|
if (Ext.type(item) == 'object') {
|
||||||
|
var folder = new Ext.tree.TreeNode({
|
||||||
|
text: file,
|
||||||
|
checked: true
|
||||||
|
});
|
||||||
|
folder.on('checkchange', self.onFolderCheck, self);
|
||||||
|
parent.appendChild(folder);
|
||||||
|
walk(item, folder);
|
||||||
|
} else {
|
||||||
|
parent.appendChild(new Ext.tree.TreeNode({
|
||||||
|
filename: file,
|
||||||
|
text: file, // this needs to be here for sorting reasons
|
||||||
|
size: fsize(item[1]),
|
||||||
|
leaf: true,
|
||||||
|
checked: item[2],
|
||||||
|
iconCls: 'x-deluge-file',
|
||||||
|
uiProvider: Ext.tree.ColumnNodeUI
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clearFiles();
|
||||||
|
var root = this.files.getRootNode();
|
||||||
|
walk(torrent['files_tree'], root);
|
||||||
|
root.firstChild.expand();
|
||||||
|
},
|
||||||
|
|
||||||
|
onFolderCheck: function(node, checked) {
|
||||||
|
node.cascade(function(child) {
|
||||||
|
child.ui.checkbox.checked = checked;
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -414,36 +454,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect: function(selModel, rowIndex, record) {
|
onSelect: function(selModel, rowIndex, record) {
|
||||||
var torrentInfo = this.torrents[record.get('info_hash')];
|
this.optionsPanel.setTorrent(this.torrents[record.get('info_hash')]);
|
||||||
|
|
||||||
function walk(files, parent) {
|
|
||||||
for (var file in files) {
|
|
||||||
var item = files[file];
|
|
||||||
|
|
||||||
if (Ext.type(item) == 'object') {
|
|
||||||
var child = new Ext.tree.TreeNode({
|
|
||||||
text: file
|
|
||||||
});
|
|
||||||
parent.appendChild(child);
|
|
||||||
walk(item, child);
|
|
||||||
} else {
|
|
||||||
parent.appendChild(new Ext.tree.TreeNode({
|
|
||||||
filename: file,
|
|
||||||
text: file, // this needs to be here for sorting reasons
|
|
||||||
size: fsize(item[1]),
|
|
||||||
leaf: true,
|
|
||||||
checked: item[2],
|
|
||||||
iconCls: 'x-deluge-file',
|
|
||||||
uiProvider: Ext.tree.ColumnNodeUI
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options.clearFiles();
|
|
||||||
var root = this.options.files.getRootNode();
|
|
||||||
walk(torrentInfo['files_tree'], root);
|
|
||||||
root.firstChild.expand();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue