OSDN Git Service

Window managing auxiliary is added. It shows only same board windows. (#16374)
[fukui-no-namari/fukui-no-namari.git] / src / FukuiNoNamari / board_window.py
index 2e5eef6..d03e684 100644 (file)
@@ -87,7 +87,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         self.treeview.set_fixed_height_mode(True)
 
         # menu plugins
-        board_plugins.load(self.treeview, self.menu_edit)
+        board_plugins.load(self.widget_tree)
 
         self.restore()
         self.window.show()
@@ -104,7 +104,6 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         self.filterbar = self.widget_tree.get_widget(
             "bonobodockitem_filterbar")
         self.entry_filterbar = self.widget_tree.get_widget("entry_filterbar")
-        self.menu_edit = self.widget_tree.get_widget("menu_edit").get_submenu()
 
     def set_status(self, text):
         self.statusbar.set_status(text)
@@ -119,20 +118,25 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
     def get_uri(self):
         return self.bbs_type.get_uri_base()
 
+    def show(self):
+        self.window.deiconify()
+
+    def hide(self):
+        self.window.iconify()
+
     def open_thread(self):
         treeselection = self.treeview.get_selection()
         model, iter = treeselection.get_selected()
         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
 
@@ -181,6 +185,11 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
             key_iter = dictdict.iterkeys()
             value_iter = dictdict.itervalues()
             iterable = itertools.imap(set_id, key_iter, value_iter)
+
+            # remove not in subject.txt and not cache.
+            iterable = itertools.ifilter(
+                lambda dic: dic["num"] > 0 or dic["lineCount"] > 0, iterable)
+
             return [item_dict for item_dict in iterable]
 
         def load_local():
@@ -204,6 +213,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         def deep_copy():
             def init_some(dic):
                 dic["num"] = 0
+                dic["oldRes"] = dic["res"]
                 dic["res"] = 0
                 dic["average"] = 0
                 return dic
@@ -212,9 +222,6 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
             if model:
                 iterable = model.original_list
 
-                # unmerge subject.txt
-                iterable = itertools.ifilter(
-                    lambda dic: dic["lineCount"] > 0, iterable)
                 iterable = itertools.imap(lambda dic: dic.copy(), iterable)
                 iterable = itertools.imap(init_some, iterable)
 
@@ -283,8 +290,12 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         try:
             states_dict = board_states.states_file_to_dict(self.bbs_type)
 
-            self.treeview.get_model().sort(
-                states_dict["sort_column"], True, states_dict["sort_reverse"])
+            try:
+                self.treeview.get_model().sort(
+                    states_dict["sort_column"], True,
+                    states_dict["sort_reverse"])
+            except:
+                pass
 
             # set column order before set column width
             treeviewcolumn = dict(
@@ -346,8 +357,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)