[gnome-documents] view: stop iterating when we updated the selection



commit 9a42529b3415933df9bec9d003b3a55aba322453
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 23 17:31:54 2011 -0400

    view: stop iterating when we updated the selection

 src/iconView.js |   10 +++++++++-
 src/listView.js |   10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/iconView.js b/src/iconView.js
index 59f445b..99ac3f3 100644
--- a/src/iconView.js
+++ b/src/iconView.js
@@ -69,9 +69,17 @@ IconView.prototype = {
         this._treeModel.foreach(Lang.bind(this,
             function(model, path, iter) {
                 let urn = this._treeModel.get_value(iter, TrackerModel.ModelColumns.URN);
+                let urnIndex = this._selectedURNs.indexOf(urn);
 
-                if (this._selectedURNs.indexOf(urn) != -1)
+                if (urnIndex != -1) {
                     this.widget.select_path(path);
+                    this._selectedURNs.splice(urnIndex, 1);
+                }
+
+                if (this._selectedURNs.length == 0)
+                    return true;
+
+                return false;
             }));
 
         View.View.prototype.postUpdate.call(this);
diff --git a/src/listView.js b/src/listView.js
index 8909368..eb2fb4b 100644
--- a/src/listView.js
+++ b/src/listView.js
@@ -69,9 +69,17 @@ ListView.prototype = {
         this._treeModel.foreach(Lang.bind(this,
             function(model, path, iter) {
                 let urn = this._treeModel.get_value(iter, TrackerModel.ModelColumns.URN);
+                let urnIndex = this._selectedURNs.indexOf(urn);
 
-                if (this._selectedURNs.indexOf(urn) != -1)
+                if (urnIndex != -1) {
                     treeSelection.select_path(path);
+                    this._selectedURNs.splice(urnIndex, 1);
+                }
+
+                if (this._selectedURNs.length == 0)
+                    return true;
+
+                return false;
             }));
 
         View.View.prototype.postUpdate.call(this);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]