[gnome-documents/wip/split-view: 2/8] Don't clear DocumentManager on every TrackerController refresh
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/split-view: 2/8] Don't clear DocumentManager on every TrackerController refresh
- Date: Mon, 6 Oct 2014 13:36:04 +0000 (UTC)
commit 483e5a1874142578c70672abd195eefc72f6a743
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Sep 25 14:40:36 2014 +0200
Don't clear DocumentManager on every TrackerController refresh
We were clearing DocumentManager on every refresh of the
TrackerController. This will be problematic when we implement the new
split view designs because DocumentManager will have items spanning
across multiple views. Refreshing the TrackerController for one view
should not clear DocumentManager because it might have items for some
other view.
Instead, we can add some filtering to ViewModel so that it only picks
those items that are relevant to the view for which it is a model.
Since we are not clearing DocumentManager on every refresh, we will
find some items that are already part of the manager. Avoid emitting
an extra "object-removed" / "object-added" pair in these cases.
https://bugzilla.gnome.org/show_bug.cgi?id=686461
src/documents.js | 14 ++++++++++----
src/trackerController.js | 2 --
src/view.js | 11 ++++++++---
3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 229eacd..d39f1a2 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -1155,11 +1155,17 @@ const DocumentManager = new Lang.Class({
},
addDocumentFromCursor: function(cursor) {
- let doc = this.createDocumentFromCursor(cursor);
- this.addItem(doc);
+ let id = cursor.get_string(Query.QueryColumns.URN)[0];
+ let doc = this.getItemById(id);
- if (doc.collection)
- Application.collectionManager.addItem(doc);
+ if (doc) {
+ this.emit('item-added', doc);
+ } else {
+ doc = this.createDocumentFromCursor(cursor);
+ this.addItem(doc);
+ if (doc.collection)
+ Application.collectionManager.addItem(doc);
+ }
return doc;
},
diff --git a/src/trackerController.js b/src/trackerController.js
index 2bf227b..e2107b9 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -242,8 +242,6 @@ const TrackerController = new Lang.Class({
}
this._setQueryStatus(true);
- Application.documentManager.clear();
-
this._performCurrentQuery();
},
diff --git a/src/view.js b/src/view.js
index ad671f3..c84424b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -125,8 +125,13 @@ const ViewModel = new Lang.Class({
Lang.bind(this, this._onItemAdded));
Application.documentManager.connect('item-removed',
Lang.bind(this, this._onItemRemoved));
- Application.documentManager.connect('clear',
- Lang.bind(this, this._onClear));
+
+ Application.trackerController.connect('query-status-changed', Lang.bind(this,
+ function(o, status) {
+ if (!status)
+ return;
+ this._clear();
+ }));
// populate with the intial items
let items = Application.documentManager.getItems();
@@ -135,7 +140,7 @@ const ViewModel = new Lang.Class({
}
},
- _onClear: function() {
+ _clear: function() {
this.model.clear();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]