Exemple #1
0
 def get_bean_from_row(self, row):
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         setattr(bean, key, row[num])
     return bean
Exemple #2
0
 def get_bean_from_row(self, row):
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         setattr(bean, key, row[num])
     return bean
Exemple #3
0
    def __init__(self, controls):
        FilterTreeControls.__init__(self, controls)

        FTreeModel.__init__(self)
        FControl.__init__(self, controls)

        self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.set_enable_tree_lines(True)
        """model config"""
        self.model = gtk.TreeStore(*FTreeModel().types())
        """filter config"""
        self.filter_model = self.model.filter_new()
        self.filter_model.set_visible_column(self.visible[0])
        self.set_model(self.filter_model)
        """connectors"""
        self.connect("button-press-event", self.on_button_press)
        self.connect("key-release-event", self.on_key_release)
        self.connect("row-expanded", self.on_row_expanded)
        self.connect('button_press_event', self.on_multi_button_press)
        self.connect('button_release_event', self.on_multi_button_release)

        self.count_index = 0

        self.set_reorderable(False)
        self.set_headers_visible(False)

        self.set_type_plain()

        self.active_UUID = -1

        self.defer_select = False

        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.add(self)
Exemple #4
0
 def use_filter(self):
     active = self.get_selected_bean()
     if active:
         if active.get_status() == DOWNLOAD_STATUS_ALL:
             self.dm_list.filter_by_file(None, FTreeModel().status[0])
         else:
             self.dm_list.filter_by_file(active.get_status(),
                                         FTreeModel().status[0])
Exemple #5
0
 def on_button_press(self, w, e):
     if is_double_left_click(e):
         active = self.get_selected_bean()
         if active:
             if active.get_status() == DOWNLOAD_STATUS_ALL:
                 self.dm_list.filter_by_file(None, FTreeModel().status[0])
             else:
                 self.dm_list.filter_by_file(active.get_status(),
                                             FTreeModel().status[0])
Exemple #6
0
    def get_row_from_bean(self, bean):
        attributes = []
        m_dict = FTreeModel().cut().__dict__
        new_dict = dict (zip(m_dict.values(), m_dict.keys()))

        for key in new_dict.values():
            value = getattr(bean, key)
            attributes.append(value)
        return attributes
Exemple #7
0
 def get_bean_from_model_iter(self, model, iter):
     if not model or not iter:
         return None
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         val = model.get_value(iter, num)
         setattr(bean, key, val)
     return bean
Exemple #8
0
 def get_bean_from_model_iter(self, model, iter):
     if not model or not iter:
         return None
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         val = model.get_value(iter, num)
         setattr(bean, key, val)
     return bean
Exemple #9
0
    def _get_bean_by_path(self, path):
        model = self.model
        path = self.filter_model.convert_path_to_child_path(path)
        iter = model.get_iter(path)

        if iter:
            bean = FModel()
            dt = FTreeModel().__dict__
            for key in dt.keys():
                setattr(bean, key, model.get_value(iter, dt[key][0]))
            return bean
        return None
Exemple #10
0
    def _get_bean_by_path(self, path):
        model = self.model
        path = self.filter_model.convert_path_to_child_path(path)
        iter = model.get_iter(path)

        if iter:
            bean = FModel()
            dt = FTreeModel().__dict__
            for key in dt.keys():
                setattr(bean, key, model.get_value(iter, dt[key][0]))
            return bean
        return None
Exemple #11
0
 def set_play_icon_to_bean_to_selected(self):
     
     for row in self.model:
         row[self.play_icon[0]] = None
     
     paths = self.get_selected_bean_paths()
     if not paths:
         return None
     
     path = paths[0]  
              
     iter = self.model.get_iter(path)
     self.model.set_value(iter, FTreeModel().play_icon[0], gtk.STOCK_GO_FORWARD)
     self.active_UUID = self.model.get_value(iter, FTreeModel().UUID[0])
Exemple #12
0
    def get_row_from_bean(self, bean):
        #logging.debug("get_row_from_bean %s" % bean)
        attributes = []
        m_dict = FTreeModel().cut().__dict__
        new_dict = dict (zip(m_dict.values(), m_dict.keys()))

        for key in new_dict.values():
            if not hasattr(bean, key):
                setattr(bean, key, None)
                
            value = getattr(bean, key)
            attributes.append(value)

        #logging.debug("get_row_from_bean attributes %s" % attributes)
        return attributes
Exemple #13
0
 def get_row_from_model_iter(self, model, iter):
     attributes = []
     size = len(FTreeModel().__dict__)
     for i in xrange(size):
         value = model.get_value(iter, i)
         attributes.append(value)
     return attributes
