mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-26 11:21:08 +00:00
improve removing of torrents by adding a "torrentRemoved" event
This commit is contained in:
parent
71ef3f3ddc
commit
6897cd8b6b
@ -66,6 +66,7 @@ Deluge.ToolBar = {
|
||||
|
||||
switch (item.id) {
|
||||
case 'remove':
|
||||
Deluge.Events.fire('torrentRemoved', ids);
|
||||
Deluge.Client.core.remove_torrent(ids, null, {
|
||||
onSuccess: function() {
|
||||
Deluge.Ui.update();
|
||||
|
@ -56,6 +56,7 @@ Deluge.Menus = {
|
||||
});
|
||||
break;
|
||||
case 'remove':
|
||||
Deluge.Events.fire('torrentRemoved', ids);
|
||||
Deluge.Client.core.remove_torrent(ids, null, {
|
||||
onSuccess: function() {
|
||||
Deluge.Ui.update();
|
||||
|
@ -105,6 +105,22 @@ Deluge.Torrents = {
|
||||
|
||||
getSelections: function() {
|
||||
return this.Grid.getSelectionModel().getSelections();
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved.bindWithEvent(this));
|
||||
},
|
||||
|
||||
onTorrentRemoved: function(torrentIds) {
|
||||
var selModel = this.Grid.getSelectionModel();
|
||||
$each(torrentIds, function(torrentId) {
|
||||
var record = this.Store.getById(torrentId);
|
||||
if (selModel.isSelected(record)) {
|
||||
selModel.deselectRow(this.Store.indexOf(record));
|
||||
}
|
||||
this.Store.remove(record);
|
||||
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
Deluge.Torrents.Store.setDefaultSort("queue");
|
||||
@ -134,6 +150,10 @@ Deluge.Torrents.Grid = new Ext.grid.GridPanel({
|
||||
autoScroll:true,
|
||||
margins: '5 5 0 0',
|
||||
listeners: {
|
||||
'render': {
|
||||
fn: Deluge.Torrents.onRender,
|
||||
scope: Deluge.Torrents
|
||||
},
|
||||
'rowcontextmenu': {
|
||||
fn: function(grid, rowIndex, e) {
|
||||
e.stopEvent();
|
||||
|
Loading…
x
Reference in New Issue
Block a user