remove all the torrents from the store upon logout

This commit is contained in:
Damien Churchill 2010-01-23 20:34:32 +00:00
parent 14cea4fbc7
commit fe6bcd62be
1 changed files with 9 additions and 3 deletions

View File

@ -209,6 +209,8 @@ Copyright:
initComponent: function() { initComponent: function() {
Ext.deluge.TorrentGrid.superclass.initComponent.call(this); Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this); Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
Deluge.Events.on('logout', this.onDisconnect, this);
this.on('rowcontextmenu', function(grid, rowIndex, e) { this.on('rowcontextmenu', function(grid, rowIndex, e) {
e.stopEvent(); e.stopEvent();
var selection = grid.getSelectionModel(); var selection = grid.getSelectionModel();
@ -222,11 +224,11 @@ Copyright:
/** /**
* Returns the record representing the torrent at the specified index. * Returns the record representing the torrent at the specified index.
* *
* @param {int} The row index of the torrent you wish to retrieve. * @param index {int} The row index of the torrent you wish to retrieve.
* @return {Ext.data.Record} The record representing the torrent. * @return {Ext.data.Record} The record representing the torrent.
*/ */
getTorrent: function(rowIndex) { getTorrent: function(index) {
return this.getStore().getAt(rowIndex); return this.getStore().getAt(index);
}, },
getSelected: function() { getSelected: function() {
@ -245,6 +247,10 @@ Copyright:
} }
}, },
onDisconnect: function() {
this.getStore().removeAll();
},
// private // private
onTorrentRemoved: function(torrentIds) { onTorrentRemoved: function(torrentIds) {
var selModel = this.getSelectionModel(); var selModel = this.getSelectionModel();