Exemple #14
0
    def on_load(self):
        if FC().tab_position == "no":
            self.set_tab_no()
        elif FC().tab_position == "left":
            self.set_tab_left()
        else:
            self.set_tab_top()

        for page in xrange(0, len(FCache().cache_pl_tab_contents)):
            if FCache().cache_pl_tab_contents[page] == []:
                self._append_tab(FCache().tab_pl_names[page])
                continue
            self._append_tab(FCache().tab_pl_names[page])

            model_len = len(FTreeModel().__dict__)
            cache_len = len(FCache().cache_pl_tab_contents[page][0])

            for row in FCache().cache_pl_tab_contents[page]:
                if model_len > cache_len:
                    for i in xrange(abs(model_len - cache_len)):
                        row.append((None, None))
                elif model_len < cache_len:
                    for i in xrange(abs(model_len - cache_len)):
                        del row[-1]

                self.get_current_tree().model.append(None, row)
Exemple #15
0
 def filter_by_file(self, query, column_num=FTreeModel().text[0]):        
     self.show_all_lines()
     
     if query and len(query.strip()) > 0:
         query = query.decode().strip().lower()
         self.file_filter(query, column_num)
         self.expand_all()
     else:
         self.collapse_all()
Exemple #16
0
 def update_bean(self, bean):
     for row in self.model:
         if row[self.UUID[0]] == bean.UUID:
             dict = FTreeModel().__dict__
             for key in dict:
                 value = getattr(bean, key)
                 row_num = dict[key][0]
                 row[row_num] = value
             break
Exemple #17
0
 def get_next_bean_to_dowload(self):
     all = self.get_all_beans()
     if not all:
         return None
     for bean in all:
         if bean.get_status() == DOWNLOAD_STATUS_ACTIVE:
             self.set_bean_column_value(bean,
                                        FTreeModel().status[0],
                                        DOWNLOAD_STATUS_LOCK)
             return bean
Exemple #18
0
 def update_statistics(self):
     statisctics = self.dm_list.get_status_statisctics()
     all = self.get_all_beans()
     for bean in all:
         status = bean.get_status()
         num = 0
         if status in statisctics:
             num = statisctics[status]
         value = bean.artist + " (%s)" % num
         self.set_bean_column_value(bean, FTreeModel().text[0], value)
Exemple #19
0
    def __init__(self, controls):        
        FilterTreeControls.__init__(self, controls)
        
        FTreeModel.__init__(self)
        FControl.__init__(self, controls)

        self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.set_enable_tree_lines(True)

        """model config"""
        self.model = gtk.TreeStore(*FTreeModel().types())

        """filter config"""
        self.filter_model = self.model.filter_new()
        self.filter_model.set_visible_column(self.visible[0])
        self.set_model(self.filter_model)

        """connectors"""
        self.connect("button-press-event", self.on_button_press)
        self.connect("key-release-event", self.on_key_release)
        self.connect("row-expanded", self.on_row_expanded)
        self.connect('button_press_event', self.on_multi_button_press)
        self.connect('button_release_event', self.on_multi_button_release)

        self.count_index = 0

        self.set_reorderable(False)
        self.set_headers_visible(False)

        self.set_type_plain()
        
        self.active_UUID = -1
        
        
        self.defer_select = False
        
        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.add(self)
Exemple #20
0
 def on_button_press(self, w, e):
     active = self.get_selected_bean()
     if active:
         active.type = FTYPE_NOT_UPDATE_INFO_PANEL
     else:
         return None
     
     if is_left_click(e):
         if active.get_status():
             if active.get_status() == DOWNLOAD_STATUS_ALL:
                 self.controls.dm.filter(None, FTreeModel().status[0])
             else:
                 self.controls.dm.filter(active.get_status(), FTreeModel().status[0])
             
     if is_double_left_click(e):
         self.controls.play(active)
     
     if is_rigth_click(e):
         menu = Popup()
         menu.add_item('Play', gtk.STOCK_MEDIA_PLAY, self.controls.play, active)
         menu.add_item('Copy to Search Line', gtk.STOCK_COPY, self.controls.searchPanel.set_search_text, active.text)            
         menu.show(e)
Exemple #21
0
 def update_status_for_beans(self, beans, status):
     for bean in beans:
         self.set_bean_column_value(bean, FTreeModel().status[0], status)
Exemple #22
0
 def update_status_for_all(self, status):
     beans = self.get_all_beans()
     for bean in beans:
         self.set_bean_column_value(bean, FTreeModel().status[0], status)