OSDN Git Service

Enable to get dictionaries in the data store.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 28 Sep 2006 17:02:27 +0000 (02:02 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Sat, 30 Sep 2006 09:45:55 +0000 (18:45 +0900)
src/FukuiNoNamari/board_column.py
src/FukuiNoNamari/board_window.py
src/FukuiNoNamari/threadlistmodel.py

index becea8c..743d752 100644 (file)
@@ -67,10 +67,8 @@ class BaseTreeViewColumn(gtk.TreeViewColumn):
     def on_cell_data(self, column, cell, model, iter):
         self.updated_thread_highlight(column, cell, model, iter)
 
-        column_num = model.column_names.index(self.name)
-        value = model.get_value(iter, column_num)
-        if model.get_column_type(column_num) \
-               in (gobject.TYPE_INT, gobject.TYPE_DOUBLE):
+        value = model.get_dict(iter)[self.name]
+        if type(value) in (int, float):
             if value == 0:
                 cell.set_property("text", "")
             else:
@@ -81,10 +79,8 @@ class BaseTreeViewColumn(gtk.TreeViewColumn):
     def updated_thread_highlight(self, column, cell, model, iter):
 
         def is_updated_thread():
-            res = model.get_value(
-                iter, model.column_names.index("res"))
-            linecount = model.get_value(
-                iter, model.column_names.index("lineCount"))
+            res = model.get_dict(iter)["res"]
+            linecount = model.get_dict(iter)["lineCount"]
             return res != 0 and linecount != 0 and res > linecount
 
         if is_updated_thread():
@@ -149,8 +145,7 @@ class TreeViewColumn_LastModified(BaseTreeViewColumn):
     def on_cell_data(self, column, cell, model, iter):
         self.updated_thread_highlight(column, cell, model, iter)
 
-        lastmod = model.get_value(
-            iter, model.column_names.index("lastModified"))
+        lastmod = model.get_dict(iter)["lastModified"]
         if lastmod == 0:
             cell.set_property("text", "")
         else:
index 97bb3e6..e5dae3f 100644 (file)
@@ -124,14 +124,13 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         if not iter:
             return
 
-        thread = model.get_value(iter, ThreadListModel.column_names.index("id"))
-        title = model.get_value(
-            iter, ThreadListModel.column_names.index("title"))
+        dic = model.get_dict(iter)
+        thread = dic["id"]
+        title = dic["title"]
         print thread + ':"' + title + '"', "activated"
 
-        res = model.get_value(iter, ThreadListModel.column_names.index("res"))
-        lineCount = model.get_value(
-            iter, ThreadListModel.column_names.index("lineCount"))
+        res = dic["res"]
+        lineCount = dic["lineCount"]
 
         update = res > lineCount
 
@@ -345,8 +344,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         model, iter = selection.get_selected()
         if not iter:
             return
-        thread = model.get_value(
-            iter, ThreadListModel.column_names.index("id"))
+        thread = model.get_dict(iter)["id"]
         
         bbs_type_for_thread = self.bbs_type.clone_with_thread(thread)
 
index 72347f2..f0f2ba4 100644 (file)
@@ -48,6 +48,10 @@ class ThreadListModel(gtk.GenericTreeModel):
         except:
             pass
 
+    def get_dict(self, iter):
+        path = self.get_path(iter)
+        return self.list[path[0]]
+
     def modify_row(self, dict):
         id = dict["id"]
         if id in self.order_dict: