[gnome-documents/wip/ui-changes: 13/16] documents: remove ModelColumns



commit 6eb4b139f2c5d61c3cb222433c0028844ce99536
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Mar 1 17:22:37 2012 -0500

    documents: remove ModelColumns
    
    Use the enum from gd-main-view consistently

 src/documents.js |   14 +++-----------
 src/utils.js     |    4 ++--
 src/view.js      |   16 ++++++++--------
 3 files changed, 13 insertions(+), 21 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index a7b29e7..c11c081 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -915,14 +915,6 @@ DocumentManager.prototype = {
     }
 };
 
-const ModelColumns = {
-    URN: 0,
-    TITLE: 1,
-    AUTHOR: 2,
-    ICON: 3,
-    MTIME: 4
-};
-
 function DocumentModel() {
     this._init();
 }
@@ -930,7 +922,7 @@ function DocumentModel() {
 DocumentModel.prototype = {
     _init: function() {
         this.model = Gd.create_list_store();
-        this.model.set_sort_column_id(ModelColumns.MTIME,
+        this.model.set_sort_column_id(Gd.MainColumns.MTIME,
                                       Gtk.SortType.DESCENDING);
     },
 
@@ -967,9 +959,9 @@ DocumentModel.prototype = {
     documentRemoved: function(doc) {
         this.model.foreach(Lang.bind(this,
             function(model, path, iter) {
-                let urn = model.get_value(iter, ModelColumns.URN);
+                let id = model.get_value(iter, Gd.MainColumns.ID);
 
-                if (urn == doc.id) {
+                if (id == doc.id) {
                     this.model.remove(iter);
                     return true;
                 }
diff --git a/src/utils.js b/src/utils.js
index 156cfd9..4840a4f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -92,9 +92,9 @@ function getURNsFromPaths(paths, model) {
 
 function getURNFromPath(path, model) {
     let iter = model.get_iter(path)[1];
-    let urn = model.get_value(iter, Documents.ModelColumns.URN);
+    let id = model.get_value(iter, Gd.MainColumns.ID);
 
-    return urn;
+    return id;
 }
 
 function isSearchEvent(event) {
diff --git a/src/view.js b/src/view.js
index 318b5a4..f532047 100644
--- a/src/view.js
+++ b/src/view.js
@@ -155,8 +155,8 @@ View.prototype = {
         typeRenderer.add_class('dim-label');
         listWidget.add_renderer(typeRenderer, Lang.bind(this,
             function(col, cell, model, iter) {
-                let urn = model.get_value(iter, Documents.ModelColumns.URN);
-                let doc = Global.documentManager.getItemById(urn);
+                let id = model.get_value(iter, Gd.MainColumns.ID);
+                let doc = Global.documentManager.getItemById(id);
 
                 typeRenderer.text = doc.typeDescription;
             }));
@@ -166,8 +166,8 @@ View.prototype = {
         whereRenderer.add_class('dim-label');
         listWidget.add_renderer(whereRenderer, Lang.bind(this,
             function(col, cell, model, iter) {
-                let urn = model.get_value(iter, Documents.ModelColumns.URN);
-                let doc = Global.documentManager.getItemById(urn);
+                let id = model.get_value(iter, Gd.MainColumns.ID);
+                let doc = Global.documentManager.getItemById(id);
 
                 whereRenderer.text = doc.sourceName;
             }));
@@ -230,12 +230,12 @@ View.prototype = {
         let first = true;
         this._treeModel.foreach(Lang.bind(this,
             function(model, path, iter) {
-                let urn = this._treeModel.get_value(iter, Documents.ModelColumns.URN);
-                let urnIndex = selected.indexOf(urn);
+                let id = this._treeModel.get_value(iter, Gd.MainColumns.ID);
+                let idIndex = selected.indexOf(id);
 
-                if (urnIndex != -1) {
+                if (idIndex != -1) {
                     this._treeModel.set_value(iter, Gd.MainColumns.SELECTED, true);
-                    selected.splice(urnIndex, 1);
+                    selected.splice(idIndex, 1);
 
                     if (first) {
                         generic.scroll_to_path(path);



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