fix the filtering within the grid
also fixes a torrent remaining if it's the last one removed
This commit is contained in:
parent
8d7e762b0a
commit
9933536892
|
@ -106,10 +106,11 @@ Deluge.Widgets.Labels = new Class({
|
||||||
*/
|
*/
|
||||||
labelClicked: function(e) {
|
labelClicked: function(e) {
|
||||||
this.currentFilter.removeClass('activestate');
|
this.currentFilter.removeClass('activestate');
|
||||||
this.filterType = e.filter;
|
this.filterType = e.name;
|
||||||
this.filterName = e.name;
|
this.filterName = e.filter;
|
||||||
this.currentFilter = e.target;
|
this.currentFilter = e.target;
|
||||||
e.target.addClass('activestate');
|
e.target.addClass('activestate');
|
||||||
|
this.fireEvent('filterChanged');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -51,19 +51,16 @@ Deluge.Widgets.TorrentGrid = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTorrents: function(torrents) {
|
updateTorrents: function(torrents) {
|
||||||
torrents.getKeys().each(function(torrentId) {
|
torrents.each(function(torrent, id) {
|
||||||
var torrent = torrents[torrentId]
|
torrent.queue = (torrent.queue > -1) ? torrent.queue + 1 : ''
|
||||||
var torrentIds = torrents.getKeys()
|
torrent.icon = this.icons[torrent.state]
|
||||||
if (torrent.queue == -1) {var queue = ''}
|
|
||||||
else {var queue = torrent.queue + 1}
|
|
||||||
var icon = this.icons[torrent.state]
|
|
||||||
row = {
|
row = {
|
||||||
id: torrentId,
|
id: id,
|
||||||
data: {
|
data: {
|
||||||
number: queue,
|
number: torrent.queue,
|
||||||
name: {text: torrent.name, icon: icon},
|
name: {text: torrent.name, icon: torrent.icon},
|
||||||
size: torrent.total_size,
|
size: torrent.total_size,
|
||||||
progress: {percent: torrent.progress, text:torrent.state + ' ' + torrent.progress.toFixed(2) + '%'},
|
progress: {percent: torrent.progress, text: torrent.state + ' ' + torrent.progress.toFixed(2) + '%'},
|
||||||
seeders: torrent.num_seeds + ' (' + torrent.total_seeds + ')',
|
seeders: torrent.num_seeds + ' (' + torrent.total_seeds + ')',
|
||||||
peers: torrent.num_peers + ' (' + torrent.total_peers + ')',
|
peers: torrent.num_peers + ' (' + torrent.total_peers + ')',
|
||||||
down: torrent.download_payload_rate,
|
down: torrent.download_payload_rate,
|
||||||
|
@ -75,18 +72,16 @@ Deluge.Widgets.TorrentGrid = new Class({
|
||||||
torrent: torrent
|
torrent: torrent
|
||||||
}
|
}
|
||||||
if (this.has(row.id)) {
|
if (this.has(row.id)) {
|
||||||
this.updateRow(row, true)
|
this.updateRow(row, true);
|
||||||
} else {
|
} else {
|
||||||
this.addRow(row, true)
|
this.addRow(row, true);
|
||||||
}
|
}
|
||||||
|
}, this);
|
||||||
this.rows.each(function(row) {
|
this.rows.each(function(row) {
|
||||||
if (!torrentIds.contains(row.id)) {
|
if (!torrents.has(row.id)) {
|
||||||
row.element.destroy()
|
delete this.rows[this.rows.indexOf(row)]
|
||||||
this.rows.erase(row.id)
|
};
|
||||||
}
|
}, this);
|
||||||
}, this)
|
this.render();
|
||||||
}, this)
|
|
||||||
this.render()
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,7 +21,7 @@ Deluge.UI = {
|
||||||
resized: this.resized.bindWithEvent(this),
|
resized: this.resized.bindWithEvent(this),
|
||||||
toolbarClick: this.toolbarClick.bindWithEvent(this),
|
toolbarClick: this.toolbarClick.bindWithEvent(this),
|
||||||
filePriorities: this.filePriorities.bindWithEvent(this),
|
filePriorities: this.filePriorities.bindWithEvent(this),
|
||||||
labelsChanged: this.labelsChanged.bindWithEvent(this)
|
filterChanged: this.filterChanged.bindWithEvent(this)
|
||||||
};
|
};
|
||||||
this.loadUi.delay(250, this);
|
this.loadUi.delay(250, this);
|
||||||
},
|
},
|
||||||
|
@ -42,7 +42,7 @@ Deluge.UI = {
|
||||||
this.initializeGrid()
|
this.initializeGrid()
|
||||||
|
|
||||||
this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, {
|
this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, {
|
||||||
pane1: {min: 150},
|
pane1: {min: 180},
|
||||||
pane2: {min: 100, expand: true}
|
pane2: {min: 100, expand: true}
|
||||||
});
|
});
|
||||||
var details = $W('details')
|
var details = $W('details')
|
||||||
|
@ -59,11 +59,11 @@ Deluge.UI = {
|
||||||
this.details.expand()
|
this.details.expand()
|
||||||
|
|
||||||
this.toolbar.addEvent('buttonClick', this.bound.toolbarClick);
|
this.toolbar.addEvent('buttonClick', this.bound.toolbarClick);
|
||||||
this.details.addEvent('filesAction', this.bound.filePriorities)
|
this.details.addEvent('filesAction', this.bound.filePriorities);
|
||||||
this.labels.addEvent('stateChanged', this.bound.labelsChanged)
|
this.labels.addEvent('filterChanged', this.bound.filterChanged);
|
||||||
details.addEvent('resize', function(e) {
|
details.addEvent('resize', function(e) {
|
||||||
this.details.expand()
|
this.details.expand();
|
||||||
}.bindWithEvent(this))
|
}.bindWithEvent(this));
|
||||||
|
|
||||||
window.addEvent('resize', this.bound.resized);
|
window.addEvent('resize', this.bound.resized);
|
||||||
Deluge.UI.update();
|
Deluge.UI.update();
|
||||||
|
@ -136,7 +136,10 @@ Deluge.UI = {
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
filter = {};
|
filter = {};
|
||||||
//if (this.labels.state != 'All') filter['state'] = this.labels.state;
|
var type = this.labels.filterType, name = this.labels.filterName
|
||||||
|
if (type && !(type == 'state' && name == 'All')) {
|
||||||
|
filter[this.labels.filterType] = this.labels.filterName;
|
||||||
|
}
|
||||||
Deluge.Client.update_ui(Deluge.Keys.Grid, filter, {
|
Deluge.Client.update_ui(Deluge.Keys.Grid, filter, {
|
||||||
onSuccess: this.bound.updated
|
onSuccess: this.bound.updated
|
||||||
});
|
});
|
||||||
|
@ -186,8 +189,8 @@ Deluge.UI = {
|
||||||
this.torrentAction(event.action);
|
this.torrentAction(event.action);
|
||||||
},
|
},
|
||||||
|
|
||||||
labelsChanged: function(event) {
|
filterChanged: function(event) {
|
||||||
this.update()
|
this.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
torrentAction: function(action, value) {
|
torrentAction: function(action, value) {
|
||||||
|
|
|
@ -1357,13 +1357,11 @@ Widgets.DataGrid = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
filter: function() {
|
filter: function() {
|
||||||
if (!$chk(this.filterer)) {
|
this.filterer = (this.filterer) ? this.filterer : $lambda(true);
|
||||||
this.filterer = $lambda(true)
|
this.displayRows.empty();
|
||||||
}
|
this.rows.each(function(row) {
|
||||||
this.displayRows.empty()
|
if (this.filterer(row)) {this.displayRows.include(row)}
|
||||||
this.rows.each(function(r) {
|
}.bind(this));
|
||||||
if (this.filterer(r)) {this.displayRows.include(r)}
|
|
||||||
}.bind(this))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getById: function(id) {
|
getById: function(id) {
|
||||||
|
@ -1390,8 +1388,8 @@ Widgets.DataGrid = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.filter()
|
this.filter();
|
||||||
this.resort()
|
this.resort();
|
||||||
var rows = [], rowIds = []
|
var rows = [], rowIds = []
|
||||||
this.rows.each(function(row) {
|
this.rows.each(function(row) {
|
||||||
if (this.displayRows.contains(row)) {
|
if (this.displayRows.contains(row)) {
|
||||||
|
|
Loading…
Reference in New Issue