Пример #1
0
 def refresh(self, files=None):
     """overrides Show, files is {repos: [FileDescriptors], }"""
     if files is None:
         if get_facade() is None:
             return
         files = get_facade().get_document().get_shared_files()
     self.peerfiles_list.DeleteAllItems()
     if len(files) > 0:
         # reformat data
         file_data = []
         for file_descs in files.values():
             for file_desc in file_descs:
                 file_data.append([file_desc.get_path(), file_desc.name, file_desc._tag, file_desc.size])
         # clear previous data
         for key in self.data.keys():
             del self.data[key]
         # fill list
         for path, name, tag, size in file_data:
             index = self.peerfiles_list.InsertStringItem(sys.maxint, unicode(name, ENCODING))
             self.peerfiles_list.SetStringItem(index, TAG_COL, tag)
             self.peerfiles_list.SetStringItem(
                 index, SIZE_COL, formatbytes(size, kiloname="Ko", meganame="Mo", bytename="o")
             )
             self.data[index] = (path.split(os.sep), size)
     # show result
     self.peerfiles_list.SetColumnWidth(TAG_COL, wx.LIST_AUTOSIZE)
Пример #2
0
 def refresh(self, files=None):
     """overrides Show, files is {repos: [FileDescriptors], }"""
     if not self.IsShown():
         return
     if files is None:
         if get_facade() is None:
             return
         files = get_facade()._desc.document.get_shared_files()
     # clear previous data
     self.peerfiles_list.DeleteAllItems()
     for key in self.data.keys():
         del self.data[key]
     # fill new data
     for file_container in files.flatten():
         path = file_container.get_path()
         index = self.peerfiles_list.InsertStringItem(
             sys.maxint, force_unicode(file_container.name))
         self.peerfiles_list.SetStringItem(index, TAG_COL, file_container._tag)
         self.peerfiles_list.SetStringItem(index, SIZE_COL,
                                           formatbytes(file_container.size,
                                                       kiloname="Ko",
                                                       meganame="Mo",
                                                       bytename="o"))
         self.data[index] = (path.split(os.sep), file_container.size)
     # show result
     self.peerfiles_list.SetColumnWidth(TAG_COL, wx.LIST_AUTOSIZE)
Пример #3
0
 def _display_dir_content(self, dir_container):
     """update list view with content of directory"""
     self.dir_list.DeleteAllItems()
     for name, container in dir_container.iteritems():
         if isinstance(container, DirContainer):
             index = self.dir_list.InsertImageStringItem(sys.maxint, force_unicode(name), self.dir_fldridx)
             self.dir_list.SetItemTextColour(index, wx.LIGHT_GREY)
         else:
             index = self.dir_list.InsertImageStringItem(sys.maxint, force_unicode(name), self.dir_fileidx)
             self.dir_list.SetStringItem(index, SIZE_COL, formatbytes(container.size,
                                                                     kiloname="Ko",
                                                                     meganame="Mo",
                                                                     bytename="o"))
             self.dir_list.SetItemTextColour(index, container._shared and wx.BLUE or wx.BLACK)
             self.dir_list.SetStringItem(index, SHARED_COL, str(container._shared))
             self.dir_list.SetStringItem(index, TAG_COL, container._tag)
     self.dir_list.SetColumnWidth(TAG_COL, wx.LIST_AUTOSIZE)