remove obsolete group code from collection.js

This commit is contained in:
alta88@gmail.com 2009-10-30 08:29:42 -06:00
Родитель 635804b7ce
Коммит 24f8840046
1 изменённых файлов: 0 добавлений и 130 удалений

Просмотреть файл

@ -101,136 +101,6 @@ SnowlCollection.prototype = {
},
//**************************************************************************//
// Grouping
// XXX This stuff only matters when the collection is being displayed
// in the sidebar. Should we split it out to another class that subclasses
// Collection or composes a new class with it?
isOpen: false,
level: 0,
_groups: null,
get groups() {
if (!this.grouped)
return null;
if (this._groups)
return this._groups;
let groups = [];
let statement = this._generateGetGroupsStatement();
try {
while (statement.step()) {
let name = statement.row.name;
let iconURL =
statement.row.iconURL ? URI.get(statement.row.iconURL) :
statement.row.homeURL ? this.getFaviconURL(URI.get(statement.row.homeURL))
: null;
if (!iconURL && this.iconURL)
iconURL = this.iconURL;
// FIXME: fall back to a default collection icon.
let constraints = [constraint for each (constraint in this.constraints)];
constraints.push({ expression: this.groupNameColumn + " = :groupValue",
parameters: { groupValue: statement.row.name } });
let group = new SnowlCollection(null, name, iconURL, constraints, this);
//this._log.info("got group name: " + group.name);
if (this.groupIDColumn)
group.groupID = statement.row.groupID;
group.level = this.level + 1;
groups.push(group);
}
}
finally {
statement.reset();
}
this._log.info("got " + groups.length + " groups");
return this._groups = groups;
},
_generateGetGroupsStatement: function() {
let columns = [];
if (this.groupIDColumn) {
columns.push("DISTINCT(" + this.groupIDColumn + ") AS groupID");
columns.push(this.groupNameColumn + " AS name");
}
else
columns.push("DISTINCT(" + this.groupNameColumn + ") AS name");
// For some reason, trying to access statement.row.foo dies without throwing
// an exception if foo isn't defined as a column in the query, so we have to
// define iconURL and homeURL columns even if we don't use them.
// FIXME: file a bug on this bizarre behavior.
if (this.groupIconURLColumn)
columns.push(this.groupIconURLColumn + " AS iconURL");
else
columns.push("NULL AS iconURL");
if (this.groupHomeURLColumn)
columns.push(this.groupHomeURLColumn + " AS homeURL");
else
columns.push("NULL AS homeURL");
// FIXME: allow group queries to make people the primary table.
let query =
"SELECT " + columns.join(", ") + " " +
"FROM sources LEFT JOIN messages ON sources.id = messages.sourceID " +
"LEFT JOIN people AS authors ON messages.authorID = authors.id";
let conditions = [];
for each (let condition in this.constraints)
conditions.push(condition.expression);
if (conditions.length > 0)
query += " WHERE " + conditions.join(" AND ");
query += " ORDER BY " + this.groupNameColumn + " COLLATE NOCASE";
if (this.limit)
query += " LIMIT " + this.limit;
this._log.info(this.name + " group query: " + query);
let statement = SnowlDatastore.createStatement(query);
for each (let condition in this.constraints)
for (let [name, value] in Iterator(condition.parameters))
statement.params[name] = value;
return statement;
},
// Favicon Service
get _faviconSvc() {
let faviconSvc = Cc["@mozilla.org/browser/favicon-service;1"].
getService(Ci.nsIFaviconService);
delete this.__proto__._faviconSvc;
this.__proto__._faviconSvc = faviconSvc;
return this._faviconSvc;
},
getFaviconURL: function(homeURL) {
try {
return this._faviconSvc.getFaviconForPage(homeURL);
}
catch(ex) { /* no known favicon; use the default */ }
return null;
},
//**************************************************************************//
// Retrieval