add support for selecting multiple filters

This commit is contained in:
Damien Churchill 2010-03-16 23:47:44 +00:00
parent 7a115622df
commit 9672480d39

View File

@ -146,30 +146,26 @@ Copyright:
this.doLayout(); this.doLayout();
this.panels[filter] = panel; this.panels[filter] = panel;
if (!this.selected) { panel.getSelectionModel().selectFirstRow();
panel.getSelectionModel().selectFirstRow();
this.selected = {
row: 0,
filter: states[0][0],
panel: panel
}
}
}, },
getFilters: function() { getFilters: function() {
var filters = {} var filters = {}
if (!this.selected) {
return filters; // Grab the filters from each of the filter panels
} this.items.each(function(panel) {
if (!this.selected.filter || !this.selected.panel) { var sm = panel.getSelectionModel();
return filters;
} if (!sm.hasSelection()) return;
var filterType = this.selected.panel.store.id;
if (filterType == "state" && this.selected.filter == "All") { var filter = sm.getSelected();
return filters; var filterType = panel.getStore().id;
}
if (filter.id == "All") return;
filters[filterType] = this.selected.filter;
filters[filterType] = filter.id;
}, this);
return filters; return filters;
}, },
@ -183,16 +179,7 @@ Copyright:
}, },
onFilterSelect: function(selModel, rowIndex, record) { onFilterSelect: function(selModel, rowIndex, record) {
if (!this.selected) needsUpdate = true; Deluge.UI.update();
else if (this.selected.row != rowIndex) needsUpdate = true;
else needsUpdate = false;
this.selected = {
row: rowIndex,
filter: record.get('filter'),
panel: this.panels[record.store.id]
}
if (needsUpdate) Deluge.UI.update();
}, },
/** /**
@ -241,10 +228,6 @@ Copyright:
record.endEdit(); record.endEdit();
record.commit(); record.commit();
}, this); }, this);
if (this.selected && this.selected.panel == this.panels[filter]) {
this.panels[filter].getSelectionModel().selectRow(this.selected.row);
}
} }
}); });
Deluge.Sidebar = new Ext.deluge.Sidebar(); Deluge.Sidebar = new Ext.deluge.Sidebar();