Mercurial > snowl
changeset 174:88b162978988
collection object rearch: substantiate conditions top-level object
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Thu, 17 Jul 2008 16:11:30 -0700 |
parents | 4d59aa183d57 |
children | 5409a8759186 |
files | extension/content/sidebar.js extension/content/sidebar.xul extension/modules/collection.js |
diffstat | 3 files changed, 11 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/extension/content/sidebar.js Thu Jul 17 15:50:52 2008 -0700 +++ b/extension/content/sidebar.js Thu Jul 17 16:11:30 2008 -0700 @@ -226,19 +226,6 @@ } }, - _group: "source", - onSelectGroup: function(event) { - this._group = event.target.value; - gBrowserWindow.SnowlView.setGroup(this._group); - this._getCollections(); - - // Rebuild the view to reflect the new collection of messages. - // Since the number of rows might have changed, we do this by reinitializing - // the view instead of merely invalidating the box object (which doesn't - // expect changes to the number of rows). - this._tree.view = this; - }, - _collections: null, _getCollections: function() { // FIXME: reimplement the "All" collection.
--- a/extension/content/sidebar.xul Thu Jul 17 15:50:52 2008 -0700 +++ b/extension/content/sidebar.xul Thu Jul 17 16:11:30 2008 -0700 @@ -43,12 +43,6 @@ <script type="application/x-javascript" src="chrome://snowl/content/sidebar.js"/> - <menulist oncommand="SourcesView.onSelectGroup(event)"> - <menupopup> - <menuitem value="source" label="Sources"/> - <menuitem value="person" label="People"/> - </menupopup> - </menulist> <toolbar> <!-- FIXME: Note in credits that silk icons licensed - from http://www.famfamfam.com/lab/icons/silk/
--- a/extension/modules/collection.js Thu Jul 17 15:50:52 2008 -0700 +++ b/extension/modules/collection.js Thu Jul 17 16:11:30 2008 -0700 @@ -26,13 +26,13 @@ /** * A group of messages. */ -function SnowlCollection(aSourceID, aFilter, aCurrent, aRead, aAuthorID) { +function SnowlCollection(aSourceID, aFilter, aCurrent, aRead, aAuthorID, conditions) { this._sourceID = aSourceID; this._authorID = aAuthorID; this._filter = aFilter; this._current = aCurrent; this._read = aRead; - this.conditions = []; + this.conditions = conditions || []; } SnowlCollection.prototype = { @@ -138,10 +138,11 @@ let statement = this._generateGetGroupsStatement(); try { while (statement.step()) { - let group = new SnowlCollection(this.sourceID, this.filter, this.current, this.read, this.authorID); + let conditions = [ { expression: this.nameGroupField + " = :groupValue", + parameters: { groupValue: statement.row.name } } ]; + let group = new SnowlCollection(this.sourceID, this.filter, this.current, this.read, this.authorID, conditions); group.name = statement.row.name; group.uri = URI.get(statement.row.uri); - group.conditions.push({ column: this.nameGroupField, value: group.name }); groups.push(group); } } @@ -154,12 +155,6 @@ return this._groups = groups; }, - getGroup: function(name) { - let group = new SnowlCollection(this.sourceID, this.filter, this.current, this.read, this.authorID); - group.conditions.push({ column: this.nameGroupField, value: name }); - return group; - }, - _generateGetGroupsStatement: function() { let query = "SELECT DISTINCT(" + this.nameGroupField + ") AS name, " + @@ -314,11 +309,8 @@ if (typeof this.read != "undefined") conditions.push("read = " + (this.read ? "1" : "0")); - // FIXME: allow specification of the operator as well. - // FIXME: use parameter binding. - if (this.conditions) - for each (let condition in this.conditions) - conditions.push(condition.column + " = '" + condition.value + "'"); + for each (let condition in this.conditions) + conditions.push(condition.expression); if (conditions.length > 0) query += " WHERE " + conditions.join(" AND "); @@ -336,6 +328,10 @@ if (this.filter) statement.params.filter = this.filter; + for each (let condition in this.conditions) + for (let [name, value] in Iterator(condition.parameters)) + statement.params[name] = value; + return statement; },