[gnome-documents] all: add a sideFilterController class
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] all: add a sideFilterController class
- Date: Wed, 19 Oct 2011 23:04:09 +0000 (UTC)
commit 6835b779769714d193d649e339a222964aee7155
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Oct 14 13:44:46 2011 -0400
all: add a sideFilterController class
Keeps track globally of the currently selected item in the sidebar,
abstracting between Collections and Categories.
src/application.js | 1 +
src/filters.js | 32 ++++++++++++++++++++++++++++++++
src/global.js | 2 ++
src/query.js | 10 +++++-----
src/sidebar.js | 10 +++++++++-
src/trackerController.js | 2 ++
6 files changed, 51 insertions(+), 6 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index c6c0101..216fdfe 100644
--- a/src/application.js
+++ b/src/application.js
@@ -146,6 +146,7 @@ Application.prototype = {
Global.queryBuilder = new Query.QueryBuilder();
Global.changeMonitor = new ChangeMonitor.TrackerChangeMonitor();
Global.collectionManager = new Collections.CollectionManager();
+ Global.sideFilterController = new Filters.SideFilterController();
Global.documentManager = new Documents.DocumentManager();
Global.trackerController = new TrackerController.TrackerController();
Global.modeController = new WindowMode.ModeController();
diff --git a/src/filters.js b/src/filters.js
index 22c0113..31bec0f 100644
--- a/src/filters.js
+++ b/src/filters.js
@@ -43,3 +43,35 @@ SearchFilterController.prototype = {
}
};
Signals.addSignalMethods(SearchFilterController.prototype);
+
+function SideFilterController() {
+ this._init();
+}
+
+SideFilterController.prototype = {
+ _init: function() {
+ this._whereItem = null;
+ },
+
+ setActiveItem: function(controller, item) {
+ if (this._whereItem == item)
+ return;
+
+ this._whereItem = item;
+ controller.setActiveItem(this._whereItem);
+
+ this.emit('changed', this._whereItem);
+ },
+
+ getWhere: function() {
+ if (!this._whereItem)
+ return '';
+
+ return this._whereItem.getWhere();
+ },
+
+ getWhereItem: function() {
+ return this._whereItem;
+ }
+};
+Signals.addSignalMethods(SideFilterController.prototype);
diff --git a/src/global.js b/src/global.js
index 3f2c710..5e6a2cf 100644
--- a/src/global.js
+++ b/src/global.js
@@ -29,6 +29,8 @@ let goaClient = null;
let modeController = null;
let offsetController = null;
let queryBuilder = null;
+let searchFilterController = null;
+let sideFilterController = null;
let selectionController = null;
let settings = null;
let sourceManager = null;
diff --git a/src/query.js b/src/query.js
index 61e9fdf..0e813f6 100644
--- a/src/query.js
+++ b/src/query.js
@@ -147,11 +147,11 @@ QueryBuilder.prototype = {
if (global) {
globalSparql +=
- Global.categoryManager.getActiveCategoryWhere() +
- this._buildFilterString() +
- ' } ' +
- 'ORDER BY DESC (?mtime)' +
- ('LIMIT %d OFFSET %d').format(Global.offsetController.getOffsetStep(),
+ Global.sideFilterController.getWhere() +
+ this._buildFilterString() +
+ ' } ' +
+ 'ORDER BY DESC (?mtime)' +
+ ('LIMIT %d OFFSET %d').format(Global.offsetController.getOffsetStep(),
Global.offsetController.getOffset());
} else {
globalSparql += this._buildFilterString() + ' }';
diff --git a/src/sidebar.js b/src/sidebar.js
index 96faf15..f0425b0 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -148,8 +148,16 @@ SidebarView.prototype = {
function(view, path) {
let iter = this._treeModel.get_iter(path)[1];
let id = this._treeModel.get_value(iter, SidebarModelColumns.ID);
+ let section = this._treeModel.get_value(iter, SidebarModelColumns.SECTION);
- Global.categoryManager.setActiveCategoryId(id);
+ let controller = null;
+ if (section == SidebarModelSections.CATEGORIES)
+ controller = Global.categoryManager;
+ else if (section == SidebarModelSections.COLLECTIONS)
+ controller = Global.collectionManager;
+
+ let item = controller.getItemById(id);
+ Global.sideFilterController.setActiveItem(controller, item);
}));
let col = new Gtk.TreeViewColumn();
diff --git a/src/trackerController.js b/src/trackerController.js
index bae43e4..59be039 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -51,6 +51,8 @@ TrackerController.prototype = {
this._offsetController.connect('offset-changed',
Lang.bind(this, this._performCurrentQuery));
+ Global.sideFilterController.connect('changed',
+ Lang.bind(this, this._refresh));
Global.searchFilterController.connect('changed',
Lang.bind(this, this._onSearchFilterChanged));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]