Mercurial > snowl
changeset 182:489b8c2db12d
make the river view use the new collection architecture for setting filters
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Sun, 20 Jul 2008 19:13:25 -0700 |
parents | d3da7d77c89a |
children | b497c5463801 |
files | extension/content/river.js extension/content/river.xul |
diffstat | 2 files changed, 32 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/extension/content/river.js Sun Jul 20 18:50:34 2008 -0700 +++ b/extension/content/river.js Sun Jul 20 19:13:25 2008 -0700 @@ -105,6 +105,11 @@ return this._orderButton; }, + get _filterTextbox() { + delete this._filter; + return this._filter = document.getElementById("filterTextbox"); + }, + // The set of messages to display in the view. _collection: null, @@ -284,28 +289,42 @@ sourceMenu.selectedIndex = 0; }, + onFilter: function(aEvent) { + this._updateURI(); + this._applyFilters(); + }, + onCommandCurrentButton: function(aEvent) { - if (this._currentButton.checked) - this._collection.current = true; - else - this._collection.current = undefined; - - this.rebuildView(); this._updateURI(); + this._applyFilters(); }, onCommandUnreadButton: function(aEvent) { - // FIXME: instead of rebuilding from scratch each time, when going from + this._updateURI(); + // XXX Instead of rebuilding from scratch each time, when going from // all to unread, simply hide the ones that are read (f.e. by setting a CSS - // class on read items and then using a CSS rule to hide them). + // class on read items and then using a CSS rule to hide them)? + this._applyFilters(); + }, + + _applyFilters: function() { + let filters = []; + + if (this._currentButton.checked) + filters.push({ expression: "current = 1", parameters: {} }); if (this._unreadButton.checked) - this._collection.read = false; - else - this._collection.read = undefined; + filters.push({ expression: "read = 0", parameters: {} }); + // FIXME: use a left join here once the SQLite bug breaking left joins to + // virtual tables has been fixed (i.e. after we upgrade to SQLite 3.5.7+). + if (this._filterTextbox.value) + filters.push({ expression: "messages.id IN (SELECT messageID FROM parts WHERE content MATCH :filter)", + parameters: { filter: this._filterTextbox.value } }); + + this._collection.filters = filters; + this._collection.invalidate(); this.rebuildView(); - this._updateURI(); }, onCommandBodyButton: function(aEvent) { @@ -331,12 +350,6 @@ this._updateURI(); }, - onCommandFilterTextbox: function(aEvent, aFilterTextbox) { - this._collection.filter = aFilterTextbox.value; - this.rebuildView(); - this._updateURI(); - }, - onCommandSourceMenu: function(aEvent) { let sourceMenu = document.getElementById("sourceMenu"); this._collection.sourceID = sourceMenu.selectedItem.value;
--- a/extension/content/river.xul Sun Jul 20 18:50:34 2008 -0700 +++ b/extension/content/river.xul Sun Jul 20 19:13:25 2008 -0700 @@ -49,7 +49,7 @@ <spacer flex="1"/> <textbox id="filterTextbox" type="timed" timeout="200" - oncommand="RiverView.onCommandFilterTextbox(event, this)"/> + oncommand="RiverView.onFilter(event)"/> </toolbar> <stack flex="1">