mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
improve removing of torrents by adding a "torrentRemoved" event
This commit is contained in:
parent
71ef3f3ddc
commit
6897cd8b6b
3 changed files with 22 additions and 0 deletions
|
@ -66,6 +66,7 @@ Deluge.ToolBar = {
|
||||||
|
|
||||||
switch (item.id) {
|
switch (item.id) {
|
||||||
case 'remove':
|
case 'remove':
|
||||||
|
Deluge.Events.fire('torrentRemoved', ids);
|
||||||
Deluge.Client.core.remove_torrent(ids, null, {
|
Deluge.Client.core.remove_torrent(ids, null, {
|
||||||
onSuccess: function() {
|
onSuccess: function() {
|
||||||
Deluge.Ui.update();
|
Deluge.Ui.update();
|
||||||
|
|
|
@ -56,6 +56,7 @@ Deluge.Menus = {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'remove':
|
case 'remove':
|
||||||
|
Deluge.Events.fire('torrentRemoved', ids);
|
||||||
Deluge.Client.core.remove_torrent(ids, null, {
|
Deluge.Client.core.remove_torrent(ids, null, {
|
||||||
onSuccess: function() {
|
onSuccess: function() {
|
||||||
Deluge.Ui.update();
|
Deluge.Ui.update();
|
||||||
|
|
|
@ -105,6 +105,22 @@ Deluge.Torrents = {
|
||||||
|
|
||||||
getSelections: function() {
|
getSelections: function() {
|
||||||
return this.Grid.getSelectionModel().getSelections();
|
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");
|
Deluge.Torrents.Store.setDefaultSort("queue");
|
||||||
|
@ -134,6 +150,10 @@ Deluge.Torrents.Grid = new Ext.grid.GridPanel({
|
||||||
autoScroll:true,
|
autoScroll:true,
|
||||||
margins: '5 5 0 0',
|
margins: '5 5 0 0',
|
||||||
listeners: {
|
listeners: {
|
||||||
|
'render': {
|
||||||
|
fn: Deluge.Torrents.onRender,
|
||||||
|
scope: Deluge.Torrents
|
||||||
|
},
|
||||||
'rowcontextmenu': {
|
'rowcontextmenu': {
|
||||||
fn: function(grid, rowIndex, e) {
|
fn: function(grid, rowIndex, e) {
|
||||||
e.stopEvent();
|
e.stopEvent();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue